Documentation ¶
Overview ¶
Package proxyutil contains helper functions that are used in all other dnsproxy packages
Index ¶
- Variables
- func AppendIPAddrs(ipAddrs *[]net.IPAddr, answers []dns.RR)
- func ContainsIP(ips []net.IP, ip net.IP) bool
- func DNSSize(isUDP bool, r *dns.Msg) int
- func GetIPFromDNSRecord(r dns.RR) net.IP
- func IsConnClosed(err error) bool
- func ReadPrefixed(conn net.Conn) ([]byte, error)
- func SortIPAddrs(ipAddrs []net.IPAddr) []net.IPAddr
- func UDPGetOOBSize() (oobSize int)
- func UDPRead(c *net.UDPConn, buf []byte, udpOOBSize int) (n int, localIP net.IP, remoteAddr *net.UDPAddr, err error)
- func UDPSetOptions(c *net.UDPConn) (err error)
- func UDPWrite(data []byte, conn *net.UDPConn, remoteAddr *net.UDPAddr, localIP net.IP) (n int, err error)
- func WritePrefixed(b []byte, conn net.Conn) error
Constants ¶
This section is empty.
Variables ¶
var ErrTooLarge = errors.New("DNS message is too large")
ErrTooLarge - DNS message is larger than 64kb
Functions ¶
func AppendIPAddrs ¶
AppendIPAddrs appends the IP addresses got from dns.RR to the specified array
func ContainsIP ¶ added in v0.28.0
ContainsIP checks if the specified IP is in the array
func DNSSize ¶ added in v0.33.0
DNSSize returns if buffer size *advertised* in the requests OPT record. Or when the request was over TCP, we return the maximum allowed size of 64K.
func GetIPFromDNSRecord ¶ added in v0.27.0
GetIPFromDNSRecord - extracts IP address for a DNS record returns null if the record is of a wrong type
func IsConnClosed ¶ added in v0.33.0
IsConnClosed - checks if the error signals of a closed server connecting
func ReadPrefixed ¶ added in v0.33.0
ReadPrefixed -- reads a DNS message with a 2-byte prefix containing message length
func SortIPAddrs ¶
SortIPAddrs sorts the specified IP addresses array IPv4 addresses go first, then IPv6 addresses
func UDPGetOOBSize ¶ added in v0.33.0
func UDPGetOOBSize() (oobSize int)
UDPGetOOBSize returns maximum size of the received OOB data.
func UDPRead ¶ added in v0.33.0
func UDPRead( c *net.UDPConn, buf []byte, udpOOBSize int, ) (n int, localIP net.IP, remoteAddr *net.UDPAddr, err error)
UDPRead udpRead reads the message from c using buf receives payload of size udpOOBSize from the UDP socket. It returns the number of bytes copied into buf, the number of bytes copied with OOB and the source address of the message.
func UDPSetOptions ¶ added in v0.33.0
UDPSetOptions sets flag options on a UDP socket to be able to receive the necessary OOB data.
Types ¶
This section is empty.