Skip to content

Conversation

maisem
Copy link
Contributor

@maisem maisem commented May 18, 2024

This adds a new ListenPacket function on tsnet.Server
which acts mostly like net.ListenPacket.

Unlike Server.Listen, this requires listening on a
specific IP and does not automatically listen on both
V4 and V6 addresses of the Server when the IP is unspecified.

To test this, it also adds UDP support to tsdial.Dialer.UserDial
and plumbs it through the localapi. Then an associated test
to make sure the UDP functionality works from both sides.

Updates #12182

@maisem maisem requested review from willnorris and bradfitz May 18, 2024 21:39
@maisem maisem force-pushed the maisem/tsnet-udp branch 3 times, most recently from f72de82 to da82771 Compare May 18, 2024 22:01
@willnorris
Copy link
Member

Okay, I got this working:

% /opt/homebrew/opt/curl/bin/curl -i --http3 https://caddytest.tailb575b.ts.net/
HTTP/3 200
date: Tue, 21 May 2024 16:26:26 GMT
content-length: 2
server: Caddy
content-type: text/plain; charset=utf-8

OK

I think the issues I had yesterday were more to do with my browser. Once I got a version of curl compiled with QUIC support, this packet listener seems to work as expected.

@maisem maisem force-pushed the maisem/tsnet-udp branch 2 times, most recently from a7406a6 to d8c0547 Compare June 1, 2024 23:22
@maisem maisem changed the title tsnet,wgengine/netstack: WIP add ListenPacket tsnet,wgengine/netstack: add ListenPacket Jun 1, 2024
@maisem maisem marked this pull request as ready for review June 1, 2024 23:23
@maisem maisem force-pushed the maisem/tsnet-udp branch from d8c0547 to 116749d Compare June 2, 2024 00:07
Copy link
Member

@bradfitz bradfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this works for both of what you two need, SGTM.

@@ -908,6 +917,34 @@ func (s *Server) Listen(network, addr string) (net.Listener, error) {
return s.listen(network, addr, listenOnTailnet)
}

// ListenPacket announces on the Tailscale network.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL that's exactly the wording the net package uses. okay then

This adds a new ListenPacket function on tsnet.Server
which acts mostly like `net.ListenPacket`.

Unlike `Server.Listen`, this requires listening on a
specific IP and does not automatically listen on both
V4 and V6 addresses of the Server when the IP is unspecified.

To test this, it also adds UDP support to tsdial.Dialer.UserDial
and plumbs it through the localapi. Then an associated test
to make sure the UDP functionality works from both sides.

Updates #12182

Signed-off-by: Maisem Ali <maisem@tailscale.com>
@maisem maisem force-pushed the maisem/tsnet-udp branch from 116749d to 30bd3ff Compare June 2, 2024 16:09
@maisem maisem merged commit 42cfbf4 into main Jun 2, 2024
@maisem maisem deleted the maisem/tsnet-udp branch June 2, 2024 21:14
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

Successfully merging this pull request may close these issues.

3 participants