Documentation
¶
Overview ¶
Package netutil contains network-related utilities common among dnsproxy packages.
TODO(a.garipov): Move improved versions of these into netutil in module golibs.
Index ¶
- func DefaultHostsPaths() (paths []string, err error)
- func ListenConfig(l *slog.Logger) (lc *net.ListenConfig)
- func ParseSubnet(s string) (p netip.Prefix, err error)
- func UDPGetOOBSize() (oobSize int)
- func UDPRead(conn *net.UDPConn, buf []byte, udpOOBSize int) (n int, localIP netip.Addr, remoteAddr *net.UDPAddr, err error)
- func UDPSetOptions(c *net.UDPConn) (err error)
- func UDPWrite(data []byte, conn *net.UDPConn, remoteAddr *net.UDPAddr, localIP netip.Addr) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHostsPaths ¶ added in v0.74.1
DefaultHostsPaths returns the slice of default paths to system hosts files.
TODO(s.chzhen): Since [fs.FS] is no longer needed, update the hostsfile.DefaultHostsPaths from golibs.
func ListenConfig ¶ added in v0.49.0
func ListenConfig(l *slog.Logger) (lc *net.ListenConfig)
ListenConfig returns the default net.ListenConfig used by the plain-DNS servers in this module. l must not be nil.
TODO(a.garipov): Add tests.
TODO(a.garipov): Add an option to not set SO_REUSEPORT on Unix to prevent issues with OpenWrt.
See https://github.com/AdguardTeam/AdGuardHome/issues/5872.
TODO(a.garipov): DRY with AdGuard DNS when we can.
func ParseSubnet ¶ added in v0.58.0
ParseSubnet parses s either as a CIDR prefix itself, or as an IP address, returning the corresponding single-IP CIDR prefix.
TODO(e.burkov): Replace usages with netutil.Prefix.
func UDPGetOOBSize ¶ added in v0.49.0
func UDPGetOOBSize() (oobSize int)
UDPGetOOBSize returns maximum size of the received OOB data.
func UDPRead ¶ added in v0.49.0
func UDPRead( conn *net.UDPConn, buf []byte, udpOOBSize int, ) (n int, localIP netip.Addr, remoteAddr *net.UDPAddr, err error)
UDPRead reads the message from conn using buf and receives a control-message payload of size udpOOBSize from it. It returns the number of bytes copied into buf and the source address of the message.
TODO(s.chzhen): Consider using netip.Addr.
func UDPSetOptions ¶ added in v0.49.0
UDPSetOptions sets flag options on a UDP socket to be able to receive the necessary OOB data.
Types ¶
This section is empty.