Skip to content

Commit 73abdc4

Browse files
added resp/req parsing for handleForward, minor changes to CLI, bumped to v1.7.2
1 parent ecb3c1b commit 73abdc4

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ You can download the binary for your platform from [Releases](https://github.com
9393
Example:
9494

9595
```shell
96-
HPTS_RELEASE=v1.7.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
96+
HPTS_RELEASE=v1.7.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
9797
```
9898

9999
Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later):

cmd/gohpts/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func root(args []string) error {
6363
flags.StringVar(&conf.SniffLogFile, "snifflog", "", "Sniffed traffic log file path (Default: the same as -logfile)")
6464
flags.BoolVar(&conf.Color, "color", false, "Enable colored output for logs in stdout (no effect if log file provided or -j flag specified)")
6565
flags.BoolFunc("v", "print version", func(flagValue string) error {
66-
fmt.Println(gohpts.Version)
66+
fmt.Printf("%s (built for %s %s with %s)\n", gohpts.Version, runtime.GOOS, runtime.GOARCH, runtime.Version())
6767
os.Exit(0)
6868
return nil
6969
})

gohpts.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ func (p *proxyapp) handleForward(w http.ResponseWriter, r *http.Request) {
347347
return
348348
}
349349
req.RequestURI = ""
350-
delConnectionHeaders(r.Header)
351-
delHopHeaders(r.Header)
352350
copyHeader(req.Header, r.Header)
351+
delConnectionHeaders(req.Header)
352+
delHopHeaders(req.Header)
353353
if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil {
354354
appendHostToXForwardHeader(req.Header, clientIP)
355355
}
@@ -392,6 +392,18 @@ func (p *proxyapp) handleForward(w http.ResponseWriter, r *http.Request) {
392392
}
393393
}
394394
defer resp.Body.Close()
395+
if p.sniff {
396+
sniffheader := make([]string, 0, 2)
397+
j, err := json.Marshal(&layers.HTTPMessage{Request: r})
398+
if err == nil {
399+
sniffheader = append(sniffheader, string(j))
400+
}
401+
j, err = json.Marshal(&layers.HTTPMessage{Response: resp})
402+
if err == nil {
403+
sniffheader = append(sniffheader, string(j))
404+
}
405+
p.snifflogger.Debug().Msg(fmt.Sprintf("[%s]", strings.Join(sniffheader, ",")))
406+
}
395407
done := make(chan bool)
396408
if chunked {
397409
rc := http.NewResponseController(w)

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.7.1"
3+
const Version string = "gohpts v1.7.2"

0 commit comments

Comments
 (0)