mirror of
https://github.com/Alexey71/opera-proxy.git
synced 2026-05-15 07:01:00 +00:00
@@ -100,6 +100,7 @@ eu3.sec-tunnel.com,77.111.244.22,443
|
||||
| bootstrap-dns | String | Comma-separated list of DNS/DoH/DoT resolvers for initial discovery of SurfEasy API address. Supported schemes are: `dns://`, `https://`, `tls://`, `tcp://`. Examples: `https://1.1.1.1/dns-query`, `tls://9.9.9.9:853` (default `https://1.1.1.3/dns-query,https://8.8.8.8/dns-query,https://dns.google/dns-query,https://security.cloudflare-dns.com/dns-query,https://fidelity.vm-0.com/q,https://wikimedia-dns.org/dns-query,https://dns.adguard-dns.com/dns-query,https://dns.quad9.net/dns-query,https://doh.cleanbrowsing.org/doh/adult-filter/`) |
|
||||
| cafile | String | use custom CA certificate bundle file |
|
||||
| certchain-workaround | Boolean | add bundled cross-signed intermediate cert to certchain to make it check out on old systems (default true) |
|
||||
| config | String | read configuration from file with space-separated keys and values |
|
||||
| country | String | desired proxy location (default "EU") |
|
||||
| dp-export | - | export configuration for dumbproxy |
|
||||
| fake-SNI | String | domain name to use as SNI in communications with servers |
|
||||
|
||||
@@ -184,6 +184,7 @@ func parse_args() *CLIArgs {
|
||||
flag.StringVar(&args.serverSelectionTestURL, "server-selection-test-url", "https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js",
|
||||
"URL used for download benchmark by fastest server selection policy")
|
||||
flag.Int64Var(&args.serverSelectionDLLimit, "server-selection-dl-limit", 0, "restrict amount of downloaded data per connection by fastest server selection")
|
||||
flag.Func("config", "read configuration from file with space-separated keys and values", readConfig)
|
||||
flag.Parse()
|
||||
if args.country == "" {
|
||||
arg_fail("Country can't be empty string.")
|
||||
@@ -586,6 +587,50 @@ func retryPolicy(retries int, retryInterval time.Duration, logger *clog.CondLogg
|
||||
}
|
||||
}
|
||||
|
||||
func readConfig(filename string) error {
|
||||
f, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to open config file %q: %w", filename, err)
|
||||
}
|
||||
defer f.Close()
|
||||
r := csv.NewReader(f)
|
||||
r.Comma = ' '
|
||||
r.Comment = '#'
|
||||
r.FieldsPerRecord = -1
|
||||
r.TrimLeadingSpace = true
|
||||
r.ReuseRecord = true
|
||||
for {
|
||||
record, err := r.Read()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("configuration file parsing failed: %w", err)
|
||||
}
|
||||
switch len(record) {
|
||||
case 0:
|
||||
continue
|
||||
case 1:
|
||||
if err := flag.Set(record[0], "true"); err != nil {
|
||||
line, _ := r.FieldPos(0)
|
||||
return fmt.Errorf("error parsing config file %q at line %d (%#v): %w", filename, line, record, err)
|
||||
}
|
||||
case 2:
|
||||
if err := flag.Set(record[0], record[1]); err != nil {
|
||||
line, _ := r.FieldPos(0)
|
||||
return fmt.Errorf("error parsing config file %q at line %d (%#v): %w", filename, line, record, err)
|
||||
}
|
||||
default:
|
||||
unified := strings.Join(record[1:], " ")
|
||||
if err := flag.Set(record[0], unified); err != nil {
|
||||
line, _ := r.FieldPos(0)
|
||||
return fmt.Errorf("error parsing config file %q at line %d (%#v): %w", filename, line, record, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func version() string {
|
||||
bi, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user