Parcourir la source

Add parameter for a simple run that sets socks5 proxies up

tags/v2.1.7^2^2
9seconds il y a 3 ans
Parent
révision
7e3e4a611d
1 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. 12
    1
      internal/cli/simple_run.go

+ 12
- 1
internal/cli/simple_run.go Voir le fichier

@@ -20,10 +20,11 @@ type SimpleRun struct {
20 20
 	DomainFrontingPort  uint64        `kong:"name='domain-fronting-port',short='p',default='443',help='A port to access for domain fronting.'"`                        //nolint: lll
21 21
 	DOHIP               net.IP        `kong:"name='doh-ip',short='n',default='9.9.9.9',help='IP address of DNS-over-HTTP to use.'"`                                    //nolint: lll
22 22
 	Timeout             time.Duration `kong:"name='timeout',short='t',default='10s',help='Network timeout to use'"`                                                    //nolint: lll
23
+	Socks5Proxies       []string      `kong:"name='socks5-proxy',short='s',help='Socks5 proxies to use for network access.'"`                                          //nolint: lll
23 24
 	AntiReplayCacheSize string        `kong:"name='antireplay-cache-size',short='a',default='1MB',help='A size of anti-replay cache to use.'"`                         //nolint: lll
24 25
 }
25 26
 
26
-func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop
27
+func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funlen
27 28
 	conf := &config.Config{}
28 29
 
29 30
 	if err := conf.BindTo.Set(s.BindTo); err != nil {
@@ -66,6 +67,16 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop
66 67
 		return fmt.Errorf("incorrect antireplay-cache-size: %w", err)
67 68
 	}
68 69
 
70
+	for _, v := range s.Socks5Proxies {
71
+		proxyURL := config.TypeProxyURL{}
72
+
73
+		if err := proxyURL.Set(v); err != nil {
74
+			return fmt.Errorf("incorrect socks5 proxy URL: %w", err)
75
+		}
76
+
77
+		conf.Network.Proxies = append(conf.Network.Proxies, proxyURL)
78
+	}
79
+
69 80
 	conf.Debug.Value = s.Debug
70 81
 	conf.AllowFallbackOnUnknownDC.Value = true
71 82
 	conf.Defense.AntiReplay.Enabled.Value = true

Chargement…
Annuler
Enregistrer