@@ -29,7 +29,37 @@ GitHub: https://github.com/shadowy-pycoder/go-http-proxy-to-socks
2929
3030Usage: gohpts [OPTIONS]
3131Options:
32- -h Show this help message and exit.
32+ -h Show this help message and exit
33+ -v Show version and build information
34+ -D Run as a daemon (provide -logfile to see logs)
35+
36+ Proxy:
37+ -l Address of HTTP proxy server (default "127.0.0.1:8080")
38+ -s Address of SOCKS5 proxy server (default "127.0.0.1:1080")
39+ -c Path to certificate PEM encoded file
40+ -k Path to private key PEM encoded file
41+ -U User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)
42+ -u User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal)
43+ -f Path to server configuration file in YAML format (overrides other proxy flags)
44+
45+ Logs:
46+ -d Show logs in DEBUG mode
47+ -j Show logs in JSON format
48+ -logfile Log file path (Default: stdout)
49+ -nocolor Disable colored output for logs (no effect if -j flag specified)
50+
51+ Sniffing:
52+ -sniff Enable traffic sniffing for HTTP and TLS
53+ -snifflog Sniffed traffic log file path (Default: the same as -logfile)
54+ -body Collect request and response body for HTTP traffic (credentials, tokens, etc)
55+ `
56+ const usageTproxy string = `
57+ TProxy:
58+ -t Address of transparent proxy server (it starts along with HTTP proxy server)
59+ -T Address of transparent proxy server (no HTTP)
60+ -M Transparent proxy mode: (redirect, tproxy)
61+ -auto Automatically setup iptables for transparent proxy (requires elevated privileges)
62+ -mark Set mark for each packet sent through transparent proxy (Default: redirect 0, tproxy 100)
3363`
3464
3565func root (args []string ) error {
@@ -41,7 +71,7 @@ func root(args []string) error {
4171 flags .StringVar (& conf .ServerUser , "U" , "" , "User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)" )
4272 flags .StringVar (& conf .CertFile , "c" , "" , "Path to certificate PEM encoded file" )
4373 flags .StringVar (& conf .KeyFile , "k" , "" , "Path to private key PEM encoded file" )
44- flags .StringVar (& conf .ServerConfPath , "f" , "" , "Path to server configuration file in YAML format" )
74+ flags .StringVar (& conf .ServerConfPath , "f" , "" , "Path to server configuration file in YAML format (overrides other proxy flags) " )
4575 daemon := flags .Bool ("D" , false , "Run as a daemon (provide -logfile to see logs)" )
4676 if runtime .GOOS == tproxyOS {
4777 flags .StringVar (& conf .TProxy , "t" , "" , "Address of transparent proxy server (it starts along with HTTP proxy server)" )
@@ -55,24 +85,26 @@ func root(args []string) error {
5585 return nil
5686 })
5787 flags .BoolVar (& conf .Auto , "auto" , false , "Automatically setup iptables for transparent proxy (requires elevated privileges)" )
58- flags .UintVar (& conf .Mark , "mark" , 0 , "Set the mark for each packet sent through transparent proxy" )
88+ flags .UintVar (& conf .Mark , "mark" , 0 , "Set mark for each packet sent through transparent proxy (Default: redirect 0, tproxy 100) " )
5989 }
6090 flags .StringVar (& conf .LogFilePath , "logfile" , "" , "Log file path (Default: stdout)" )
6191 flags .BoolVar (& conf .Debug , "d" , false , "Show logs in DEBUG mode" )
6292 flags .BoolVar (& conf .Json , "j" , false , "Show logs in JSON format" )
6393 flags .BoolVar (& conf .Sniff , "sniff" , false , "Enable traffic sniffing for HTTP and TLS" )
6494 flags .StringVar (& conf .SniffLogFile , "snifflog" , "" , "Sniffed traffic log file path (Default: the same as -logfile)" )
6595 flags .BoolVar (& conf .NoColor , "nocolor" , false , "Disable colored output for logs (no effect if -j flag specified)" )
66- flags .BoolVar (& conf .Body , "body" , false , "Collect request and response body for HTTP sniffing " )
67- flags .BoolFunc ("v" , "print version" , func (flagValue string ) error {
96+ flags .BoolVar (& conf .Body , "body" , false , "Collect request and response body for HTTP traffic (credentials, tokens, etc) " )
97+ flags .BoolFunc ("v" , "Show version and build information " , func (flagValue string ) error {
6898 fmt .Printf ("%s (built for %s %s with %s)\n " , gohpts .Version , runtime .GOOS , runtime .GOARCH , runtime .Version ())
6999 os .Exit (0 )
70100 return nil
71101 })
72102
73103 flags .Usage = func () {
74104 fmt .Print (usagePrefix )
75- flags .PrintDefaults ()
105+ if runtime .GOOS == tproxyOS {
106+ fmt .Print (usageTproxy )
107+ }
76108 }
77109
78110 if err := flags .Parse (args ); err != nil {
@@ -107,9 +139,6 @@ func root(args []string) error {
107139 if ! seen ["t" ] && ! seen ["T" ] {
108140 return fmt .Errorf ("-auto requires -t or -T flag" )
109141 }
110- if conf .TProxyMode != "redirect" {
111- return fmt .Errorf ("-auto is available only for -M redirect" )
112- }
113142 }
114143 if seen ["mark" ] {
115144 if ! seen ["t" ] && ! seen ["T" ] {
0 commit comments