Open k0ngoz opened 8 months ago
I have been unable to use .handleConnect, to hijack the CONNECT requests, and also .DoFunc to be able to access and modify request data.
.handleConnect
.DoFunc
When using .handleConnect, my .DoFunc function is just not triggered at all.
` p := goproxy.NewProxyHttpServer()
homeDir, err := os.UserHomeDir() if err != nil { log.Fatalf("Error getting home directory: %v", err) } caCertPath := filepath.Join(homeDir, ".mitmproxy", "mitmproxy-ca-cert.pem") caKeyPath := filepath.Join(homeDir, ".mitmproxy", "mitmproxy-ca.pem") caCert, err := ioutil.ReadFile(caCertPath) if err != nil { log.Fatalf("Error reading CA certificate: %v", err) } caKey, err := ioutil.ReadFile(caKeyPath) if err != nil { log.Fatalf("Error reading CA private key: %v", err) } goproxyCa, err := tls.X509KeyPair(caCert, caKey) if err != nil { log.Fatalf("Error loading key pair: %v", err) } ca := x509.NewCertPool() ca.AppendCertsFromPEM(caCert) goproxy.GoproxyCa = goproxyCa p.OnRequest().HandleConnect(goproxy.FuncHttpsHandler( func(host string, ctx *goproxy.ProxyCtx) (*goproxy.ConnectAction, string) { log.Println("Handling HTTPS CONNECT request for:", host) return &goproxy.ConnectAction{ Action: goproxy.ConnectHijack, TLSConfig: goproxy.TLSConfigFromCA(&goproxyCa), Hijack: getTLSHijackFunc(hj), }, host })) // Handle regular HTTP requests p.OnRequest().DoFunc( func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) { log.Println("Received regular HTTP request:", r.Method, r.URL.String()) return r, nil }, ) log.Fatal(http.ListenAndServe(opts.ListenAddress, p))
`
Hey @k0ngoz, I have a similar use-case, where one is able to Hijack CONNECT and also able to modify the request data, which currently does not work due to SSL certificate failures.
@k0ngoz hi, any news?
I have been unable to use
.handleConnect
, to hijack the CONNECT requests, and also.DoFunc
to be able to access and modify request data.When using
.handleConnect
, my.DoFunc
function is just not triggered at all.` p := goproxy.NewProxyHttpServer()
`