physnet

package
v0.0.209 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package physnet keeps sockets that a VPN client opens for itself off the TUN it serves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenControl

func ListenControl(ctx context.Context) control.Func

ListenControl returns a net.ListenConfig.Control function that force-binds newly-created sockets to the platform's default physical interface. When no NetworkManager is registered on ctx (tests, standalone sing-box without the tunnel wrapper), it's a no-op — the socket follows the routing table like a plain net.ListenUDP.

Implementation-wise we borrow the same ProtectFunc / AutoDetectInterfaceFunc hooks sing-box's default dialer uses, but we apply them UNCONDITIONALLY whenever a NetworkManager is present — not gated on networkManager.AutoDetectInterface() the way sing-box/common/dialer/default.go:NewDefault is. This is intentional: pion's ICE host-candidate gathering fails if sockets aren't kept off the TUN we're serving, even when the user hasn't explicitly set auto_detect_interface on the outbound. Gating on AutoDetectInterface() would reintroduce the "NAT failure, aborting!" regression the unbounded outbound's ListenUDP override exists to fix.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL