Documentation ¶
Index ¶
- Constants
- Variables
- func FreeIdleSockets(gw *UDPListener)
- func ReadFromUDP(conn *net.UDPConn, b []byte) (int, *net.UDPAddr, *net.UDPAddr, error)
- func SetReceiveBuffer(c net.PacketConn, minSize int) error
- func StartUDPTProxyListener6(port int) (*net.UDPConn, error)
- func UDPAccept(con *net.UDPConn, ...)
- type OOBCapablePacketConn
- type TProxyUDP
- type UDPListener
- func (gw *UDPListener) Close() error
- func (udpg *UDPListener) HandleUdp(dstAddr net.IP, dstPort uint16, localAddr net.IP, localPort uint16, ...)
- func (udpg *UDPListener) HttpUDPNat(w http.ResponseWriter, r *http.Request)
- func (udpg *UDPListener) InitMux(mux *http.ServeMux)
- func (udpg *UDPListener) Listener(lc *meshauth.PortListener)
- type UdpNat
Constants ¶
const DumpUdp = true
const MaxPacketBufferSize = 9000
Variables ¶
var TransparentUDPWriter ugate.UdpWriter
Capture return - sends packets back to client app. This is typically a netstack or TProxy
Functions ¶
func FreeIdleSockets ¶
func FreeIdleSockets(gw *UDPListener)
Called on the periodic cleanup thread (~60sec), or if too many sockets open. Will update udp stats. Default UDP timeout to 60 sec.
func ReadFromUDP ¶
ReadFromUDP reads a UDP packet from c, copying the payload into b. It returns the number of bytes copied into b and the return address that was on the packet.
RequestInPipe-of-band data is also read in so that the original destination address can be identified and parsed.
func SetReceiveBuffer ¶
func SetReceiveBuffer(c net.PacketConn, minSize int) error
func StartUDPTProxyListener6 ¶
Initialize a port as a TPROXY socket. This can be sent over UDS from the root, and used for UDP capture.
Types ¶
type OOBCapablePacketConn ¶
type OOBCapablePacketConn interface { net.PacketConn SyscallConn() (syscall.RawConn, error) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error) WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error) }
If the PacketConn passed to RoundTripStart or Listen satisfies this interface, quic-go will read the ECN bits from the IP header.
In this case, ReadMsgUDP() will be used instead of ReadFrom() to read packets.
type TProxyUDP ¶
type TProxyUDP struct {
// contains filtered or unexported fields
}
Handles UDP packets intercepted using TProxy. Can send packets preserving original IP/port.
type UDPListener ¶
type UDPListener struct { ActiveUdp map[string]*UdpNat // UDP // Capture return - sends packets back to client app. // This is typically a netstack or TProxy TransparentUDPWriter ugate.UdpWriter // Timeout for UDP sockets. Default 60 sec. ConnTimeout time.Duration // contains filtered or unexported fields }
func New ¶
func New(ug *ugate.UGate, l *meshauth.PortListener) *UDPListener
func (*UDPListener) Close ¶
func (gw *UDPListener) Close() error
func (*UDPListener) HandleUdp ¶
func (udpg *UDPListener) HandleUdp(dstAddr net.IP, dstPort uint16, localAddr net.IP, localPort uint16, data []byte)
HandleUDP is processing a captured UDP packet. It can be captured by iptables TPROXY or netstack TUN. Will create a NAT, using a local port as source and translating back.
func (*UDPListener) HttpUDPNat ¶
func (udpg *UDPListener) HttpUDPNat(w http.ResponseWriter, r *http.Request)
func (*UDPListener) InitMux ¶
func (udpg *UDPListener) InitMux(mux *http.ServeMux)
func (*UDPListener) Listener ¶
func (udpg *UDPListener) Listener(lc *meshauth.PortListener)
Listener creates a regular UDP listener port
type UdpNat ¶
type UdpNat struct { nio.Stats // External address - string Dest string // External address DestAddr *net.UDPAddr //util.Stream // bound to a local port (on the real network). UDP *net.UDPConn Closed bool // For captured traffic / NAT LocalIP net.IP LocalPort int LastRemoteIP net.IP LastsRemotePort uint16 ReverseSrcAddr *net.UDPAddr }
Represents on UDP 'nat' connection or association.
Currently full cone, i.e. one local port per NAT - max 30k This should be sufficient for local capture and small p2p nets. In the mesh, UDP should be encapsulated in WebRTC or quic.