mirror of
https://github.com/Snawoot/opera-proxy.git
synced 2025-09-02 10:42:07 +00:00
run ticker only in proxy mode
This commit is contained in:
parent
0d32dc273f
commit
1deeb512cf
1 changed files with 21 additions and 21 deletions
42
main.go
42
main.go
|
@ -208,6 +208,27 @@ func run() int {
|
||||||
}
|
}
|
||||||
cl()
|
cl()
|
||||||
|
|
||||||
|
if args.listCountries {
|
||||||
|
return printCountries(mainLogger, args.timeout, seclient)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cl = context.WithTimeout(context.Background(), args.timeout)
|
||||||
|
// TODO: learn about requested_geo value format
|
||||||
|
ips, err := seclient.Discover(ctx, fmt.Sprintf("\"%s\",,", args.country))
|
||||||
|
if err != nil {
|
||||||
|
mainLogger.Critical("Endpoint discovery failed: %v", err)
|
||||||
|
return 12
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.listProxies {
|
||||||
|
return printProxies(ips, seclient)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ips) == 0 {
|
||||||
|
mainLogger.Critical("Empty endpoint list!")
|
||||||
|
return 13
|
||||||
|
}
|
||||||
|
|
||||||
runTicker(context.Background(), args.refresh, func(ctx context.Context) {
|
runTicker(context.Background(), args.refresh, func(ctx context.Context) {
|
||||||
mainLogger.Info("Refreshing login...")
|
mainLogger.Info("Refreshing login...")
|
||||||
reqCtx, cl := context.WithTimeout(ctx, args.timeout)
|
reqCtx, cl := context.WithTimeout(ctx, args.timeout)
|
||||||
|
@ -230,27 +251,6 @@ func run() int {
|
||||||
mainLogger.Info("Device password refreshed.")
|
mainLogger.Info("Device password refreshed.")
|
||||||
})
|
})
|
||||||
|
|
||||||
if args.listCountries {
|
|
||||||
return printCountries(mainLogger, args.timeout, seclient)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cl = context.WithTimeout(context.Background(), args.timeout)
|
|
||||||
// TODO: learn about requested_geo value format
|
|
||||||
ips, err := seclient.Discover(ctx, fmt.Sprintf("\"%s\",,", args.country))
|
|
||||||
if err != nil {
|
|
||||||
mainLogger.Critical("Endpoint discovery failed: %v", err)
|
|
||||||
return 12
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.listProxies {
|
|
||||||
return printProxies(ips, seclient)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ips) == 0 {
|
|
||||||
mainLogger.Critical("Empty endpoint list!")
|
|
||||||
return 13
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint := ips[0]
|
endpoint := ips[0]
|
||||||
auth := func() string {
|
auth := func() string {
|
||||||
return basic_auth_header(seclient.GetProxyCredentials())
|
return basic_auth_header(seclient.GetProxyCredentials())
|
||||||
|
|
Loading…
Add table
Reference in a new issue