goproxy
goproxy copied to clipboard
Core Functionality Broken
I basically copy and pasted the example of http-dump, however, nothing is being written to log. It's just empty. I also tried using .OnRequest().DoFunc() however it's not working as well.
The following code would never panic for some strange reason.
It would however proxy the traffic normally and print in the console: $ HOST=127.0.0.1 PORT=8081 go run . 2024/04/11 11:57:40 [001] INFO: Running 0 CONNECT handlers 2024/04/11 11:57:40 [002] INFO: Running 0 CONNECT handlers 2024/04/11 11:57:40 [003] INFO: Running 0 CONNECT handlers 2024/04/11 11:57:40 [001] INFO: Accepting CONNECT to www.google.com:443
` package main
import ( "api/env" "fmt" "net" "net/http" "os"
"github.com/elazarl/goproxy"
)
func main() { proxy := goproxy.NewProxyHttpServer() proxy.Verbose = true
proxy.OnRequest().DoFunc(
func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
panic("not called")
return r, nil
})
if err := http.ListenAndServe(net.JoinHostPort(env.SRV_ADDR, env.SRV_PORT), proxy); err != nil {
fmt.Println(err)
os.Exit(1)
}
} `
Edit: Some random POST requests would go trough an call the hook. Log: 2024/04/11 12:00:31 [020] INFO: Got request / ocsp.sectigo.com POST http://ocsp.sectigo.com/