Skip to content

Commit 1a85b27

Browse files
Merge pull request #9 from shadowy-pycoder/fixesfeatures
Support of `SO_MARK` in auto configuration
2 parents da31d1b + 6f128cb commit 1a85b27

File tree

6 files changed

+187
-86
lines changed

6 files changed

+187
-86
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ You can download the binary for your platform from [Releases](https://github.com
9797
Example:
9898

9999
```shell
100-
HPTS_RELEASE=v1.8.1; 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
100+
HPTS_RELEASE=v1.8.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
101101
```
102102

103103
Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later):
@@ -159,6 +159,8 @@ Options:
159159
Address of HTTP proxy server (default "127.0.0.1:8080")
160160
-logfile string
161161
Log file path (Default: stdout)
162+
-mark uint
163+
Set the mark for each packet sent through transparent proxy
162164
-nocolor
163165
Disable colored output for logs (no effect if -j flag specified)
164166
-s string
@@ -387,6 +389,12 @@ sudo env PATH=$PATH gohpts -d -T 8888 -M redirect -auto
387389
388390
Please note, automatic configuration requires `sudo` and is very generic, which might not be suitable for your needs.
389391
392+
You can optionally specify `-mark <value>` to prevent possible proxy loops
393+
394+
```shell
395+
sudo env PATH=$PATH gohpts -d -T 8888 -M redirect -auto -mark 100
396+
```
397+
390398
## `tproxy` (via _MANGLE_ and _IP_TRANSPARENT_)
391399
392400
[[Back]](#table-of-contents)

cmd/gohpts/cli.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func root(args []string) error {
5555
return nil
5656
})
5757
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")
5859
}
5960
flags.StringVar(&conf.LogFilePath, "logfile", "", "Log file path (Default: stdout)")
6061
flags.BoolVar(&conf.Debug, "d", false, "Show logs in DEBUG mode")
@@ -110,6 +111,11 @@ func root(args []string) error {
110111
return fmt.Errorf("-auto is available only for -M redirect")
111112
}
112113
}
114+
if seen["mark"] {
115+
if !seen["t"] && !seen["T"] {
116+
return fmt.Errorf("-mark requires -t or -T flag")
117+
}
118+
}
113119
if seen["f"] {
114120
for _, da := range []string{"s", "u", "U", "c", "k", "l"} {
115121
if seen[da] {

0 commit comments

Comments
 (0)