From 9118ac4faefa5d0ddc0602baa18fe38684edf503 Mon Sep 17 00:00:00 2001 From: Vladislav Yarmak Date: Sun, 28 May 2023 16:38:26 +0300 Subject: [PATCH] fix ext_ver param --- README.md | 1 + credservice.go | 5 +++-- holaapi.go | 13 +++++++------ main.go | 9 ++++++--- utils.go | 4 ++-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d0a0534..850d937 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,7 @@ zagent248.hola.org,165.22.65.3,22222,22223,22224,22225,22226,digitalocean | cafile | String | use custom CA certificate bundle file | | country | String | desired proxy location (default "us") | | dont-use-trial | - | use regular ports instead of trial ports | +| ext-ver | String | extension version to mimic in requests. Can be obtained from https://chrome.google.com/webstore/detail/hola-vpn-the-website-unbl/gkojfkhlekighikafcpjkiklfbnlmeio (default "999.999.999") | | force-port-field | Number | force specific port field/num (example 24232 or lum) | | limit | Unsigned Integer (Number) | amount of proxies in retrieved list (default 3) | | list-countries | String | list available countries and exit | diff --git a/credservice.go b/credservice.go index 675c66d..24ce152 100644 --- a/credservice.go +++ b/credservice.go @@ -10,6 +10,7 @@ import ( const DEFAULT_LIST_LIMIT = 3 func CredService(interval, timeout time.Duration, + extVer string, country string, proxytype string, logger *CondLogger, @@ -26,7 +27,7 @@ func CredService(interval, timeout time.Duration, } tx_res, tx_err := EnsureTransaction(context.Background(), timeout, func(ctx context.Context, client *http.Client) bool { - tunnels, user_uuid, err = Tunnels(ctx, logger, client, country, proxytype, + tunnels, user_uuid, err = Tunnels(ctx, logger, client, extVer, country, proxytype, DEFAULT_LIST_LIMIT, timeout, backoffInitial, backoffDeadline) if err != nil { logger.Error("Configuration bootstrap error: %v. Retrying with the fallback mechanism...", err) @@ -57,7 +58,7 @@ func CredService(interval, timeout time.Duration, <-ticker.C logger.Info("Rotating credentials...") tx_res, tx_err := EnsureTransaction(context.Background(), timeout, func(ctx context.Context, client *http.Client) bool { - tuns, user_uuid, err = Tunnels(ctx, logger, client, country, proxytype, + tuns, user_uuid, err = Tunnels(ctx, logger, client, extVer, country, proxytype, DEFAULT_LIST_LIMIT, timeout, backoffInitial, backoffDeadline) if err != nil { logger.Error("Credential rotation error: %v. Retrying with the fallback mechanism...", err) diff --git a/holaapi.go b/holaapi.go index a09055c..5a19a3d 100644 --- a/holaapi.go +++ b/holaapi.go @@ -25,7 +25,6 @@ import ( ) const USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" -const EXT_VER = "1.210.946" const EXT_BROWSER = "chrome" const PRODUCT = "cws" const CCGI_URL = "https://client.hola.org/client_cgi/" @@ -193,10 +192,10 @@ func VPNCountries(ctx context.Context, client *http.Client) (res CountryList, er return } -func background_init(ctx context.Context, client *http.Client, user_uuid string) (res BgInitResponse, reterr error) { +func background_init(ctx context.Context, client *http.Client, extVer, user_uuid string) (res BgInitResponse, reterr error) { post_data := make(url.Values) post_data.Add("login", "1") - post_data.Add("ver", EXT_VER) + post_data.Add("ver", extVer) qs := make(url.Values) qs.Add("uuid", user_uuid) resp, err := do_req(ctx, client, "POST", BG_INIT_URL, qs, post_data) @@ -220,6 +219,7 @@ func zgettunnels(ctx context.Context, client *http.Client, user_uuid string, session_key int64, + extVer string, country string, proxy_type string, limit uint) (res *ZGetTunnelsResponse, reterr error) { @@ -239,7 +239,7 @@ func zgettunnels(ctx context.Context, } params.Add("limit", strconv.FormatInt(int64(limit), 10)) params.Add("ping_id", strconv.FormatFloat(rand.New(RandomSource).Float64(), 'f', -1, 64)) - params.Add("ext_ver", EXT_VER) + params.Add("ext_ver", extVer) params.Add("browser", EXT_BROWSER) params.Add("product", PRODUCT) params.Add("uuid", user_uuid) @@ -325,6 +325,7 @@ func GetFallbackProxies(ctx context.Context) (*FallbackConfig, error) { func Tunnels(ctx context.Context, logger *CondLogger, client *http.Client, + extVer string, country string, proxy_type string, limit uint, @@ -336,7 +337,7 @@ func Tunnels(ctx context.Context, user_uuid = hex.EncodeToString(u[:]) ctx1, cancel := context.WithTimeout(ctx, timeout) defer cancel() - initres, err := background_init(ctx1, client, user_uuid) + initres, err := background_init(ctx1, client, extVer, user_uuid) if err != nil { reterr = err return @@ -354,7 +355,7 @@ func Tunnels(ctx context.Context, err = backoff.RetryNotify(func() error { ctx1, cancel := context.WithTimeout(ctx, timeout) defer cancel() - res, reterr = zgettunnels(ctx1, client, user_uuid, initres.Key, country, proxy_type, limit) + res, reterr = zgettunnels(ctx1, client, user_uuid, initres.Key, extVer, country, proxy_type, limit) return reterr }, bo, func(err error, dur time.Duration) { logger.Info("zgettunnels error: %v; will retry after %v", err, dur.Truncate(time.Millisecond)) diff --git a/main.go b/main.go index f74c2e0..2f03fd5 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ func arg_fail(msg string) { } type CLIArgs struct { + extVer string country string list_countries, list_proxies, use_trial bool limit uint @@ -62,6 +63,8 @@ type CLIArgs struct { func parse_args() CLIArgs { var args CLIArgs + flag.StringVar(&args.extVer, "ext-ver", "999.999.999", "extension version to mimic in requests. "+ + "Can be obtained from https://chrome.google.com/webstore/detail/hola-vpn-the-website-unbl/gkojfkhlekighikafcpjkiklfbnlmeio") flag.StringVar(&args.force_port_field, "force-port-field", "", "force specific port field/num (example 24232 or lum)") // would be nice to not show in help page flag.StringVar(&args.country, "country", "us", "desired proxy location") flag.BoolVar(&args.list_countries, "list-countries", false, "list available countries and exit") @@ -171,7 +174,7 @@ func run() int { } if args.list_proxies { - return print_proxies(mainLogger, args.country, args.proxy_type, args.limit, args.timeout, + return print_proxies(mainLogger, args.extVer, args.country, args.proxy_type, args.limit, args.timeout, args.backoffInitial, args.backoffDeadline) } @@ -184,8 +187,8 @@ func run() int { } mainLogger.Info("Initializing configuration provider...") - auth, tunnels, err := CredService(args.rotate, args.timeout, args.country, args.proxy_type, credLogger, - args.backoffInitial, args.backoffDeadline) + auth, tunnels, err := CredService(args.rotate, args.timeout, args.extVer, args.country, + args.proxy_type, credLogger, args.backoffInitial, args.backoffDeadline) if err != nil { mainLogger.Critical("Unable to instantiate credential service: %v", err) return 4 diff --git a/utils.go b/utils.go index 9bf1b15..f147f4e 100644 --- a/utils.go +++ b/utils.go @@ -135,7 +135,7 @@ func print_countries(timeout time.Duration) int { return 0 } -func print_proxies(logger *CondLogger, country string, proxy_type string, +func print_proxies(logger *CondLogger, extVer, country string, proxy_type string, limit uint, timeout time.Duration, backoffInitial time.Duration, backoffDeadline time.Duration, ) int { var ( @@ -144,7 +144,7 @@ func print_proxies(logger *CondLogger, country string, proxy_type 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, logger, client, country, proxy_type, limit, timeout, backoffInitial, backoffDeadline) + tunnels, user_uuid, err = Tunnels(ctx, logger, client, extVer, country, proxy_type, limit, timeout, backoffInitial, backoffDeadline) if err != nil { fmt.Fprintf(os.Stderr, "Transaction error: %v. Retrying with the fallback mechanism...\n", err) return false