88 "slices"
99
1010 gohpts "github.com/shadowy-pycoder/go-http-proxy-to-socks"
11+ "github.com/shadowy-pycoder/mshark/network"
1112 "golang.org/x/term"
1213)
1314
@@ -33,15 +34,17 @@ Options:
3334 -h Show this help message and exit
3435 -v Show version and build information
3536 -D Run as a daemon (provide -logfile to see logs)
37+ -I Display list of network interfaces and exit
3638
3739 Proxy:
38- -l Address of HTTP proxy server (default "127.0.0.1:8080")
39- -s Address of SOCKS5 proxy server (default "127.0.0.1:1080")
40+ -l Address of HTTP proxy server (Default: "127.0.0.1:8080")
41+ -s Address of SOCKS5 proxy server (Default: "127.0.0.1:1080")
4042 -c Path to certificate PEM encoded file
4143 -k Path to private key PEM encoded file
4244 -U User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)
4345 -u User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal)
44- -f Path to server configuration file in YAML format (overrides other proxy flags)
46+ -i Bind proxy to specific network interface (either by interface name or index)
47+ -f Path to server configuration file in YAML format (overrides proxy flags above)
4548
4649 Logs:
4750 -d Show logs in DEBUG mode
@@ -90,6 +93,15 @@ func root(args []string) error {
9093 "" ,
9194 "Path to server configuration file in YAML format (overrides other proxy flags)" ,
9295 )
96+ flags .StringVar (& conf .Interface , "i" , "" , "Bind proxy to specific network interface" )
97+ flags .BoolFunc ("I" , "Display list of network interfaces and exit" , func (flagValue string ) error {
98+ if err := network .DisplayInterfaces (); err != nil {
99+ fmt .Fprintf (os .Stderr , "%s: %v\n " , app , err )
100+ os .Exit (2 )
101+ }
102+ os .Exit (0 )
103+ return nil
104+ })
93105 daemon := flags .Bool ("D" , false , "Run as a daemon (provide -logfile to see logs)" )
94106 if runtime .GOOS == tproxyOS {
95107 flags .StringVar (& conf .TProxy , "t" , "" , "Address of transparent proxy server (it starts along with HTTP proxy server)" )
@@ -157,7 +169,7 @@ func root(args []string) error {
157169 if seen ["T" ] {
158170 for _ , da := range []string {"U" , "c" , "k" , "l" } {
159171 if seen [da ] {
160- return fmt .Errorf ("-T flag only works with -s , -u , -f , -M, -d, -D, -logfile, -sniff, -snifflog and -j flags" )
172+ return fmt .Errorf ("-T flag does not work with -U , -c , -k , -l flags" )
161173 }
162174 }
163175 if ! seen ["M" ] {
@@ -180,12 +192,9 @@ func root(args []string) error {
180192 }
181193 }
182194 if seen ["f" ] {
183- for _ , da := range []string {"s" , "u" , "U" , "c" , "k" , "l" } {
195+ for _ , da := range []string {"s" , "u" , "U" , "c" , "k" , "l" , "i" } {
184196 if seen [da ] {
185- if runtime .GOOS == tproxyOS {
186- return fmt .Errorf ("-f flag only works with -t, -T, -M, -d, -D, -logfile, -sniff, -snifflog and -j flags" )
187- }
188- return fmt .Errorf ("-f flag only works with -d, -D, -logfile, -sniff, -snifflog and -j flags" )
197+ return fmt .Errorf ("-f flag does not work with other proxy flags specified" )
189198 }
190199 }
191200 }
0 commit comments