MCPcopy Index your code
hub / github.com/tailscale/tailscale / wrapUDPProtocolHandler

Method wrapUDPProtocolHandler

wgengine/netstack/netstack.go:491–508  ·  view source on GitHub ↗

wrapUDPProtocolHandler wraps the protocol handler we pass to netstack for UDP.

(h protocolHandlerFunc)

Source from the content-addressed store, hash-verified

489
490// wrapUDPProtocolHandler wraps the protocol handler we pass to netstack for UDP.
491func (ns *Impl) wrapUDPProtocolHandler(h protocolHandlerFunc) protocolHandlerFunc {
492 return func(tei stack.TransportEndpointID, pb *stack.PacketBuffer) bool {
493 addr := tei.LocalAddress
494 ip, ok := netip.AddrFromSlice(addr.AsSlice())
495 if !ok {
496 ns.logf("netstack: could not parse local address for incoming connection")
497 return false
498 }
499
500 // Dynamically reconfigure ns's subnet addresses as needed for
501 // outbound traffic.
502 ip = ip.Unmap()
503 if !ns.isLocalIP(ip) {
504 ns.addSubnetAddress(ip)
505 }
506 return h(tei, pb)
507 }
508}
509
510var (
511 metricPerClientForwardLimit = clientmetric.NewCounter("netstack_tcp_forward_dropped_attempts_per_client")

Callers 1

StartMethod · 0.95

Calls 4

isLocalIPMethod · 0.95
addSubnetAddressMethod · 0.95
AsSliceMethod · 0.45
logfMethod · 0.45

Tested by

no test coverage detected