Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ You can download the binary for your platform from [Releases](https://github.com
Example:

```shell
HPTS_RELEASE=v1.9.2; wget -v https://github.com/shadowy-pycoder/go-http-proxy-to-socks/releases/download/$HPTS_RELEASE/gohpts-$HPTS_RELEASE-linux-amd64.tar.gz -O gohpts && tar xvzf gohpts && mv -f gohpts-$HPTS_RELEASE-linux-amd64 gohpts && ./gohpts -h
GOHPTS_RELEASE=v1.9.3; wget -v https://github.com/shadowy-pycoder/go-http-proxy-to-socks/releases/download/$GOHPTS_RELEASE/gohpts-$GOHPTS_RELEASE-linux-amd64.tar.gz -O gohpts && tar xvzf gohpts && mv -f gohpts-$GOHPTS_RELEASE-linux-amd64 gohpts && ./gohpts -h
```

Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later):
Expand Down Expand Up @@ -142,15 +142,17 @@ Options:
-h Show this help message and exit
-v Show version and build information
-D Run as a daemon (provide -logfile to see logs)
-I Display list of network interfaces and exit

Proxy:
-l Address of HTTP proxy server (default "127.0.0.1:8080")
-s Address of SOCKS5 proxy server (default "127.0.0.1:1080")
-l Address of HTTP proxy server (Default: "127.0.0.1:8080")
-s Address of SOCKS5 proxy server (Default: "127.0.0.1:1080")
-c Path to certificate PEM encoded file
-k Path to private key PEM encoded file
-U User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)
-u User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal)
-f Path to server configuration file in YAML format (overrides other proxy flags)
-i Bind proxy to specific network interface (either by interface name or index)
-f Path to server configuration file in YAML format (overrides proxy flags above)

Logs:
-d Show logs in DEBUG mode
Expand Down Expand Up @@ -279,7 +281,8 @@ proxy_list:
- address: 127.0.0.1:1081
- address: :1082 # empty host means localhost
server:
address: 127.0.0.1:8080 # the only required field in this section
address: 127.0.0.1:8080 # the only required field in this section (ignored when -T flag specified)
interface: "eth0" # if specified, overrides server address
# these are for adding basic authentication
username: username
password: password
Expand Down
27 changes: 18 additions & 9 deletions cmd/gohpts/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"slices"

gohpts "github.com/shadowy-pycoder/go-http-proxy-to-socks"
"github.com/shadowy-pycoder/mshark/network"
"golang.org/x/term"
)

Expand All @@ -33,15 +34,17 @@ Options:
-h Show this help message and exit
-v Show version and build information
-D Run as a daemon (provide -logfile to see logs)
-I Display list of network interfaces and exit

Proxy:
-l Address of HTTP proxy server (default "127.0.0.1:8080")
-s Address of SOCKS5 proxy server (default "127.0.0.1:1080")
-l Address of HTTP proxy server (Default: "127.0.0.1:8080")
-s Address of SOCKS5 proxy server (Default: "127.0.0.1:1080")
-c Path to certificate PEM encoded file
-k Path to private key PEM encoded file
-U User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)
-u User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal)
-f Path to server configuration file in YAML format (overrides other proxy flags)
-i Bind proxy to specific network interface (either by interface name or index)
-f Path to server configuration file in YAML format (overrides proxy flags above)

Logs:
-d Show logs in DEBUG mode
Expand Down Expand Up @@ -90,6 +93,15 @@ func root(args []string) error {
"",
"Path to server configuration file in YAML format (overrides other proxy flags)",
)
flags.StringVar(&conf.Interface, "i", "", "Bind proxy to specific network interface")
flags.BoolFunc("I", "Display list of network interfaces and exit", func(flagValue string) error {
if err := network.DisplayInterfaces(); err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", app, err)
os.Exit(2)
}
os.Exit(0)
return nil
})
daemon := flags.Bool("D", false, "Run as a daemon (provide -logfile to see logs)")
if runtime.GOOS == tproxyOS {
flags.StringVar(&conf.TProxy, "t", "", "Address of transparent proxy server (it starts along with HTTP proxy server)")
Expand Down Expand Up @@ -157,7 +169,7 @@ func root(args []string) error {
if seen["T"] {
for _, da := range []string{"U", "c", "k", "l"} {
if seen[da] {
return fmt.Errorf("-T flag only works with -s, -u, -f, -M, -d, -D, -logfile, -sniff, -snifflog and -j flags")
return fmt.Errorf("-T flag does not work with -U, -c, -k, -l flags")
}
}
if !seen["M"] {
Expand All @@ -180,12 +192,9 @@ func root(args []string) error {
}
}
if seen["f"] {
for _, da := range []string{"s", "u", "U", "c", "k", "l"} {
for _, da := range []string{"s", "u", "U", "c", "k", "l", "i"} {
if seen[da] {
if runtime.GOOS == tproxyOS {
return fmt.Errorf("-f flag only works with -t, -T, -M, -d, -D, -logfile, -sniff, -snifflog and -j flags")
}
return fmt.Errorf("-f flag only works with -d, -D, -logfile, -sniff, -snifflog and -j flags")
return fmt.Errorf("-f flag does not work with other proxy flags specified")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/google/uuid v1.6.0
github.com/rs/zerolog v1.34.0
github.com/shadowy-pycoder/colors v0.0.1
github.com/shadowy-pycoder/mshark v0.0.8
github.com/shadowy-pycoder/mshark v0.0.9
golang.org/x/net v0.40.0
golang.org/x/sys v0.33.0
golang.org/x/term v0.32.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
github.com/shadowy-pycoder/colors v0.0.1 h1:weCj/YIOupqy4BSP8KuVzr20fC+cuAv/tArz7bhhkP4=
github.com/shadowy-pycoder/colors v0.0.1/go.mod h1:lkrJS1PY2oVigNLTT6pkbF7B/v0YcU2LD5PZnss1Q4U=
github.com/shadowy-pycoder/mshark v0.0.8 h1:7kuVgX9Qp4Q9nGl9Gi7UOaNFUnOF0I2Vpfmc4X3GLug=
github.com/shadowy-pycoder/mshark v0.0.8/go.mod h1:FqbHFdsx0zMnrZZH0+oPzaFcleP4O+tUWv8i5gxo87k=
github.com/shadowy-pycoder/mshark v0.0.9 h1:mMHmkqUpkSlkt74DaSkNjhvO0nJ0AxZiYPH6QbllB9A=
github.com/shadowy-pycoder/mshark v0.0.9/go.mod h1:FqbHFdsx0zMnrZZH0+oPzaFcleP4O+tUWv8i5gxo87k=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
Expand Down
Loading