proxyutil

package
v0.38.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Overview

Package proxyutil contains helper functions that are used in all other dnsproxy packages

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLarge = errors.New("DNS message is too large")

ErrTooLarge - DNS message is larger than 64kb

Functions

func AppendIPAddrs

func AppendIPAddrs(ipAddrs *[]net.IPAddr, answers []dns.RR)

AppendIPAddrs appends the IP addresses got from dns.RR to the specified array

func ContainsIP added in v0.28.0

func ContainsIP(ips []net.IP, ip net.IP) bool

ContainsIP checks if the specified IP is in the array

func DNSSize added in v0.33.0

func DNSSize(isUDP bool, r *dns.Msg) int

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

func GetIPFromDNSRecord(r dns.RR) net.IP

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

func IsConnClosed(err error) bool

IsConnClosed - checks if the error signals of a closed server connecting

func ReadPrefixed added in v0.33.0

func ReadPrefixed(conn net.Conn) ([]byte, error)

ReadPrefixed -- reads a DNS message with a 2-byte prefix containing message length

func SortIPAddrs

func SortIPAddrs(ipAddrs []net.IPAddr) []net.IPAddr

SortIPAddrs sorts the specified IP addresses array IPv4 addresses go first, then IPv6 addresses

func UDPGetOOBSize added in v0.33.0

func UDPGetOOBSize() int

UDPGetOOBSize - get max. size of received OOB data It will then be used in the ReadMsgUDP function

func UDPRead added in v0.33.0

func UDPRead(c *net.UDPConn, buf []byte, udpOOBSize int) (int, net.IP, *net.UDPAddr, error)

UDPRead - receive payload and OOB data from the UDP socket

func UDPSetOptions added in v0.33.0

func UDPSetOptions(c *net.UDPConn) error

UDPSetOptions - set options on a UDP socket to be able to receive the necessary OOB data

func UDPWrite added in v0.33.0

func UDPWrite(bytes []byte, conn *net.UDPConn, remoteAddr *net.UDPAddr, localIP net.IP) (int, error)

UDPWrite - writes to the UDP socket and sets local IP to OOB data

func WritePrefixed added in v0.33.0

func WritePrefixed(b []byte, conn net.Conn) error

WritePrefixed -- write a DNS message to a TCP connection it first writes a 2-byte prefix followed by the message itself

Types

This section is empty.

Jump to

Keyboard shortcuts

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