Skip to content

Commit c9ab954

Browse files
bumped to 1.10.1, added pprof, updated mshark to 0.0.14
1 parent db852b5 commit c9ab954

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

README.md

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

108108
```shell
109-
GOHPTS_RELEASE=v1.10.0; 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
109+
GOHPTS_RELEASE=v1.10.1; 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
110110
```
111111

112112
Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later):
@@ -164,6 +164,7 @@ Options:
164164
-j Show logs in JSON format
165165
-logfile Log file path (Default: stdout)
166166
-nocolor Disable colored output for logs (no effect if -j flag specified)
167+
-pprof Address of pprof server with profiling data
167168

168169
Sniffing:
169170
-sniff Enable traffic sniffing for HTTP and TLS

cmd/gohpts/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Options:
5151
-j Show logs in JSON format
5252
-logfile Log file path (Default: stdout)
5353
-nocolor Disable colored output for logs (no effect if -j flag specified)
54+
-pprof Address of pprof server with profiling data
5455
5556
Sniffing:
5657
-sniff Enable traffic sniffing for HTTP and TLS
@@ -140,6 +141,7 @@ func root(args []string) error {
140141
flags.BoolVar(&conf.JSON, "j", false, "Show logs in JSON format")
141142
flags.BoolVar(&conf.Sniff, "sniff", false, "Enable traffic sniffing for HTTP and TLS")
142143
flags.StringVar(&conf.SniffLogFile, "snifflog", "", "Sniffed traffic log file path (Default: the same as -logfile)")
144+
flags.StringVar(&conf.AddrPprof, "pprof", "", "Address of pprof server with profiling data")
143145
flags.BoolVar(&conf.NoColor, "nocolor", false, "Disable colored output for logs (no effect if -j flag specified)")
144146
flags.BoolVar(&conf.Body, "body", false, "Collect request and response body for HTTP traffic (credentials, tokens, etc)")
145147
flags.BoolFunc("v", "Show version and build information", func(flagValue string) error {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/google/uuid v1.6.0
88
github.com/rs/zerolog v1.34.0
99
github.com/shadowy-pycoder/colors v0.0.1
10-
github.com/shadowy-pycoder/mshark v0.0.13
10+
github.com/shadowy-pycoder/mshark v0.0.14
1111
github.com/wzshiming/socks5 v0.5.2
1212
golang.org/x/sys v0.33.0
1313
golang.org/x/term v0.32.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
3434
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
3535
github.com/shadowy-pycoder/colors v0.0.1 h1:weCj/YIOupqy4BSP8KuVzr20fC+cuAv/tArz7bhhkP4=
3636
github.com/shadowy-pycoder/colors v0.0.1/go.mod h1:lkrJS1PY2oVigNLTT6pkbF7B/v0YcU2LD5PZnss1Q4U=
37-
github.com/shadowy-pycoder/mshark v0.0.13 h1:ROEuey/Th4YAmfRg8Xc17aboMs5fknQho4mNBC9h+KE=
38-
github.com/shadowy-pycoder/mshark v0.0.13/go.mod h1:FqbHFdsx0zMnrZZH0+oPzaFcleP4O+tUWv8i5gxo87k=
37+
github.com/shadowy-pycoder/mshark v0.0.14 h1:Gou+y9tIEjNSztGWzfFSYJJ8G0DDNYmkvKTQUZDYeVQ=
38+
github.com/shadowy-pycoder/mshark v0.0.14/go.mod h1:FqbHFdsx0zMnrZZH0+oPzaFcleP4O+tUWv8i5gxo87k=
3939
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
4040
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4141
github.com/wzshiming/socks5 v0.5.2 h1:LtoowVNwAmkIQSkP1r1Wg435xUmC+tfRxorNW30KtnM=

gohpts.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"math/rand"
1818
"net"
1919
"net/http"
20+
"net/http/pprof"
2021
"os"
2122
"os/exec"
2223
"os/signal"
@@ -57,6 +58,7 @@ var (
5758
type Config struct {
5859
AddrHTTP string
5960
AddrSOCKS string
61+
AddrPprof string
6062
User string
6163
Pass string
6264
ServerUser string
@@ -136,6 +138,7 @@ type proxyapp struct {
136138
certFile string
137139
keyFile string
138140
httpServerAddr string
141+
pprofAddr string
139142
iface *net.Interface
140143
tproxyAddr string
141144
tproxyAddrUDP string
@@ -244,6 +247,12 @@ func New(conf *Config) *proxyapp {
244247
lvl = zerolog.DebugLevel
245248
}
246249
p.debug = conf.Debug
250+
if conf.AddrPprof != "" {
251+
p.pprofAddr, err = getFullAddress(conf.AddrPprof, "", false)
252+
if err != nil {
253+
p.logger.Fatal().Err(err).Msg("")
254+
}
255+
}
247256
// the only way I found to make debug level independent between loggers
248257
l := logger.Level(lvl)
249258
sl := snifflogger.Level(lvl)
@@ -504,6 +513,9 @@ func New(conf *Config) *proxyapp {
504513
if p.tproxyAddrUDP != "" {
505514
p.logger.Info().Msgf("TPROXY (UDP): %s", p.tproxyAddrUDP)
506515
}
516+
if p.pprofAddr != "" {
517+
p.logger.Info().Msgf("PPROF: %s", p.pprofAddr)
518+
}
507519
return &p
508520
}
509521

@@ -512,6 +524,15 @@ func (p *proxyapp) Run() {
512524
quit := make(chan os.Signal, 1)
513525
p.closeConn = make(chan bool)
514526
signal.Notify(quit, os.Interrupt)
527+
if p.pprofAddr != "" {
528+
sm := http.NewServeMux()
529+
sm.HandleFunc("/debug/pprof/", pprof.Index)
530+
sm.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
531+
sm.HandleFunc("/debug/pprof/profile", pprof.Profile)
532+
sm.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
533+
sm.HandleFunc("/debug/pprof/trace", pprof.Trace)
534+
go http.ListenAndServe(p.pprofAddr, sm)
535+
}
515536
if p.arpspoofer != nil {
516537
go p.arpspoofer.Start()
517538
}

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package gohpts
22

3-
const Version string = "gohpts v1.10.0"
3+
const Version string = "gohpts v1.10.1"

0 commit comments

Comments
 (0)