Checkpoint

This commit is contained in:
2025-10-01 21:10:48 +02:00
parent 03352e3312
commit a23259cfdc
52 changed files with 2214 additions and 39 deletions

View File

@@ -168,6 +168,34 @@ func Transparent(port int) ConnHandler {
})
}
// DialHandler can filter network dial requests coming from the proxy.
type DialHandler interface {
// HandleDial filters an outbound dial request made by the proxy.
//
// The handler may decide to intercept the dial request and return a new [net.Conn]
// that will be used instead of dialing the target. The handler can also return
// nil, in which case the normal dial will proceed.
HandleDial(Context, *http.Request) (net.Conn, error)
}
// DialHandlerFunc is a function that implements the [DialHandler] interface.
type DialHandlerFunc func(Context, *http.Request) (net.Conn, error)
func (f DialHandlerFunc) HandleDial(ctx Context, req *http.Request) (net.Conn, error) {
return f(ctx, req)
}
// ForwardHandler can filter forward HTTP proxy requests.
type ForwardHandler interface {
HandleForward(Context, *http.Request) (*http.Response, error)
}
type ForwardHandlerFunc func(Context, *http.Request) (*http.Response, error)
func (f ForwardHandlerFunc) HandleForward(ctx Context, req *http.Request) (*http.Response, error) {
return f(ctx, req)
}
// RequestHandler can filter HTTP requests coming to the proxy.
type RequestHandler interface {
// HandlerRequest filters a HTTP request made to the proxy. The current request may be obtained