wrapUDPProtocolHandler wraps the protocol handler we pass to netstack for UDP.
(h protocolHandlerFunc)
| 489 | |
| 490 | // wrapUDPProtocolHandler wraps the protocol handler we pass to netstack for UDP. |
| 491 | func (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 | |
| 510 | var ( |
| 511 | metricPerClientForwardLimit = clientmetric.NewCounter("netstack_tcp_forward_dropped_attempts_per_client") |
no test coverage detected