mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 20:26:47 +02:00
wgengine/netstack: add UDP forwarding bypass.
Allow a tsnet application to supply its own UDP handling, similar to the existing TCP handling. Updates https://github.com/tailscale/tailscale/issues/5871 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:
parent
2d3ae485e3
commit
93042b4407
@ -84,6 +84,10 @@ type Impl struct {
|
||||
// port other than accepting it and closing it.
|
||||
ForwardTCPIn func(c net.Conn, port uint16)
|
||||
|
||||
// ForwardUDPIn, if non-nil, handles forwarding inbound UDP
|
||||
// packets.
|
||||
ForwardUDPIn func(c net.PacketConn, port uint16)
|
||||
|
||||
// ProcessLocalIPs is whether netstack should handle incoming
|
||||
// traffic directed at the Node.Addresses (local IPs).
|
||||
// It can only be set before calling Start.
|
||||
@ -1021,6 +1025,12 @@ func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
|
||||
}
|
||||
|
||||
c := gonet.NewUDPConn(ns.ipstack, &wq, ep)
|
||||
|
||||
if ns.ForwardUDPIn != nil {
|
||||
ns.ForwardUDPIn(c, r.ID().LocalPort)
|
||||
return
|
||||
}
|
||||
|
||||
go ns.forwardUDP(c, &wq, srcAddr, dstAddr)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user