mirror of
https://github.com/Alexey71/opera-proxy.git
synced 2026-05-13 22:20:59 +00:00
main: implement list-proxies; remove SNI completely
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
"crypto/tls"
|
||||||
|
"strings"
|
||||||
|
|
||||||
xproxy "golang.org/x/net/proxy"
|
xproxy "golang.org/x/net/proxy"
|
||||||
|
|
||||||
@@ -130,6 +132,12 @@ func run() int {
|
|||||||
MaxIdleConns: 100,
|
MaxIdleConns: 100,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
// Dialing w/o SNI, receiving self-signed certificate, so skip verification.
|
||||||
|
// Either way we'll validate certificate of actual proxy server.
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
ServerName: "",
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
},
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -166,8 +174,7 @@ func run() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if args.listProxies {
|
if args.listProxies {
|
||||||
//return printProxies(args.country, args.proxy_type, args.limit, args.timeout)
|
return printProxies(ips, seclient)
|
||||||
return 666
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ips) == 0 {
|
if len(ips) == 0 {
|
||||||
@@ -210,50 +217,24 @@ func printCountries(logger *CondLogger, timeout time.Duration, seclient *se.SECl
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func printProxies(country string, proxy_type string, limit uint, timeout time.Duration) int {
|
func printProxies(ips []se.SEIPEntry, seclient *se.SEClient) int {
|
||||||
/*var (
|
|
||||||
tunnels *ZGetTunnelsResponse
|
|
||||||
user_uuid string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
tx_res, tx_err := EnsureTransaction(context.Background(), timeout, func(ctx context.Context, client *http.Client) bool {
|
|
||||||
tunnels, user_uuid, err = Tunnels(ctx, client, country, proxy_type, limit)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "Transaction error: %v. Retrying with the fallback mechanism...\n", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
if tx_err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "Transaction recovery mechanism failure: %v.\n", tx_err)
|
|
||||||
return 4
|
|
||||||
}
|
|
||||||
if !tx_res {
|
|
||||||
fmt.Fprintf(os.Stderr, "All attempts failed.")
|
|
||||||
return 3
|
|
||||||
}
|
|
||||||
wr := csv.NewWriter(os.Stdout)
|
wr := csv.NewWriter(os.Stdout)
|
||||||
login := LOGIN_PREFIX + user_uuid
|
defer wr.Flush()
|
||||||
password := tunnels.AgentKey
|
login, password := seclient.GetProxyCredentials()
|
||||||
fmt.Println("Login:", login)
|
fmt.Println("Proxy login:", login)
|
||||||
fmt.Println("Password:", password)
|
fmt.Println("Proxy password:", password)
|
||||||
fmt.Println("Proxy-Authorization:",
|
fmt.Println("Proxy-Authorization:", basic_auth_header(login, password))
|
||||||
basic_auth_header(login, password))
|
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
wr.Write([]string{"host", "ip_address", "direct", "peer", "hola", "trial", "trial_peer", "vendor"})
|
wr.Write([]string{"host", "ip_address", "port"})
|
||||||
for host, ip := range tunnels.IPList {
|
for i, ip := range ips {
|
||||||
if PROTOCOL_WHITELIST[tunnels.Protocol[host]] {
|
for _, port := range ip.Ports {
|
||||||
wr.Write([]string{host,
|
wr.Write([]string{
|
||||||
ip,
|
fmt.Sprintf("%s%d.sec-tunnel.com", strings.ToLower(ip.Geo.CountryCode), i),
|
||||||
strconv.FormatUint(uint64(tunnels.Port.Direct), 10),
|
ip.IP,
|
||||||
strconv.FormatUint(uint64(tunnels.Port.Peer), 10),
|
fmt.Sprintf("%d", port),
|
||||||
strconv.FormatUint(uint64(tunnels.Port.Hola), 10),
|
})
|
||||||
strconv.FormatUint(uint64(tunnels.Port.Trial), 10),
|
|
||||||
strconv.FormatUint(uint64(tunnels.Port.TrialPeer), 10),
|
|
||||||
tunnels.Vendor[host]})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wr.Flush()*/
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user