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
Listening on Unix socket? #3560
Comments
I’m not really familiar with Unix sockets. |
I'm not super well versed in this either, but I think udp unix sockets take the unixgram network type, which corresponds to a net.UnixListener struct, rather than a net.PacketConn. |
The What's the use case for this? |
I admit I don't have a specific use case right now, but I noticed that Caddy 2.6.0 failed to start when binding a site to a unix socket, because we try to start the HTTP/3 listener on the same address (but for datagrams) and get an error. In 2.6.1, I've simply disabled HTTP/3 for sites bound to unix sockets. But in doing this I realized, "Huh, I don't know how to serve HTTP/3 over a unix socket" so I opened the issue. I suspect at some point we'll get requests for this and I can ask their use case then. But I just wanted to make sure I wasn't missing something already there. |
You can grab it like this:
The returned |
Oh, awesome!! I didn't even notice that. Thanks @zllovesuki |
@mholt Does that mean you can get the |
@marten-seemann I don't know... it looks like we'd need quic-go to do this or expose a new API. We use |
Ahh... Not sure how I missed that. 😅 🤦♂️ -- I'll give that a shot. Thanks! |
@zllovesuki @marten-seemann Ah, so I've been working on this the last few days.... the problem with using (Edit: And, I'm an idiot for not reading the godoc comment on And I think that makes sense, except I'm having trouble reusing listeners across reloads because I can't keep track of when Close() is called, since quic-go doesn't call Close(): Basically, I expect the listener to be closed when I shut down the server using it. Maybe that's not always the case for PacketConns? I dunno. It makes reusing unix sockets a bit tricky. Do you have any suggestions or maybe can explain and help me understand why that's the case? (One more note: I think it's a bit surprising since calling
|
It turns out that because the This means I need to design an API like this: func ListenQUIC(address string) (net.PacketConn, quic.EarlyListener, error) instead of this: func ListenQUIC(address string) (quic.EarlyListener, error) because I need to get a handle on the underlying PacketConn to close it, since closing the quic.EarlyListener doesn't close the PacketConn. So in other words, I now need to hold onto both the net.PacketConn and quic.EarlyListener, and close them separately. At this point, I'm wondering if you'd be open to one of these changes:
|
Deprecate: - caddy.Listen - caddy.ListenTimeout - caddy.ListenPacket Prefer caddy.NetworkAddress.Listen() instead. Change: - caddy.ListenQUIC (hopefully to remove later) - caddy.ListenerFunc signature (add context and ListenConfig) - Don't emit Alt-Svc header advertising h3 over HTTP/3 - Use quic.ListenEarly instead of quic.ListenEarlyAddr; this gives us more flexibility (e.g. possibility of HTTP/3 over UDS) but also introduces a new issue: quic-go/quic-go#3560 (comment) - Unlink unix socket before and after use
* core: Refactor, improve listener logic Deprecate: - caddy.Listen - caddy.ListenTimeout - caddy.ListenPacket Prefer caddy.NetworkAddress.Listen() instead. Change: - caddy.ListenQUIC (hopefully to remove later) - caddy.ListenerFunc signature (add context and ListenConfig) - Don't emit Alt-Svc header advertising h3 over HTTP/3 - Use quic.ListenEarly instead of quic.ListenEarlyAddr; this gives us more flexibility (e.g. possibility of HTTP/3 over UDS) but also introduces a new issue: quic-go/quic-go#3560 (comment) - Unlink unix socket before and after use * Appease the linter * Keep ListenAll
I've been working on running a QUIC application locally over Unixgram, and I've successfully set up the listener using the However, when attempting to use Has anyone successfully managed this or can provide some guidance on the right direction to pursue? Any help or pointers would be greatly appreciated. Thank you in advance! |
Why can’t you just use the same net.PacketConn that you obtained from ListenPacket? |
Quic question (you probably get that pun a lot) - is there a way to serve HTTP/3 over Unix socket?
I know that probably doesn't make sense, but would quic-go work for
unixgram
network types? I noticed thatlistenAddr()
hard-codesudp
as the network type:https://github.com/lucas-clemente/quic-go/blob/17761bf35f0e91c82ce963d4138aacf90213768a/server.go#L139-L147
Currently fixing a bug in Caddy that doesn't play well with unix sockets (oops). For now I might just disable the HTTP/3 listener for sites configured on Unix sockets, but I thought I should ask if it's possible or even makes sense to use HTTP/3 over UDS. Thanks!
The text was updated successfully, but these errors were encountered: