quic-go / masque-go

MASQUE: Proxying UDP in HTTP/3, RFC 9298
MIT License
67 stars 7 forks source link

allow applications to control DNS resolution #41

Closed marten-seemann closed 3 months ago

marten-seemann commented 3 months ago

A proxy might want to control DNS resolution of target hosts (e.g. force usage of DoH). This is currently not possible, since the proxy implementation handles DNS resolution.

We could combine pass the hostname to DialTarget instead:

type Proxy struct {
    // DialTarget is called when the proxy needs to open a new UDP socket to the target server.
    // It must return a connected UDP socket.
    // TODO(#3): support unconnected sockets.
    DialTarget func(context.Context, string) (*net.UDPConn, error)
}

This would also allow us to remove the Allow callback.

It's not clear how we should set the HTTP status code though.

marten-seemann commented 3 months ago

One option is to define an error. Iff the applications returns this error, we can set a custom HTTP status:

type ProxyError struct {
    HTTPStatus int
    Error string
}

func (e *ProxyError) Error() string { return e.Error }
marten-seemann commented 3 months ago

Resolved by #43.