Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core Functionality Broken #533

Closed
nik-ngp opened this issue Apr 11, 2024 · 7 comments
Closed

Core Functionality Broken #533

nik-ngp opened this issue Apr 11, 2024 · 7 comments

Comments

@nik-ngp
Copy link

nik-ngp commented Apr 11, 2024

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/

@nik-ngp nik-ngp changed the title Cannot Dump Http Traffic Core Functionality Broken Apr 11, 2024
@nik-ngp
Copy link
Author

nik-ngp commented Apr 12, 2024

I also tried Reddit blocking example, doesn't work. Go version 1.22.2

@nik-ngp
Copy link
Author

nik-ngp commented Apr 12, 2024

Replicated the issue in a Linux VM.

@nik-ngp
Copy link
Author

nik-ngp commented Apr 12, 2024

It does work, however, I'd need to set trusted root cert if I wish to intercept HTTPS traffic.

@nik-ngp nik-ngp closed this as completed Apr 12, 2024
@elazarl
Copy link
Owner

elazarl commented Apr 12, 2024 via email

@nik-ngp
Copy link
Author

nik-ngp commented Apr 15, 2024

That would be quite real helpful to have an example with the cert. Maybe even, if not too much to ask, an option to generate keys, serialize them into a certificate so that the whole system can trust it.

I will kindly re-open the ticket with this comment. If you're willing to proceed with the additional example we can attach a PR to this issue.

@nik-ngp nik-ngp reopened this Apr 15, 2024
@zarkones
Copy link

Hello @elazarl . I think such an example for root cert would be really useful. Do you have maybe a timeline of when you could do it for us? :)

@ErikPelli
Copy link
Collaborator

#560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants