Description
The -l flag for specifying the HTTP proxy listen address is parsed and logged correctly, but the HTTP server always binds to the default port 8080 regardless of the value provided.
Version
gohpts v1.14.0 (built for darwin arm64 with go1.26.3)
Steps to Reproduce
# Start gohpts with custom port 38080
gohpts -l 38080 -s 13659
# Log output shows correct address:
# [INF] SOCKS5 Proxy: 127.0.0.1:13659
# [INF] HTTP Proxy: 127.0.0.1:38080
# But the server actually binds to 8080:
lsof -i :38080 # (empty - nothing listening)
lsof -i :8080 # gohpts is listening here instead
Expected Behavior
The HTTP server should bind to the address specified by the -l flag (e.g., 127.0.0.1:38080).
Actual Behavior
The HTTP server always binds to 127.0.0.1:8080 (the default), ignoring the -l flag. This applies to both the HTTP server and the HTTP/3 server.
Root Cause
In gohpts.go, both http.Server and http3.Server are initialized with the addrHTTP constant ("127.0.0.1:8080") instead of the parsed p.httpServerAddr:
- Line 549:
Addr: addrHTTP should be Addr: p.httpServerAddr
- Line 581:
Addr: addrHTTP should be Addr: p.httpServerAddr
The log output (line 768) correctly uses p.httpServerAddr, which is why the logged address appears correct while the actual binding is wrong.
Fix
--- a/gohpts.go
+++ b/gohpts.go
@@ -546,7 +546,7 @@
hs := &http.Server{
- Addr: addrHTTP,
+ Addr: p.httpServerAddr,
@@ -578,7 +578,7 @@
hs3 := &http3.Server{
- Addr: addrHTTP,
+ Addr: p.httpServerAddr,
I have a commit with this fix ready and can submit a PR if desired.
Description
The
-lflag for specifying the HTTP proxy listen address is parsed and logged correctly, but the HTTP server always binds to the default port8080regardless of the value provided.Version
Steps to Reproduce
Expected Behavior
The HTTP server should bind to the address specified by the
-lflag (e.g.,127.0.0.1:38080).Actual Behavior
The HTTP server always binds to
127.0.0.1:8080(the default), ignoring the-lflag. This applies to both the HTTP server and the HTTP/3 server.Root Cause
In
gohpts.go, bothhttp.Serverandhttp3.Serverare initialized with theaddrHTTPconstant ("127.0.0.1:8080") instead of the parsedp.httpServerAddr:Addr: addrHTTPshould beAddr: p.httpServerAddrAddr: addrHTTPshould beAddr: p.httpServerAddrThe log output (line 768) correctly uses
p.httpServerAddr, which is why the logged address appears correct while the actual binding is wrong.Fix
I have a commit with this fix ready and can submit a PR if desired.