Skip to content

Commit

Permalink
Merge pull request #278 from 9seconds/socks5-proxies-for-simple-run
Browse files Browse the repository at this point in the history
Add parameter for a simple run that sets socks5 proxies up
  • Loading branch information
9seconds authored Aug 9, 2022
2 parents db2be40 + 7e3e4a6 commit bd8a7ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/cli/simple_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ type SimpleRun struct {
DomainFrontingPort uint64 `kong:"name='domain-fronting-port',short='p',default='443',help='A port to access for domain fronting.'"` //nolint: lll
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
Timeout time.Duration `kong:"name='timeout',short='t',default='10s',help='Network timeout to use'"` //nolint: lll
Socks5Proxies []string `kong:"name='socks5-proxy',short='s',help='Socks5 proxies to use for network access.'"` //nolint: lll
AntiReplayCacheSize string `kong:"name='antireplay-cache-size',short='a',default='1MB',help='A size of anti-replay cache to use.'"` //nolint: lll
}

func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop
func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funlen
conf := &config.Config{}

if err := conf.BindTo.Set(s.BindTo); err != nil {
Expand Down Expand Up @@ -66,6 +67,16 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop
return fmt.Errorf("incorrect antireplay-cache-size: %w", err)
}

for _, v := range s.Socks5Proxies {
proxyURL := config.TypeProxyURL{}

if err := proxyURL.Set(v); err != nil {
return fmt.Errorf("incorrect socks5 proxy URL: %w", err)
}

conf.Network.Proxies = append(conf.Network.Proxies, proxyURL)
}

conf.Debug.Value = s.Debug
conf.AllowFallbackOnUnknownDC.Value = true
conf.Defense.AntiReplay.Enabled.Value = true
Expand Down

0 comments on commit bd8a7ed

Please sign in to comment.