net

Imports

Imports #

"context"
"syscall"
"context"
"io"
"os"
"syscall"
"internal/poll"
"internal/syscall/unix"
"syscall"
"unsafe"
"syscall"
"internal/syscall/windows"
"os"
"syscall"
"os"
"syscall"
"os"
"syscall"
"os"
"syscall"
"syscall"
"time"
"errors"
"internal/bytealg"
"internal/godebug"
"internal/stringslite"
"io/fs"
"os"
"runtime"
"sync"
"internal/poll"
"io"
"os"
"syscall"
"time"
"internal/poll"
"runtime"
"syscall"
"time"
"os"
"context"
"internal/bytealg"
"runtime"
"sync"
_ "unsafe"
"context"
"internal/bytealg"
"internal/itoa"
"io/fs"
"os"
"syscall"
"internal/syscall/windows"
"syscall"
"errors"
"io"
"os"
"syscall"
"syscall"
"golang.org/x/net/route"
"internal/poll"
"io"
"syscall"
"internal/poll"
"io"
"os"
"syscall"
"runtime"
"syscall"
"syscall"
"runtime"
"syscall"
"C"
"syscall"
"context"
"internal/poll"
"os"
"syscall"
"syscall"
"time"
"context"
"net/netip"
"syscall"
"context"
"os"
"syscall"
"errors"
"internal/itoa"
"internal/stringslite"
"os"
"C"
"syscall"
"syscall"
"golang.org/x/net/route"
"C"
"unsafe"
"internal/bytealg"
"internal/stringslite"
"net/netip"
"time"
"runtime"
"syscall"
"os"
"syscall"
"unsafe"
"context"
"internal/poll"
"internal/syscall/windows"
"os"
"runtime"
"syscall"
"unsafe"
"context"
"internal/bytealg"
"sync"
"context"
"C"
"context"
"errors"
"internal/bytealg"
"net/netip"
"runtime"
"syscall"
"unsafe"
"golang.org/x/net/dns/dnsmessage"
"C"
"internal/poll"
"runtime"
"time"
"context"
"syscall"
"internal/bytealg"
"sync"
"C"
"unsafe"
"cmp"
"internal/bytealg"
"internal/itoa"
"slices"
_ "unsafe"
"golang.org/x/net/dns/dnsmessage"
"context"
"errors"
"internal/poll"
"internal/syscall/unix"
"sync"
"syscall"
"internal/bytealg"
"io"
"os"
"time"
"syscall"
"internal/syscall/unix"
"syscall"
"internal/syscall/unix"
"runtime"
"syscall"
"time"
"context"
"os"
"sync"
"syscall"
"time"
"context"
"internal/syscall/windows"
"os"
"runtime"
"syscall"
"time"
"unsafe"
"runtime"
"syscall"
"internal/syscall/windows"
"os"
"runtime"
"syscall"
"time"
"unsafe"
"net/netip"
"slices"
"context"
"syscall"
"syscall"
"context"
"errors"
"os"
"syscall"
"C"
"syscall"
"unsafe"
"os"
"sync/atomic"
"time"
_ "unsafe"
"internal/syscall/windows"
"syscall"
"internal/poll"
"runtime"
"syscall"
"C"
"context"
"errors"
"internal/bytealg"
"internal/godebug"
"internal/itoa"
"internal/stringslite"
"io"
"os"
"runtime"
"sync"
"sync/atomic"
"time"
"golang.org/x/net/dns/dnsmessage"
"syscall"
"golang.org/x/net/lif"
"errors"
"internal/bytealg"
"os"
"sync"
"time"
"internal/poll"
"internal/syscall/unix"
"os"
"syscall"
"os"
"syscall"
"internal/syscall/unix"
"C"
"syscall"
"unsafe"
"context"
"errors"
"internal/poll"
"io"
"os"
"sync"
"syscall"
"time"
_ "unsafe"
"runtime"
"syscall"
"time"
"internal/itoa"
"syscall"
"time"
"syscall"
"golang.org/x/net/route"
"C"
"unsafe"
"context"
"internal/poll"
"os"
"syscall"
"internal/syscall/windows"
"os"
"syscall"
"unsafe"
"context"
"errors"
"internal/bytealg"
"internal/itoa"
"internal/stringslite"
"io"
"os"
"os"
"syscall"
"context"
"internal/itoa"
"net/netip"
"syscall"
"C"
"os"
"syscall"
"context"
"internal/itoa"
"io"
"net/netip"
"os"
"syscall"
"time"
"errors"
"internal/itoa"
"sync"
"time"
_ "unsafe"
"internal/bytealg"
"runtime"
"syscall"
"C"
"unsafe"
"context"
"errors"
"io"
"os"
"sync"
"sync/atomic"
"syscall"
"time"
"runtime"
"syscall"
"internal/syscall/unix"
"runtime"
"syscall"
"unsafe"
"internal/poll"
"io"
"os"
"os"
"runtime"
"syscall"
"syscall"
"syscall"
"internal/bytealg"
"internal/itoa"
"internal/stringslite"
"net/netip"
"context"
"errors"
"internal/nettrace"
"internal/singleflight"
"net/netip"
"sync"
"golang.org/x/net/dns/dnsmessage"
"internal/syscall/unix"
"syscall"
"context"
"io"
"os"
"os"
"syscall"
"syscall"
"context"
"internal/bytealg"
"internal/godebug"
"internal/nettrace"
"syscall"
"time"
"context"
"internal/poll"
"os"
"runtime"
"syscall"
"syscall"
"os"
"syscall"
_ "unsafe"
"errors"
"internal/bytealg"
"io/fs"
"net/netip"
"sync"
"time"
"os"
"syscall"
"os"
"syscall"
"C"
"context"
"internal/poll"
"net/netip"
"runtime"
"syscall"
_ "unsafe"
"os"
"runtime"
"syscall"
"runtime"
"syscall"
"internal/poll"
"io"
"context"
"errors"
"net/netip"
"os"
"syscall"
"syscall"
"syscall"
"io"
"internal/poll"
"os"
"syscall"
"runtime"
"syscall"
"time"
"C"
"syscall"
"golang.org/x/net/route"
"io"
"os"
"sync"
"time"
"io"
"syscall"
"internal/syscall/windows"
"syscall"
"time"
"context"

Constants & Variables

DefaultResolver var #

DefaultResolver is the resolver used by the package-level Lookup functions and by Dialers without a specified Resolver.

var DefaultResolver = *ast.UnaryExpr

ErrClosed var #

ErrClosed is the error returned by an I/O call on a network connection that has already been closed, or that is closed by another goroutine before the I/O is completed. This may be wrapped in another error, and should normally be tested using errors.Is(err, net.ErrClosed).

var ErrClosed error = errClosed

ErrWriteToConnected var #

Various errors contained in OpError.

var ErrWriteToConnected = *ast.CallExpr

FlagBroadcast const #

const FlagBroadcast

FlagLoopback const #

const FlagLoopback

FlagMulticast const #

const FlagMulticast

FlagPointToPoint const #

const FlagPointToPoint

FlagRunning const #

const FlagRunning

FlagUp const #

const FlagUp Flags = *ast.BinaryExpr

IPv4allrouter var #

Well-known IPv4 addresses

var IPv4allrouter = *ast.CallExpr

IPv4allsys var #

Well-known IPv4 addresses

var IPv4allsys = *ast.CallExpr

IPv4bcast var #

Well-known IPv4 addresses

var IPv4bcast = *ast.CallExpr

IPv4len const #

IP address lengths (bytes).

const IPv4len = 4

IPv4zero var #

Well-known IPv4 addresses

var IPv4zero = *ast.CallExpr

IPv6interfacelocalallnodes var #

Well-known IPv6 addresses

var IPv6interfacelocalallnodes = IP{...}

IPv6len const #

IP address lengths (bytes).

const IPv6len = 16

IPv6linklocalallnodes var #

Well-known IPv6 addresses

var IPv6linklocalallnodes = IP{...}

IPv6linklocalallrouters var #

Well-known IPv6 addresses

var IPv6linklocalallrouters = IP{...}

IPv6loopback var #

Well-known IPv6 addresses

var IPv6loopback = IP{...}

IPv6unspecified var #

Well-known IPv6 addresses

var IPv6unspecified = IP{...}

IPv6zero var #

Well-known IPv6 addresses

var IPv6zero = IP{...}

_ var #

var _ io.WriterTo = *ast.CallExpr

_ var #

var _ io.Reader = *ast.CallExpr

_ var #

var _ context.Context = *ast.CallExpr

_C_AF_INET const #

const _C_AF_INET = syscall.AF_INET

_C_AF_INET const #

const _C_AF_INET = C.AF_INET

_C_AF_INET6 const #

const _C_AF_INET6 = syscall.AF_INET6

_C_AF_INET6 const #

const _C_AF_INET6 = C.AF_INET6

_C_AF_UNSPEC const #

const _C_AF_UNSPEC = syscall.AF_UNSPEC

_C_AF_UNSPEC const #

const _C_AF_UNSPEC = C.AF_UNSPEC

_C_EAI_ADDRFAMILY const #

const _C_EAI_ADDRFAMILY = unix.EAI_ADDRFAMILY

_C_EAI_ADDRFAMILY const #

const _C_EAI_ADDRFAMILY = C.EAI_ADDRFAMILY

_C_EAI_AGAIN const #

const _C_EAI_AGAIN = unix.EAI_AGAIN

_C_EAI_AGAIN const #

const _C_EAI_AGAIN = C.EAI_AGAIN

_C_EAI_NODATA const #

const _C_EAI_NODATA = C.EAI_NODATA

_C_EAI_NODATA const #

const _C_EAI_NODATA = unix.EAI_NODATA

_C_EAI_NONAME const #

const _C_EAI_NONAME = unix.EAI_NONAME

_C_EAI_NONAME const #

const _C_EAI_NONAME = C.EAI_NONAME

_C_EAI_OVERFLOW const #

const _C_EAI_OVERFLOW = C.EAI_OVERFLOW

_C_EAI_OVERFLOW const #

const _C_EAI_OVERFLOW = unix.EAI_OVERFLOW

_C_EAI_SERVICE const #

const _C_EAI_SERVICE = C.EAI_SERVICE

_C_EAI_SERVICE const #

const _C_EAI_SERVICE = unix.EAI_SERVICE

_C_EAI_SYSTEM const #

const _C_EAI_SYSTEM = unix.EAI_SYSTEM

_C_EAI_SYSTEM const #

const _C_EAI_SYSTEM = C.EAI_SYSTEM

_C_IPPROTO_TCP const #

const _C_IPPROTO_TCP = syscall.IPPROTO_TCP

_C_IPPROTO_TCP const #

const _C_IPPROTO_TCP = C.IPPROTO_TCP

_C_IPPROTO_UDP const #

const _C_IPPROTO_UDP = C.IPPROTO_UDP

_C_IPPROTO_UDP const #

const _C_IPPROTO_UDP = syscall.IPPROTO_UDP

_C_SOCK_DGRAM const #

const _C_SOCK_DGRAM = C.SOCK_DGRAM

_C_SOCK_DGRAM const #

const _C_SOCK_DGRAM = syscall.SOCK_DGRAM

_C_SOCK_STREAM const #

const _C_SOCK_STREAM = C.SOCK_STREAM

_C_SOCK_STREAM const #

const _C_SOCK_STREAM = syscall.SOCK_STREAM

_DNS_ERROR_RCODE_NAME_ERROR const #

const _DNS_ERROR_RCODE_NAME_ERROR = *ast.CallExpr

_DNS_INFO_NO_RECORDS const #

const _DNS_INFO_NO_RECORDS = *ast.CallExpr

_IPPROTO_MPTCP const #

These constants aren't in the syscall package, which is frozen

const _IPPROTO_MPTCP = 0x106

_KINFO_RT_IFLIST const #

const _KINFO_RT_IFLIST = *ast.BinaryExpr

_MPTCP_INFO const #

These constants aren't in the syscall package, which is frozen

const _MPTCP_INFO = 0x1

_RTAX_IFA const #

const _RTAX_IFA = 5

_RTAX_MAX const #

const _RTAX_MAX = 8

_RTAX_NETMASK const #

const _RTAX_NETMASK = 2

_SOL_MPTCP const #

These constants aren't in the syscall package, which is frozen

const _SOL_MPTCP = 0x11c

_WSAHOST_NOT_FOUND const #

const _WSAHOST_NOT_FOUND = *ast.CallExpr

_WSATRY_AGAIN const #

const _WSATRY_AGAIN = *ast.CallExpr

_WSATYPE_NOT_FOUND const #

const _WSATYPE_NOT_FOUND = *ast.CallExpr

aLongTimeAgo var #

aLongTimeAgo is a non-zero time, far in the past, used for immediate cancellation of dials.

var aLongTimeAgo = *ast.CallExpr

big const #

Bigger than we need, not too big to worry about overflow

const big = 0xFFFFFF

cacheMaxAge const #

const cacheMaxAge = *ast.BinaryExpr

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = C.AI_CANONNAME

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = C.AI_CANONNAME

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = *ast.BinaryExpr

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = *ast.BinaryExpr

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = C.AI_CANONNAME

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = C.AI_CANONNAME

cgoAddrInfoFlags const #

NOTE(rsc): In theory there are approximately balanced arguments for and against including AI_ADDRCONFIG in the flags (it includes IPv4 results only on IPv4 systems, and similarly for IPv6), but in practice setting it causes getaddrinfo to return the wrong canonical name on Linux. So definitely leave it out.

const cgoAddrInfoFlags = *ast.BinaryExpr

cgoAddrInfoFlags const #

const cgoAddrInfoFlags = *ast.BinaryExpr

cgoAvailable const #

cgoAvailable set to false to indicate that the cgo resolver is not available on this system.

const cgoAvailable = false

cgoAvailable const #

cgoAvailable set to true to indicate that the cgo resolver is available on Plan 9. Note that on Plan 9 the cgo resolver does not actually use cgo.

const cgoAvailable = true

cgoAvailable const #

cgoAvailable set to true to indicate that the cgo resolver is available on this system.

const cgoAvailable = true

cgoAvailable const #

cgoAvailable set to true to indicate that the cgo resolver is available on Windows. Note that on Windows the cgo resolver does not actually use cgo.

const cgoAvailable = true

classAMask var #

Default route masks for IPv4.

var classAMask = *ast.CallExpr

classBMask var #

Default route masks for IPv4.

var classBMask = *ast.CallExpr

classCMask var #

Default route masks for IPv4.

var classCMask = *ast.CallExpr

confOnce var #

var confOnce sync.Once

confVal var #

var confVal = *ast.UnaryExpr

connectFunc var #

var connectFunc func(syscall.Handle, syscall.Sockaddr) error = syscall.Connect

connectFunc var #

var connectFunc func(int, syscall.Sockaddr) error = syscall.Connect

defaultBuffer const #

const defaultBuffer = 65535

defaultKeepAliveIdle const #

Default values of KeepAliveTime and KeepAliveInterval on Windows, check out https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals#remarks for details.

const defaultKeepAliveIdle = *ast.BinaryExpr

defaultKeepAliveInterval const #

Default values of KeepAliveTime and KeepAliveInterval on Windows, check out https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals#remarks for details.

const defaultKeepAliveInterval = time.Second

defaultMPTCPEnabledDial const #

const defaultMPTCPEnabledDial = false

defaultMPTCPEnabledListen const #

For the moment, MultiPath TCP is used by default with listeners, if available, but not with dialers. See go.dev/issue/56539

const defaultMPTCPEnabledListen = true

defaultNS var #

defaultNS is the default name servers to use in the absence of DNS configuration. defaultNS should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/pojntfx/hydrapp/hydrapp - github.com/mtibben/androiddnsfix - github.com/metacubex/mihomo Do not remove or change the type signature. See go.dev/issue/67401. go:linkname defaultNS

var defaultNS = []string{...}

defaultTCPKeepAliveCount const #

defaultTCPKeepAliveCount is a default constant value for TCP_KEEPCNT.

const defaultTCPKeepAliveCount = 9

defaultTCPKeepAliveIdle const #

defaultTCPKeepAliveIdle is a default constant value for TCP_KEEPIDLE. See go.dev/issue/31510 for details.

const defaultTCPKeepAliveIdle = *ast.BinaryExpr

defaultTCPKeepAliveInterval const #

defaultTCPKeepAliveInterval is a default constant value for TCP_KEEPINTVL. It is the same as defaultTCPKeepAliveIdle, see go.dev/issue/31510 for details.

const defaultTCPKeepAliveInterval = *ast.BinaryExpr

dnsSectionMask const #

const dnsSectionMask = 0x0003

dnsWaitGroup var #

dnsWaitGroup can be used by tests to wait for all DNS goroutines to complete. This avoids races on the test hooks.

var dnsWaitGroup sync.WaitGroup

errCanceled var #

For both read and write operations.

var errCanceled = canceledError{...}

errCannotMarshalDNSMessage var #

var errCannotMarshalDNSMessage = *ast.CallExpr

errCannotUnmarshalDNSMessage var #

var errCannotUnmarshalDNSMessage = *ast.CallExpr

errClosed var #

errClosed exists just so that the docs for ErrClosed don't mention the internal package poll.

var errClosed = poll.ErrNetClosing

errInvalidDNSResponse var #

var errInvalidDNSResponse = *ast.CallExpr

errInvalidInterface var #

var errInvalidInterface = *ast.CallExpr

errInvalidInterfaceIndex var #

var errInvalidInterfaceIndex = *ast.CallExpr

errInvalidInterfaceName var #

var errInvalidInterfaceName = *ast.CallExpr

errLameReferral var #

var errLameReferral = *ast.CallExpr

errMalformedDNSRecordsDetail var #

errMalformedDNSRecordsDetail is the DNSError detail which is returned when a Resolver.Lookup... method receives DNS records which contain invalid DNS names. This may be returned alongside results which have had the malformed records filtered out.

var errMalformedDNSRecordsDetail = "DNS response contained records which contain invalid names"

errMissingAddress var #

For connection setup and write operations.

var errMissingAddress = *ast.CallExpr

errNoAnswerFromDNSServer var #

var errNoAnswerFromDNSServer = *ast.CallExpr

errNoSuchHost var #

Various errors contained in DNSError.

var errNoSuchHost = *ast.UnaryExpr

errNoSuchInterface var #

var errNoSuchInterface = *ast.CallExpr

errNoSuchMulticastInterface var #

var errNoSuchMulticastInterface = *ast.CallExpr

errNoSuitableAddress var #

For connection setup operations.

var errNoSuitableAddress = *ast.CallExpr

errServerMisbehaving var #

var errServerMisbehaving = *ast.CallExpr

errServerTemporarilyMisbehaving var #

errServerTemporarilyMisbehaving is like errServerMisbehaving, except that when it gets translated to a DNSError, the IsTemporary field gets set to true.

var errServerTemporarilyMisbehaving = *ast.UnaryExpr

errTimeout var #

errTimeout exists to return the historical "i/o timeout" string for context.DeadlineExceeded. See mapErr. It is also used when Dialer.Deadline is exceeded. error.Is(errTimeout, context.DeadlineExceeded) returns true. TODO(iant): We could consider changing this to os.ErrDeadlineExceeded in the future, if we make errors.Is(os.ErrDeadlineExceeded, context.DeadlineExceeded) return true.

var errTimeout error = *ast.UnaryExpr

errUnknownPort var #

Various errors contained in DNSError.

var errUnknownPort = *ast.UnaryExpr

fakePorts var #

var fakePorts sync.Map

flagNames var #

var flagNames = []string{...}

getHostname var #

var getHostname = os.Hostname

getsockoptIntFunc var #

var getsockoptIntFunc func(int, int, int) (int, error) = syscall.GetsockoptInt

hasSOLMPTCP var #

var hasSOLMPTCP bool

hexDigit const #

const hexDigit = "0123456789abcdef"

hostLookupCgo const #

hostLookupCgo means defer to cgo.

const hostLookupCgo hostLookupOrder = iota

hostLookupDNS const #

const hostLookupDNS

hostLookupDNSFiles const #

const hostLookupDNSFiles

hostLookupFiles const #

const hostLookupFiles

hostLookupFilesDNS const #

const hostLookupFilesDNS

hosts var #

hosts contains known host entries.

var hosts struct{...}

hostsFilePath var #

var hostsFilePath = *ast.BinaryExpr

hostsFilePath var #

var hostsFilePath = "/etc/hosts"

hostsFilePath var #

var hostsFilePath = "/etc/hosts"

ipStackCaps var #

var ipStackCaps ipStackCapabilities

listenFunc var #

var listenFunc func(int, int) error = syscall.Listen

listenFunc var #

var listenFunc func(syscall.Handle, int) error = syscall.Listen

listenerBacklogCache var #

var listenerBacklogCache struct{...}

lookupOrderName var #

var lookupOrderName = map[hostLookupOrder]string{...}

maxDNSPacketSize const #

Maximum DNS packet size. Value taken from https://dnsflagday.net/2020/.

const maxDNSPacketSize = 1232

maxNameinfoLen const #

These are roughly enough for the following: Source Encoding Maximum length of single name entry Unicast DNS ASCII or <=253 + a NUL terminator Unicode in RFC 5892 252 * total number of labels + delimiters + a NUL terminator Multicast DNS UTF-8 in RFC 5198 or <=253 + a NUL terminator the same as unicast DNS ASCII <=253 + a NUL terminator Local database various depends on implementation

const maxNameinfoLen = 4096

maxPacketSize const #

const maxPacketSize = 65535

maxPortBufSize const #

maxPortBufSize is the longest reasonable name of a service (non-numeric port). Currently the longest known IANA-unregistered name is "mobility-header", so we use that length, plus some slop in case something longer is added in the future.

const maxPortBufSize = *ast.BinaryExpr

maxProtoLength const #

const maxProtoLength = *ast.BinaryExpr

mdnsAssumeDoesNotExist const #

const mdnsAssumeDoesNotExist

mdnsAssumeExists const #

const mdnsAssumeExists

mdnsFromSystem const #

const mdnsFromSystem mdnsTest = iota

mptcpAvailable var #

var mptcpAvailable bool

mptcpDisabledDial const #

const mptcpDisabledDial

mptcpDisabledListen const #

const mptcpDisabledListen

mptcpEnabledDial const #

const mptcpEnabledDial

mptcpEnabledListen const #

const mptcpEnabledListen

mptcpOnce var #

var mptcpOnce sync.Once

mptcpUseDefaultDial const #

The value 0 is the system default, linked to defaultMPTCPEnabledDial

const mptcpUseDefaultDial mptcpStatusDial = iota

mptcpUseDefaultListen const #

The value 0 is the system default, linked to defaultMPTCPEnabledListen

const mptcpUseDefaultListen mptcpStatusListen = iota

multipathtcp var #

The type of service offered 0 == MPTCP disabled 1 == MPTCP enabled 2 == MPTCP enabled on listeners only 3 == MPTCP enabled on dialers only

var multipathtcp = *ast.CallExpr

nameinfoLen const #

These are roughly enough for the following: Source Encoding Maximum length of single name entry Unicast DNS ASCII or <=253 + a NUL terminator Unicode in RFC 5892 252 * total number of labels + delimiters + a NUL terminator Multicast DNS UTF-8 in RFC 5198 or <=253 + a NUL terminator the same as unicast DNS ASCII <=253 + a NUL terminator Local database various depends on implementation

const nameinfoLen = 64

netCgoBuildTag const #

const netCgoBuildTag = true

netCgoBuildTag const #

const netCgoBuildTag = false

netGoBuildTag const #

const netGoBuildTag = false

netGoBuildTag const #

const netGoBuildTag = true

netdir var #

var netdir = "/net"

netdns var #

var netdns = *ast.CallExpr

netedns0 var #

netedns0 controls whether we send an EDNS0 additional header.

var netedns0 = *ast.CallExpr

nextPortCounter var #

var nextPortCounter atomic.Int32

noCancel var #

var noCancel = *ast.CallExpr

noDeadline var #

noDeadline and noCancel are just zero values for readability with functions taking too many parameters.

var noDeadline = time.Time{...}

nssConfig var #

var nssConfig nsswitchConfig

nssConfigPath const #

const nssConfigPath = "/etc/nsswitch.conf"

onceReadProtocols var #

var onceReadProtocols sync.Once

onceReadServices var #

var onceReadServices sync.Once

packetPool var #

var packetPool = sync.Pool{...}

pollSplice var #

var pollSplice = poll.Splice

protocols var #

protocols contains minimal mappings between internet protocol names and numbers for platforms that don't have a complete list of protocol numbers. See https://www.iana.org/assignments/protocol-numbers On Unix, this map is augmented by readProtocols via lookupProtocol.

var protocols = map[string]int{...}

readFromSyscallName const #

const readFromSyscallName = "recvfrom"

readFromSyscallName const #

const readFromSyscallName = "wsarecvfrom"

readMsgFlags const #

const readMsgFlags = 0

readMsgFlags const #

const readMsgFlags = 0

readMsgFlags const #

const readMsgFlags = syscall.MSG_CMSG_CLOEXEC

readMsgSyscallName const #

const readMsgSyscallName = "recvmsg"

readMsgSyscallName const #

const readMsgSyscallName = "wsarecvmsg"

readSyscallName const #

const readSyscallName = "wsarecv"

readSyscallName const #

const readSyscallName = "fd_read"

readSyscallName const #

const readSyscallName = "read"

resolvConf var #

var resolvConf resolverConfig

rfc6724policyTable var #

RFC 6724 section 2.1. Items are sorted by the size of their Prefix.Mask.Size,

var rfc6724policyTable = policyTable{...}

scopeAdminLocal const #

const scopeAdminLocal scope = 0x4

scopeGlobal const #

const scopeGlobal scope = 0xe

scopeInterfaceLocal const #

const scopeInterfaceLocal scope = 0x1

scopeLinkLocal const #

const scopeLinkLocal scope = 0x2

scopeOrgLocal const #

const scopeOrgLocal scope = 0x8

scopeSiteLocal const #

const scopeSiteLocal scope = 0x5

services var #

services contains minimal mappings between services names and port numbers for platforms that don't have a complete list of port numbers. See https://www.iana.org/assignments/service-names-port-numbers On Unix, this map is augmented by readServices via goLookupPort.

var services = map[string]map[string]int{...}

socketFunc var #

Placeholders for socket system calls.

var socketFunc func(int, int, int) (int, error) = syscall.Socket

sockets var #

var sockets sync.Map

supportsSendfile const #

const supportsSendfile = true

supportsSendfile const #

const supportsSendfile = true

supportsSendfile const #

const supportsSendfile = false

supportsSendfile const #

const supportsSendfile = true

sysARPHardwareGREIPv4 const #

const sysARPHardwareGREIPv4 = 778

sysARPHardwareGREIPv6 const #

const sysARPHardwareGREIPv6 = 823

sysARPHardwareIPv4IPv4 const #

See linux/if_arp.h. Note that Linux doesn't support IPv4 over IPv6 tunneling.

const sysARPHardwareIPv4IPv4 = 768

sysARPHardwareIPv6IPv4 const #

const sysARPHardwareIPv6IPv4 = 776

sysARPHardwareIPv6IPv6 const #

const sysARPHardwareIPv6IPv6 = 769

sysTCP_KEEPCNT const #

syscall.TCP_KEEPINTVL and syscall.TCP_KEEPCNT might be missing on some darwin architectures.

const sysTCP_KEEPCNT = 0x102

sysTCP_KEEPCNT const #

Some macros of TCP Keep-Alive options on Solaris 11.4 may differ from those on OpenSolaris-based derivatives.

const sysTCP_KEEPCNT = 0x1F

sysTCP_KEEPIDLE const #

Some macros of TCP Keep-Alive options on Solaris 11.4 may differ from those on OpenSolaris-based derivatives.

const sysTCP_KEEPIDLE = 0x1D

sysTCP_KEEPINTVL const #

Some macros of TCP Keep-Alive options on Solaris 11.4 may differ from those on OpenSolaris-based derivatives.

const sysTCP_KEEPINTVL = 0x1E

sysTCP_KEEPINTVL const #

syscall.TCP_KEEPINTVL and syscall.TCP_KEEPCNT might be missing on some darwin architectures.

const sysTCP_KEEPINTVL = 0x101

testHookCanceledDial var #

var testHookCanceledDial = *ast.FuncLit

testHookDialTCP var #

if non-nil, overrides dialTCP.

var testHookDialTCP func(ctx context.Context, net string, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

testHookLookupIP var #

var testHookLookupIP = *ast.FuncLit

testHookSetKeepAlive var #

var testHookSetKeepAlive = *ast.FuncLit

testHookStepTime var #

testHookStepTime sleeps until time has moved forward by a nonzero amount. This helps to avoid flakes in timeout tests by ensuring that an implausibly short deadline (such as 1ns in the future) is always expired by the time a relevant system call occurs.

var testHookStepTime = *ast.FuncLit

testPreHookSetKeepAlive var #

var testPreHookSetKeepAlive = *ast.FuncLit

threadLimit var #

var threadLimit chan struct{...}

threadOnce var #

var threadOnce sync.Once

udpHeaderSize const #

const udpHeaderSize = *ast.BinaryExpr

useTCPOnly const #

to be used as a useTCP parameter to exchange

const useTCPOnly = true

useUDPOrTCP const #

const useUDPOrTCP = false

v4InV6Prefix var #

var v4InV6Prefix = []byte{...}

writeMsgSyscallName const #

const writeMsgSyscallName = "sendmsg"

writeMsgSyscallName const #

const writeMsgSyscallName = "wsasendmsg"

writeSyscallName const #

const writeSyscallName = "wsasend"

writeSyscallName const #

const writeSyscallName = "fd_write"

writeSyscallName const #

const writeSyscallName = "write"

writeToSyscallName const #

const writeToSyscallName = "wsasendto"

writeToSyscallName const #

const writeToSyscallName = "sendto"

wsaSocketFunc var #

Placeholders for socket system calls.

var wsaSocketFunc func(int32, int32, int32, *syscall.WSAProtocolInfo, uint32, uint32) (syscall.Handle, error) = windows.WSASocket

zoneCache var #

var zoneCache = ipv6ZoneCache{...}

Type Aliases

Buffers type #

Buffers contains zero or more runs of bytes to write. On certain machines, for certain types of connections, this is optimized into an OS-specific batch write operation (such as "writev").

type Buffers [][]byte

Flags type #

type Flags uint

HardwareAddr type #

A HardwareAddr represents a physical hardware address.

type HardwareAddr []byte

IP type #

An IP is a single IP address, a slice of bytes. Functions in this package accept either 4-byte (IPv4) or 16-byte (IPv6) slices as input. Note that in this documentation, referring to an IP address as an IPv4 address or an IPv6 address is a semantic property of the address, not just the length of the byte slice: a 16-byte slice can still be an IPv4 address.

type IP []byte

IPMask type #

An IPMask is a bitmask that can be used to manipulate IP addresses for IP addressing and routing. See type [IPNet] and func [ParseCIDR] for details.

type IPMask []byte

InvalidAddrError type #

type InvalidAddrError string

UnknownNetworkError type #

type UnknownNetworkError string

_C_char type #

type _C_char C.char

_C_char type #

type _C_char byte

_C_int type #

type _C_int int32

_C_int type #

type _C_int C.int

_C_socklen_t type #

type _C_socklen_t C.socklen_t

_C_socklen_t type #

type _C_socklen_t int

_C_struct___res_state type #

type _C_struct___res_state C.struct___res_state

_C_struct___res_state type #

type _C_struct___res_state unix.ResState

_C_struct_addrinfo type #

type _C_struct_addrinfo C.struct_addrinfo

_C_struct_addrinfo type #

type _C_struct_addrinfo unix.Addrinfo

_C_struct_sockaddr type #

type _C_struct_sockaddr syscall.RawSockaddr

_C_struct_sockaddr type #

type _C_struct_sockaddr C.struct_sockaddr

_C_uchar type #

type _C_uchar C.uchar

_C_uchar type #

type _C_uchar byte

_C_uint type #

type _C_uint C.uint

_C_uint type #

type _C_uint uint32

addrList type #

An addrList represents a list of network endpoint addresses.

type addrList []Addr

addrinfoErrno type #

An addrinfoErrno represents a getaddrinfo, getnameinfo-specific error number. It's a signed number and a zero value is a non-error by convention.

type addrinfoErrno int

byPref type #

byPref sorts MX records by preference

type byPref []*MX

byPriorityWeight type #

byPriorityWeight sorts SRV records by ascending priority and weight.

type byPriorityWeight []*SRV

fileAddr type #

type fileAddr string

hostLookupOrder type #

hostLookupOrder specifies the order of LookupHost lookup strategies. It is basically a simplified representation of nsswitch.conf. "files" means /etc/hosts.

type hostLookupOrder int

mdnsTest type #

mdnsTest is for testing only.

type mdnsTest int

mptcpStatusDial type #

mptcpStatusDial is a tristate for Multipath TCP on clients, see go.dev/issue/56539

type mptcpStatusDial uint8

mptcpStatusListen type #

mptcpStatusListen is a tristate for Multipath TCP on servers, see go.dev/issue/56539

type mptcpStatusListen uint8

policyTable type #

type policyTable []policyTableEntry

scope type #

RFC 6724 section 3.1.

type scope uint8

Interfaces

Addr interface #

Addr represents a network end point address. The two methods [Addr.Network] and [Addr.String] conventionally return strings that can be passed as the arguments to [Dial], but the exact form and meaning of the strings is up to the implementation.

type Addr interface {
Network() string
String() string
}

Conn interface #

Conn is a generic stream-oriented network connection. Multiple goroutines may invoke methods on a Conn simultaneously.

type Conn interface {
Read(b []byte) (n int, err error)
Write(b []byte) (n int, err error)
Close() error
LocalAddr() Addr
RemoteAddr() Addr
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
}

Error interface #

An Error represents a network error.

type Error interface {
error
Timeout() bool
Temporary() bool
}

Listener interface #

A Listener is a generic network listener for stream-oriented protocols. Multiple goroutines may invoke methods on a Listener simultaneously.

type Listener interface {
Accept() (Conn, error)
Close() error
Addr() Addr
}

PacketConn interface #

PacketConn is a generic packet-oriented network connection. Multiple goroutines may invoke methods on a PacketConn simultaneously.

type PacketConn interface {
ReadFrom(p []byte) (n int, addr Addr, err error)
WriteTo(p []byte, addr Addr) (n int, err error)
Close() error
LocalAddr() Addr
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
}

buffersWriter interface #

buffersWriter is the interface implemented by Conns that support a "writev"-like batch write optimization. writeBuffers should fully consume and write all chunks from the provided Buffers, else it should report a non-nil error.

type buffersWriter interface {
writeBuffers(*Buffers) (int64, error)
}

sockaddr interface #

A sockaddr represents a TCP, UDP, IP or Unix network endpoint address that can be converted into a syscall.Sockaddr.

type sockaddr interface {
Addr
family() int
isWildcard() bool
sockaddr(family int) (syscall.Sockaddr, error)
toLocal(net string) sockaddr
}

temporary interface #

type temporary interface {
Temporary() bool
}

timeout interface #

type timeout interface {
Timeout() bool
}

Structs

AddrError struct #

type AddrError struct {
Err string
Addr string
}

DNSConfigError struct #

DNSConfigError represents an error reading the machine's DNS configuration. (No longer used; kept for compatibility.)

type DNSConfigError struct {
Err error
}

DNSError struct #

DNSError represents a DNS lookup error.

type DNSError struct {
UnwrapErr error
Err string
Name string
Server string
IsTimeout bool
IsTemporary bool
IsNotFound bool
}

Dialer struct #

A Dialer contains options for connecting to an address. The zero value for each field is equivalent to dialing without that option. Dialing with the zero value of Dialer is therefore equivalent to just calling the [Dial] function. It is safe to call Dialer's methods concurrently.

type Dialer struct {
Timeout time.Duration
Deadline time.Time
LocalAddr Addr
DualStack bool
FallbackDelay time.Duration
KeepAlive time.Duration
KeepAliveConfig KeepAliveConfig
Resolver *Resolver
Cancel <-chan struct{...}
Control func(network string, address string, c syscall.RawConn) error
ControlContext func(ctx context.Context, network string, address string, c syscall.RawConn) error
mptcpStatus mptcpStatusDial
}

IPAddr struct #

IPAddr represents the address of an IP end point.

type IPAddr struct {
IP IP
Zone string
}

IPConn struct #

IPConn is the implementation of the [Conn] and [PacketConn] interfaces for IP network connections.

type IPConn struct {
conn
}

IPNet struct #

An IPNet represents an IP network.

type IPNet struct {
IP IP
Mask IPMask
}

Interface struct #

Interface represents a mapping between network interface name and index. It also represents network interface facility information.

type Interface struct {
Index int
MTU int
Name string
HardwareAddr HardwareAddr
Flags Flags
}

KeepAliveConfig struct #

KeepAliveConfig contains TCP keep-alive options. If the Idle, Interval, or Count fields are zero, a default value is chosen. If a field is negative, the corresponding socket-level option will be left unchanged. Note that prior to Windows 10 version 1709, neither setting Idle and Interval separately nor changing Count (which is usually 10) is supported. Therefore, it's recommended to set both Idle and Interval to non-negative values in conjunction with a -1 for Count on those old Windows if you intend to customize the TCP keep-alive settings. By contrast, if only one of Idle and Interval is set to a non-negative value, the other will be set to the system default value, and ultimately, set both Idle and Interval to negative values if you want to leave them unchanged. Note that Solaris and its derivatives do not support setting Interval to a non-negative value and Count to a negative value, or vice-versa.

type KeepAliveConfig struct {
Enable bool
Idle time.Duration
Interval time.Duration
Count int
}

ListenConfig struct #

ListenConfig contains options for listening to an address.

type ListenConfig struct {
Control func(network string, address string, c syscall.RawConn) error
KeepAlive time.Duration
KeepAliveConfig KeepAliveConfig
mptcpStatus mptcpStatusListen
}

MX struct #

An MX represents a single DNS MX record.

type MX struct {
Host string
Pref uint16
}

NS struct #

An NS represents a single DNS NS record.

type NS struct {
Host string
}

OpError struct #

OpError is the error type usually returned by functions in the net package. It describes the operation, network type, and address of an error.

type OpError struct {
Op string
Net string
Source Addr
Addr Addr
Err error
}

ParseError struct #

A ParseError is the error type of literal network address parsers.

type ParseError struct {
Type string
Text string
}

Resolver struct #

A Resolver looks up names and numbers. A nil *Resolver is equivalent to a zero Resolver.

type Resolver struct {
PreferGo bool
StrictErrors bool
Dial func(ctx context.Context, network string, address string) (Conn, error)
lookupGroup singleflight.Group
}

SRV struct #

An SRV represents a single DNS SRV record.

type SRV struct {
Target string
Port uint16
Priority uint16
Weight uint16
}

TCPAddr struct #

TCPAddr represents the address of a TCP end point.

type TCPAddr struct {
IP IP
Port int
Zone string
}

TCPConn struct #

TCPConn is an implementation of the [Conn] interface for TCP network connections.

type TCPConn struct {
conn
}

TCPListener struct #

TCPListener is a TCP network listener. Clients should typically use variables of type [Listener] instead of assuming TCP.

type TCPListener struct {
fd *netFD
lc ListenConfig
}

UDPAddr struct #

UDPAddr represents the address of a UDP end point.

type UDPAddr struct {
IP IP
Port int
Zone string
}

UDPConn struct #

UDPConn is the implementation of the [Conn] and [PacketConn] interfaces for UDP network connections.

type UDPConn struct {
conn
}

UnixAddr struct #

UnixAddr represents the address of a Unix domain socket end point.

type UnixAddr struct {
Name string
Net string
}

UnixConn struct #

UnixConn is an implementation of the [Conn] interface for connections to Unix domain sockets.

type UnixConn struct {
conn
}

UnixListener struct #

UnixListener is a Unix domain socket listener. Clients should typically use variables of type [Listener] instead of assuming Unix domain sockets.

type UnixListener struct {
fd *netFD
path string
unlink bool
unlinkOnce sync.Once
}

_C_struct___res_state struct #

type _C_struct___res_state struct {

}

addrPortUDPAddr struct #

An addrPortUDPAddr is a netip.AddrPort-based UDP address that satisfies the Addr interface.

type addrPortUDPAddr struct {
netip.AddrPort
}

byName struct #

type byName struct {
addrs []string
canonicalName string
}

byRFC6724Info struct #

type byRFC6724Info struct {
addr IPAddr
addrAttr ipAttr
src netip.Addr
srcAttr ipAttr
}

canceledError struct #

canceledError lets us return the same error string we have always returned, while still being Is context.Canceled.

type canceledError struct {

}

conf struct #

conf is used to determine name resolution configuration.

type conf struct {
netGo bool
netCgo bool
dnsDebugLevel int
preferCgo bool
goos string
mdnsTest mdnsTest
}

conn struct #

type conn struct {
fd *netFD
}

deadlineTimer struct #

type deadlineTimer struct {
timer chan *time.Timer
expired chan struct{...}
}

dnsConfig struct #

type dnsConfig struct {
servers []string
search []string
ndots int
timeout time.Duration
attempts int
rotate bool
unknownOpt bool
lookup []string
err error
mtime time.Time
soffset uint32
singleRequest bool
useTCP bool
trustAD bool
noReload bool
}

fakeNetFD struct #

type fakeNetFD struct {
fd *netFD
assignedPort int
queue *packetQueue
peer *netFD
readDeadline *ast.IndexExpr
writeDeadline *ast.IndexExpr
fakeAddr fakeSockAddr
incoming chan []*netFD
incomingFull chan []*netFD
incomingEmpty chan bool
}

fakeSockAddr struct #

type fakeSockAddr struct {
family int
address string
}

file struct #

type file struct {
file *os.File
data []byte
atEOF bool
}

ifreq struct #

type ifreq struct {
Name [16]uint8
Ifru [16]byte
}

ipAttr struct #

type ipAttr struct {
Scope scope
Precedence uint8
Label uint8
}

ipStackCapabilities struct #

type ipStackCapabilities struct {
sync.Once
ipv4Enabled bool
ipv6Enabled bool
ipv4MappedIPv6Enabled bool
}

ipv6ZoneCache struct #

An ipv6ZoneCache represents a cache holding partial network interface information. It is used for reducing the cost of IPv6 addressing scope zone resolution. Multiple names sharing the index are managed by first-come first-served basis for consistency.

type ipv6ZoneCache struct {
sync.RWMutex
lastFetched time.Time
toIndex map[string]int
toName map[int]string
}

netFD struct #

Network file descriptor.

type netFD struct {
pfd poll.FD
family int
sotype int
isConnected bool
net string
laddr Addr
raddr Addr
}

netFD struct #

Network file descriptor.

type netFD struct {
pfd poll.FD
net string
n string
dir string
listen *os.File
ctl *os.File
data *os.File
laddr Addr
raddr Addr
isStream bool
}

netFD struct #

Network file descriptor.

type netFD struct {
pfd poll.FD
family int
sotype int
isConnected bool
net string
laddr Addr
raddr Addr
*fakeNetFD
}

noReadFrom struct #

noReadFrom can be embedded alongside another type to hide the ReadFrom method of that other type.

type noReadFrom struct {

}

noWriteTo struct #

noWriteTo can be embedded alongside another type to hide the WriteTo method of that other type.

type noWriteTo struct {

}

notFoundError struct #

notFoundError is a special error understood by the newDNSError function, which causes a creation of a DNSError with IsNotFound field set to true.

type notFoundError struct {
s string
}

nssConf struct #

nssConf represents the state of the machine's /etc/nsswitch.conf file.

type nssConf struct {
mtime time.Time
err error
sources map[string][]nssSource
}

nssCriterion struct #

nssCriterion is the parsed structure of one of the criteria in brackets after an NSS source name.

type nssCriterion struct {
negate bool
status string
action string
}

nssSource struct #

type nssSource struct {
source string
criteria []nssCriterion
}

nsswitchConfig struct #

type nsswitchConfig struct {
initOnce sync.Once
ch chan struct{...}
lastChecked time.Time
mu sync.Mutex
nssConf *nssConf
}

onlyValuesCtx struct #

onlyValuesCtx is a context that uses an underlying context for value lookup if the underlying context hasn't yet expired.

type onlyValuesCtx struct {
context.Context
lookupValues context.Context
}

packet struct #

type packet struct {
buf []byte
bufOffset int
next *packet
from sockaddr
}

packetQueue struct #

A packetQueue is a set of 1-buffered channels implementing a FIFO queue of packets.

type packetQueue struct {
empty chan packetQueueState
ready chan packetQueueState
full chan packetQueueState
}

packetQueueState struct #

type packetQueueState struct {
head *packet
tail *packet
nBytes int
readBufferBytes int
readClosed bool
writeClosed bool
noLinger bool
}

pipe struct #

type pipe struct {
wrMu sync.Mutex
rdRx <-chan []byte
rdTx chan<- int
wrTx chan<- []byte
wrRx <-chan int
once sync.Once
localDone chan struct{...}
remoteDone <-chan struct{...}
readDeadline pipeDeadline
writeDeadline pipeDeadline
}

pipeAddr struct #

type pipeAddr struct {

}

pipeDeadline struct #

pipeDeadline is an abstraction for handling timeouts.

type pipeDeadline struct {
mu sync.Mutex
timer *time.Timer
cancel chan struct{...}
}

policyTableEntry struct #

type policyTableEntry struct {
Prefix netip.Prefix
Precedence uint8
Label uint8
}

rawConn struct #

type rawConn struct {
fd *netFD
}

rawListener struct #

type rawListener struct {
rawConn
}

resolverConfig struct #

A resolverConfig represents a DNS stub resolver configuration.

type resolverConfig struct {
initOnce sync.Once
ch chan struct{...}
lastChecked time.Time
dnsConfig *ast.IndexExpr
}

sysDialer struct #

sysDialer contains a Dial's parameters and configuration.

type sysDialer struct {
Dialer
network string
address string
testHookDialTCP func(ctx context.Context, net string, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)
}

sysListener struct #

sysListener contains a Listen's parameters and configuration.

type sysListener struct {
ListenConfig
network string
address string
}

tcpConnWithoutReadFrom struct #

tcpConnWithoutReadFrom implements all the methods of *TCPConn other than ReadFrom. This is used to permit ReadFrom to call io.Copy without leading to a recursive call to ReadFrom.

type tcpConnWithoutReadFrom struct {
noReadFrom
*TCPConn
}

tcpConnWithoutWriteTo struct #

tcpConnWithoutWriteTo implements all the methods of *TCPConn other than WriteTo. This is used to permit WriteTo to call io.Copy without leading to a recursive call to WriteTo.

type tcpConnWithoutWriteTo struct {
noWriteTo
*TCPConn
}

temporaryError struct #

temporaryError is an error type that implements the [Error] interface. It returns true from the Temporary method.

type temporaryError struct {
s string
}

timeoutError struct #

type timeoutError struct {

}

udpHeader struct #

type udpHeader struct {
raddr IP
laddr IP
ifcaddr IP
rport uint16
lport uint16
}

unknownAddr struct #

type unknownAddr struct {

}

Functions

Accept method #

Accept implements the Accept method in the [Listener] interface. Returned connections will be of type [*UnixConn].

func (l *UnixListener) Accept() (Conn, error)

Accept method #

Accept implements the Accept method in the [Listener] interface; it waits for the next call and returns a generic [Conn].

func (l *TCPListener) Accept() (Conn, error)

AcceptTCP method #

AcceptTCP accepts the next incoming call and returns the new connection.

func (l *TCPListener) AcceptTCP() (*TCPConn, error)

AcceptUnix method #

AcceptUnix accepts the next incoming call and returns the new connection.

func (l *UnixListener) AcceptUnix() (*UnixConn, error)

Addr method #

Addr returns the listener's network address. The Addr returned is shared by all invocations of Addr, so do not modify it.

func (l *UnixListener) Addr() Addr

Addr method #

Addr returns the listener's network address, a [*TCPAddr]. The Addr returned is shared by all invocations of Addr, so do not modify it.

func (l *TCPListener) Addr() Addr

AddrPort method #

AddrPort returns the [TCPAddr] a as a [netip.AddrPort]. If a.Port does not fit in a uint16, it's silently truncated. If a is nil, a zero value is returned.

func (a *TCPAddr) AddrPort() netip.AddrPort

AddrPort method #

AddrPort returns the [UDPAddr] a as a [netip.AddrPort]. If a.Port does not fit in a uint16, it's silently truncated. If a is nil, a zero value is returned.

func (a *UDPAddr) AddrPort() netip.AddrPort

Addrs method #

Addrs returns a list of unicast interface addresses for a specific interface.

func (ifi *Interface) Addrs() ([]Addr, error)

AppendText method #

AppendText implements the [encoding.TextAppender] interface. The encoding is the same as returned by [IP.String], with one exception: When len(ip) is zero, it appends nothing.

func (ip IP) AppendText(b []byte) ([]byte, error)

Bytes method #

func (h *udpHeader) Bytes() []byte

CIDRMask function #

CIDRMask returns an [IPMask] consisting of 'ones' 1 bits followed by 0s up to a total length of 'bits' bits. For a mask of this form, CIDRMask is the inverse of [IPMask.Size].

func CIDRMask(ones int, bits int) IPMask

Classify method #

Classify returns the policyTableEntry of the entry with the longest matching prefix that contains ip. The table t must be sorted from largest mask size to smallest.

func (t policyTable) Classify(ip netip.Addr) policyTableEntry

Close method #

Close closes the connection.

func (c *conn) Close() error

Close method #

func (p *pipe) Close() error

Close method #

func (fd *netFD) Close() error

Close method #

Close stops listening on the TCP address. Already Accepted connections are not closed.

func (l *TCPListener) Close() error

Close method #

Close stops listening on the Unix address. Already accepted connections are not closed.

func (l *UnixListener) Close() error

Close method #

func (fd *netFD) Close() error

Close method #

func (fd *netFD) Close() error

Close method #

func (ffd *fakeNetFD) Close() (err error)

CloseRead method #

CloseRead shuts down the reading side of the TCP connection. Most callers should just use Close.

func (c *TCPConn) CloseRead() error

CloseRead method #

CloseRead shuts down the reading side of the Unix domain connection. Most callers should just use Close.

func (c *UnixConn) CloseRead() error

CloseWrite method #

CloseWrite shuts down the writing side of the TCP connection. Most callers should just use Close.

func (c *TCPConn) CloseWrite() error

CloseWrite method #

CloseWrite shuts down the writing side of the Unix domain connection. Most callers should just use Close.

func (c *UnixConn) CloseWrite() error

Contains method #

Contains reports whether the network includes ip.

func (n *IPNet) Contains(ip IP) bool

Control method #

func (c *rawConn) Control(f func(uintptr)) error

DefaultMask method #

DefaultMask returns the default IP mask for the IP address ip. Only IPv4 addresses have default masks; DefaultMask returns nil if ip is not a valid IPv4 address.

func (ip IP) DefaultMask() IPMask

Dial function #

Dial connects to the address on the named network. Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and "unixpacket". For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address, or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name. If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007. The functions [JoinHostPort] and [SplitHostPort] manipulate a pair of host and port in this form. When using TCP, and the host resolves to multiple IP addresses, Dial will try each IP address in order until one succeeds. Examples: Dial("tcp", "golang.org:http") Dial("tcp", "192.0.2.1:http") Dial("tcp", "198.51.100.1:80") Dial("udp", "[2001:db8::1]:domain") Dial("udp", "[fe80::1%lo0]:53") Dial("tcp", ":80") For IP networks, the network must be "ip", "ip4" or "ip6" followed by a colon and a literal protocol number or a protocol name, and the address has the form "host". The host must be a literal IP address or a literal IPv6 address with zone. It depends on each operating system how the operating system behaves with a non-well known protocol number such as "0" or "255". Examples: Dial("ip4:1", "192.0.2.1") Dial("ip6:ipv6-icmp", "2001:db8::1") Dial("ip6:58", "fe80::1%lo0") For TCP, UDP and IP networks, if the host is empty or a literal unspecified IP address, as in ":80", "0.0.0.0:80" or "[::]:80" for TCP and UDP, "", "0.0.0.0" or "::" for IP, the local system is assumed. For Unix networks, the address must be a file system path.

func Dial(network string, address string) (Conn, error)

Dial method #

Dial connects to the address on the named network. See func Dial for a description of the network and address parameters. Dial uses [context.Background] internally; to specify the context, use [Dialer.DialContext].

func (d *Dialer) Dial(network string, address string) (Conn, error)

DialContext method #

DialContext connects to the address on the named network using the provided context. The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection. When using TCP, and the host in the address parameter resolves to multiple network addresses, any dial timeout (from d.Timeout or ctx) is spread over each consecutive dial, such that each is given an appropriate fraction of the time to connect. For example, if a host has 4 IP addresses and the timeout is 1 minute, the connect to each single address will be given 15 seconds to complete before trying the next one. See func [Dial] for a description of the network and address parameters.

func (d *Dialer) DialContext(ctx context.Context, network string, address string) (Conn, error)

DialIP function #

DialIP acts like [Dial] for IP networks. The network must be an IP network name; see func Dial for details. If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.

func DialIP(network string, laddr *IPAddr, raddr *IPAddr) (*IPConn, error)

DialTCP function #

DialTCP acts like [Dial] for TCP networks. The network must be a TCP network name; see func Dial for details. If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.

func DialTCP(network string, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

DialTimeout function #

DialTimeout acts like [Dial] but takes a timeout. The timeout includes name resolution, if required. When using TCP, and the host in the address parameter resolves to multiple IP addresses, the timeout is spread over each consecutive dial, such that each is given an appropriate fraction of the time to connect. See func Dial for a description of the network and address parameters.

func DialTimeout(network string, address string, timeout time.Duration) (Conn, error)

DialUDP function #

DialUDP acts like [Dial] for UDP networks. The network must be a UDP network name; see func [Dial] for details. If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.

func DialUDP(network string, laddr *UDPAddr, raddr *UDPAddr) (*UDPConn, error)

DialUnix function #

DialUnix acts like [Dial] for Unix networks. The network must be a Unix network name; see func Dial for details. If laddr is non-nil, it is used as the local address for the connection.

func DialUnix(network string, laddr *UnixAddr, raddr *UnixAddr) (*UnixConn, error)

Equal method #

Equal reports whether ip and x are the same IP address. An IPv4 address and that same address in IPv6 form are considered to be equal.

func (ip IP) Equal(x IP) bool

Error method #

func (eai addrinfoErrno) Error() string

Error method #

func (e *OpError) Error() string

Error method #

func (canceledError) Error() string

Error method #

func (e *ParseError) Error() string

Error method #

func (e *DNSError) Error() string

Error method #

func (e *AddrError) Error() string

Error method #

func (e UnknownNetworkError) Error() string

Error method #

func (e InvalidAddrError) Error() string

Error method #

func (e *temporaryError) Error() string

Error method #

func (e *DNSConfigError) Error() string

Error method #

func (e *notFoundError) Error() string

Error method #

func (e *timeoutError) Error() string

File method #

File returns a copy of the underlying [os.File]. It is the caller's responsibility to close f when finished. Closing l does not affect f, and closing f does not affect l. The returned os.File's file descriptor is different from the connection's. Attempting to change properties of the original using this duplicate may or may not have the desired effect.

func (l *UnixListener) File() (f *os.File, err error)

File method #

File returns a copy of the underlying [os.File]. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c. The returned os.File's file descriptor is different from the connection's. Attempting to change properties of the original using this duplicate may or may not have the desired effect.

func (c *conn) File() (f *os.File, err error)

File method #

File returns a copy of the underlying [os.File]. It is the caller's responsibility to close f when finished. Closing l does not affect f, and closing f does not affect l. The returned os.File's file descriptor is different from the connection's. Attempting to change properties of the original using this duplicate may or may not have the desired effect.

func (l *TCPListener) File() (f *os.File, err error)

FileConn function #

FileConn returns a copy of the network connection corresponding to the open file f. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.

func FileConn(f *os.File) (c Conn, err error)

FileListener function #

FileListener returns a copy of the network listener corresponding to the open file f. It is the caller's responsibility to close ln when finished. Closing ln does not affect f, and closing f does not affect ln.

func FileListener(f *os.File) (ln Listener, err error)

FilePacketConn function #

FilePacketConn returns a copy of the packet network connection corresponding to the open file f. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.

func FilePacketConn(f *os.File) (c PacketConn, err error)

IPv4 function #

IPv4 returns the IP address (in 16-byte form) of the IPv4 address a.b.c.d.

func IPv4(a byte, b byte, c byte, d byte) IP

IPv4Mask function #

IPv4Mask returns the IP mask (in 4-byte form) of the IPv4 mask a.b.c.d.

func IPv4Mask(a byte, b byte, c byte, d byte) IPMask

InterfaceAddrs function #

InterfaceAddrs returns a list of the system's unicast interface addresses. The returned list does not identify the associated interface; use Interfaces and [Interface.Addrs] for more detail.

func InterfaceAddrs() ([]Addr, error)

InterfaceByIndex function #

InterfaceByIndex returns the interface specified by index. On Solaris, it returns one of the logical network interfaces sharing the logical data link; for more precision use [InterfaceByName].

func InterfaceByIndex(index int) (*Interface, error)

InterfaceByName function #

InterfaceByName returns the interface specified by name.

func InterfaceByName(name string) (*Interface, error)

Interfaces function #

Interfaces returns a list of the system's network interfaces.

func Interfaces() ([]Interface, error)

Is method #

func (canceledError) Is(err error) bool

Is method #

func (e *timeoutError) Is(err error) bool

IsGlobalUnicast method #

IsGlobalUnicast reports whether ip is a global unicast address. The identification of global unicast addresses uses address type identification as defined in RFC 1122, RFC 4632 and RFC 4291 with the exception of IPv4 directed broadcast addresses. It returns true even if ip is in IPv4 private address space or local IPv6 unicast address space.

func (ip IP) IsGlobalUnicast() bool

IsInterfaceLocalMulticast method #

IsInterfaceLocalMulticast reports whether ip is an interface-local multicast address.

func (ip IP) IsInterfaceLocalMulticast() bool

IsLinkLocalMulticast method #

IsLinkLocalMulticast reports whether ip is a link-local multicast address.

func (ip IP) IsLinkLocalMulticast() bool

IsLinkLocalUnicast method #

IsLinkLocalUnicast reports whether ip is a link-local unicast address.

func (ip IP) IsLinkLocalUnicast() bool

IsLoopback method #

IsLoopback reports whether ip is a loopback address.

func (ip IP) IsLoopback() bool

IsMulticast method #

IsMulticast reports whether ip is a multicast address.

func (ip IP) IsMulticast() bool

IsPrivate method #

IsPrivate reports whether ip is a private address, according to RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).

func (ip IP) IsPrivate() bool

IsUnspecified method #

IsUnspecified reports whether ip is an unspecified address, either the IPv4 address "0.0.0.0" or the IPv6 address "::".

func (ip IP) IsUnspecified() bool

JoinHostPort function #

JoinHostPort combines host and port into a network address of the form "host:port". If host contains a colon, as found in literal IPv6 addresses, then JoinHostPort returns "[host]:port". See func Dial for a description of the host and port parameters.

func JoinHostPort(host string, port string) string

Listen function #

Listen announces on the local network address. The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket". For TCP networks, if the host in the address parameter is empty or a literal unspecified IP address, Listen listens on all available unicast and anycast IP addresses of the local system. To only use IPv4, use network "tcp4". The address can use a host name, but this is not recommended, because it will create a listener for at most one of the host's IP addresses. If the port in the address parameter is empty or "0", as in "127.0.0.1:" or "[::1]:0", a port number is automatically chosen. The [Addr] method of [Listener] can be used to discover the chosen port. See func [Dial] for a description of the network and address parameters. Listen uses context.Background internally; to specify the context, use [ListenConfig.Listen].

func Listen(network string, address string) (Listener, error)

Listen method #

Listen announces on the local network address. See func Listen for a description of the network and address parameters. The ctx argument is used while resolving the address on which to listen; it does not affect the returned Listener.

func (lc *ListenConfig) Listen(ctx context.Context, network string, address string) (Listener, error)

ListenIP function #

ListenIP acts like [ListenPacket] for IP networks. The network must be an IP network name; see func Dial for details. If the IP field of laddr is nil or an unspecified IP address, ListenIP listens on all available IP addresses of the local system except multicast IP addresses.

func ListenIP(network string, laddr *IPAddr) (*IPConn, error)

ListenMulticastUDP function #

ListenMulticastUDP acts like [ListenPacket] for UDP networks but takes a group address on a specific network interface. The network must be a UDP network name; see func [Dial] for details. ListenMulticastUDP listens on all available IP addresses of the local system including the group, multicast IP address. If ifi is nil, ListenMulticastUDP uses the system-assigned multicast interface, although this is not recommended because the assignment depends on platforms and sometimes it might require routing configuration. If the Port field of gaddr is 0, a port number is automatically chosen. ListenMulticastUDP is just for convenience of simple, small applications. There are [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] packages for general purpose uses. Note that ListenMulticastUDP will set the IP_MULTICAST_LOOP socket option to 0 under IPPROTO_IP, to disable loopback of multicast packets.

func ListenMulticastUDP(network string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error)

ListenPacket function #

ListenPacket announces on the local network address. The network must be "udp", "udp4", "udp6", "unixgram", or an IP transport. The IP transports are "ip", "ip4", or "ip6" followed by a colon and a literal protocol number or a protocol name, as in "ip:1" or "ip:icmp". For UDP and IP networks, if the host in the address parameter is empty or a literal unspecified IP address, ListenPacket listens on all available IP addresses of the local system except multicast IP addresses. To only use IPv4, use network "udp4" or "ip4:proto". The address can use a host name, but this is not recommended, because it will create a listener for at most one of the host's IP addresses. If the port in the address parameter is empty or "0", as in "127.0.0.1:" or "[::1]:0", a port number is automatically chosen. The LocalAddr method of [PacketConn] can be used to discover the chosen port. See func [Dial] for a description of the network and address parameters. ListenPacket uses context.Background internally; to specify the context, use [ListenConfig.ListenPacket].

func ListenPacket(network string, address string) (PacketConn, error)

ListenPacket method #

ListenPacket announces on the local network address. See func ListenPacket for a description of the network and address parameters. The ctx argument is used while resolving the address on which to listen; it does not affect the returned Listener.

func (lc *ListenConfig) ListenPacket(ctx context.Context, network string, address string) (PacketConn, error)

ListenTCP function #

ListenTCP acts like [Listen] for TCP networks. The network must be a TCP network name; see func Dial for details. If the IP field of laddr is nil or an unspecified IP address, ListenTCP listens on all available unicast and anycast IP addresses of the local system. If the Port field of laddr is 0, a port number is automatically chosen.

func ListenTCP(network string, laddr *TCPAddr) (*TCPListener, error)

ListenUDP function #

ListenUDP acts like [ListenPacket] for UDP networks. The network must be a UDP network name; see func [Dial] for details. If the IP field of laddr is nil or an unspecified IP address, ListenUDP listens on all available IP addresses of the local system except multicast IP addresses. If the Port field of laddr is 0, a port number is automatically chosen.

func ListenUDP(network string, laddr *UDPAddr) (*UDPConn, error)

ListenUnix function #

ListenUnix acts like [Listen] for Unix networks. The network must be "unix" or "unixpacket".

func ListenUnix(network string, laddr *UnixAddr) (*UnixListener, error)

ListenUnixgram function #

ListenUnixgram acts like [ListenPacket] for Unix networks. The network must be "unixgram".

func ListenUnixgram(network string, laddr *UnixAddr) (*UnixConn, error)

LocalAddr method #

LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.

func (c *conn) LocalAddr() Addr

LocalAddr method #

func (*pipe) LocalAddr() Addr

LookupAddr function #

LookupAddr performs a reverse lookup for the given address, returning a list of names mapping to that address. The returned names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any. When using the host C library resolver, at most one result will be returned. To bypass the host resolver, use a custom [Resolver]. LookupAddr uses [context.Background] internally; to specify the context, use [Resolver.LookupAddr].

func LookupAddr(addr string) (names []string, err error)

LookupAddr method #

LookupAddr performs a reverse lookup for the given address, returning a list of names mapping to that address. The returned names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any.

func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error)

LookupCNAME method #

LookupCNAME returns the canonical name for the given host. Callers that do not care about the canonical name can call [LookupHost] or [LookupIP] directly; both take care of resolving the canonical name as part of the lookup. A canonical name is the final name after following zero or more CNAME records. LookupCNAME does not return an error if host does not contain DNS "CNAME" records, as long as host resolves to address records. The returned canonical name is validated to be a properly formatted presentation-format domain name.

func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error)

LookupCNAME function #

LookupCNAME returns the canonical name for the given host. Callers that do not care about the canonical name can call [LookupHost] or [LookupIP] directly; both take care of resolving the canonical name as part of the lookup. A canonical name is the final name after following zero or more CNAME records. LookupCNAME does not return an error if host does not contain DNS "CNAME" records, as long as host resolves to address records. The returned canonical name is validated to be a properly formatted presentation-format domain name. LookupCNAME uses [context.Background] internally; to specify the context, use [Resolver.LookupCNAME].

func LookupCNAME(host string) (cname string, err error)

LookupHost method #

LookupHost looks up the given host using the local resolver. It returns a slice of that host's addresses.

func (r *Resolver) LookupHost(ctx context.Context, host string) (addrs []string, err error)

LookupHost function #

LookupHost looks up the given host using the local resolver. It returns a slice of that host's addresses. LookupHost uses [context.Background] internally; to specify the context, use [Resolver.LookupHost].

func LookupHost(host string) (addrs []string, err error)

LookupIP method #

LookupIP looks up host for the given network using the local resolver. It returns a slice of that host's IP addresses of the type specified by network. network must be one of "ip", "ip4" or "ip6".

func (r *Resolver) LookupIP(ctx context.Context, network string, host string) ([]IP, error)

LookupIP function #

LookupIP looks up host using the local resolver. It returns a slice of that host's IPv4 and IPv6 addresses.

func LookupIP(host string) ([]IP, error)

LookupIPAddr method #

LookupIPAddr looks up host using the local resolver. It returns a slice of that host's IPv4 and IPv6 addresses.

func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, error)

LookupMX function #

LookupMX returns the DNS MX records for the given domain name sorted by preference. The returned mail server names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any. LookupMX uses [context.Background] internally; to specify the context, use [Resolver.LookupMX].

func LookupMX(name string) ([]*MX, error)

LookupMX method #

LookupMX returns the DNS MX records for the given domain name sorted by preference. The returned mail server names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any.

func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error)

LookupNS function #

LookupNS returns the DNS NS records for the given domain name. The returned name server names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any. LookupNS uses [context.Background] internally; to specify the context, use [Resolver.LookupNS].

func LookupNS(name string) ([]*NS, error)

LookupNS method #

LookupNS returns the DNS NS records for the given domain name. The returned name server names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any.

func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error)

LookupNetIP method #

LookupNetIP looks up host using the local resolver. It returns a slice of that host's IP addresses of the type specified by network. The network must be one of "ip", "ip4" or "ip6".

func (r *Resolver) LookupNetIP(ctx context.Context, network string, host string) ([]netip.Addr, error)

LookupPort method #

LookupPort looks up the port for the given network and service. The network must be one of "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6" or "ip".

func (r *Resolver) LookupPort(ctx context.Context, network string, service string) (port int, err error)

LookupPort function #

LookupPort looks up the port for the given network and service. LookupPort uses [context.Background] internally; to specify the context, use [Resolver.LookupPort].

func LookupPort(network string, service string) (port int, err error)

LookupSRV method #

LookupSRV tries to resolve an [SRV] query of the given service, protocol, and domain name. The proto is "tcp" or "udp". The returned records are sorted by priority and randomized by weight within a priority. LookupSRV constructs the DNS name to look up following RFC 2782. That is, it looks up _service._proto.name. To accommodate services publishing SRV records under non-standard names, if both service and proto are empty strings, LookupSRV looks up name directly. The returned service names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any.

func (r *Resolver) LookupSRV(ctx context.Context, service string, proto string, name string) (string, []*SRV, error)

LookupSRV function #

LookupSRV tries to resolve an [SRV] query of the given service, protocol, and domain name. The proto is "tcp" or "udp". The returned records are sorted by priority and randomized by weight within a priority. LookupSRV constructs the DNS name to look up following RFC 2782. That is, it looks up _service._proto.name. To accommodate services publishing SRV records under non-standard names, if both service and proto are empty strings, LookupSRV looks up name directly. The returned service names are validated to be properly formatted presentation-format domain names. If the response contains invalid names, those records are filtered out and an error will be returned alongside the remaining results, if any.

func LookupSRV(service string, proto string, name string) (cname string, addrs []*SRV, err error)

LookupTXT method #

LookupTXT returns the DNS TXT records for the given domain name. If a DNS TXT record holds multiple strings, they are concatenated as a single string.

func (r *Resolver) LookupTXT(ctx context.Context, name string) ([]string, error)

LookupTXT function #

LookupTXT returns the DNS TXT records for the given domain name. If a DNS TXT record holds multiple strings, they are concatenated as a single string. LookupTXT uses [context.Background] internally; to specify the context, use [Resolver.LookupTXT].

func LookupTXT(name string) ([]string, error)

MarshalText method #

MarshalText implements the [encoding.TextMarshaler] interface. The encoding is the same as returned by [IP.String], with one exception: When len(ip) is zero, it returns an empty slice.

func (ip IP) MarshalText() ([]byte, error)

Mask method #

Mask returns the result of masking the IP address ip with mask.

func (ip IP) Mask(mask IPMask) IP

MulticastAddrs method #

MulticastAddrs returns a list of multicast, joined group addresses for a specific interface.

func (ifi *Interface) MulticastAddrs() ([]Addr, error)

MultipathTCP method #

MultipathTCP reports whether MPTCP will be used. This method doesn't check if MPTCP is supported by the operating system or not.

func (lc *ListenConfig) MultipathTCP() bool

MultipathTCP method #

MultipathTCP reports whether the ongoing connection is using MPTCP. If Multipath TCP is not supported by the host, by the other peer or intentionally / accidentally filtered out by a device in between, a fallback to TCP will be done. This method does its best to check if MPTCP is still being used or not. On Linux, more conditions are verified on kernels >= v5.16, improving the results.

func (c *TCPConn) MultipathTCP() (bool, error)

MultipathTCP method #

MultipathTCP reports whether MPTCP will be used. This method doesn't check if MPTCP is supported by the operating system or not.

func (d *Dialer) MultipathTCP() bool

Network method #

func (addrPortUDPAddr) Network() string

Network method #

Network returns the network type of the underlying connection. Other packages in std that import internal/poll and are unable to import net (such as os) can use a type assertion to access this extension method so that they can distinguish different socket types. Network is not intended for use outside the standard library.

func (c *rawConn) Network() poll.String

Network method #

func (pipeAddr) Network() string

Network method #

Network returns the address's network name, "ip".

func (a *IPAddr) Network() string

Network method #

Network returns the address's network name, "tcp".

func (a *TCPAddr) Network() string

Network method #

func (fileAddr) Network() string

Network method #

func (unknownAddr) Network() string

Network method #

Network returns the address's network name, "ip+net".

func (n *IPNet) Network() string

Network method #

Network returns the address's network name, "udp".

func (a *UDPAddr) Network() string

Network method #

Network returns the address's network name, "unix", "unixgram" or "unixpacket".

func (a *UnixAddr) Network() string

ParseCIDR function #

ParseCIDR parses s as a CIDR notation IP address and prefix length, like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291. It returns the IP address and the network implied by the IP and prefix length. For example, ParseCIDR("192.0.2.1/24") returns the IP address 192.0.2.1 and the network 192.0.2.0/24.

func ParseCIDR(s string) (IP, *IPNet, error)

ParseIP function #

ParseIP parses s as an IP address, returning the result. The string s can be in IPv4 dotted decimal ("192.0.2.1"), IPv6 ("2001:db8::68"), or IPv4-mapped IPv6 ("::ffff:192.0.2.1") form. If s is not a valid textual representation of an IP address, ParseIP returns nil. The returned address is always 16 bytes, IPv4 addresses are returned in IPv4-mapped IPv6 form.

func ParseIP(s string) IP

ParseMAC function #

ParseMAC parses s as an IEEE 802 MAC-48, EUI-48, EUI-64, or a 20-octet IP over InfiniBand link-layer address using one of the following formats: 00:00:5e:00:53:01 02:00:5e:10:00:00:00:01 00:00:00:00:fe:80:00:00:00:00:00:00:02:00:5e:10:00:00:00:01 00-00-5e-00-53-01 02-00-5e-10-00-00-00-01 00-00-00-00-fe-80-00-00-00-00-00-00-02-00-5e-10-00-00-00-01 0000.5e00.5301 0200.5e10.0000.0001 0000.0000.fe80.0000.0000.0000.0200.5e10.0000.0001

func ParseMAC(s string) (hw HardwareAddr, err error)

Pipe function #

Pipe creates a synchronous, in-memory, full duplex network connection; both ends implement the [Conn] interface. Reads on one end are matched with writes on the other, copying data directly between the two; there is no internal buffering.

func Pipe() (Conn, Conn)

PollFD method #

PollFD returns the poll.FD of the underlying connection. Other packages in std that also import [internal/poll] (such as os) can use a type assertion to access this extension method so that they can pass the *poll.FD to functions like poll.Splice. PollFD is not intended for use outside the standard library.

func (c *rawConn) PollFD() *poll.FD

Read method #

func (fd *netFD) Read(p []byte) (n int, err error)

Read method #

func (c *rawConn) Read(f func(uintptr) bool) error

Read method #

func (p *pipe) Read(b []byte) (int, error)

Read method #

func (fd *netFD) Read(b []byte) (n int, err error)

Read method #

Read from the buffers. Read implements [io.Reader] for [Buffers]. Read modifies the slice v as well as v[i] for 0 <= i < len(v), but does not modify v[i][j] for any i, j.

func (v *Buffers) Read(p []byte) (n int, err error)

Read method #

func (ffd *fakeNetFD) Read(p []byte) (n int, err error)

Read method #

func (fd *netFD) Read(p []byte) (n int, err error)

Read method #

func (l *rawListener) Read(func(uintptr) bool) error

Read method #

Read implements the Conn Read method.

func (c *conn) Read(b []byte) (int, error)

ReadFrom method #

ReadFrom implements the [PacketConn] ReadFrom method.

func (c *UnixConn) ReadFrom(b []byte) (int, Addr, error)

ReadFrom method #

ReadFrom implements the [PacketConn] ReadFrom method.

func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error)

ReadFrom method #

ReadFrom implements the [PacketConn] ReadFrom method.

func (c *IPConn) ReadFrom(b []byte) (int, Addr, error)

ReadFrom method #

ReadFrom hides another ReadFrom method. It should never be called.

func (noReadFrom) ReadFrom(io.Reader) (int64, error)

ReadFrom method #

ReadFrom implements the [io.ReaderFrom] ReadFrom method.

func (c *TCPConn) ReadFrom(r io.Reader) (int64, error)

ReadFromIP method #

ReadFromIP acts like ReadFrom but returns an IPAddr.

func (c *IPConn) ReadFromIP(b []byte) (int, *IPAddr, error)

ReadFromUDP method #

ReadFromUDP acts like [UDPConn.ReadFrom] but returns a UDPAddr.

func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err error)

ReadFromUDPAddrPort method #

ReadFromUDPAddrPort acts like ReadFrom but returns a [netip.AddrPort]. If c is bound to an unspecified address, the returned netip.AddrPort's address might be an IPv4-mapped IPv6 address. Use [netip.Addr.Unmap] to get the address without the IPv6 prefix.

func (c *UDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error)

ReadFromUnix method #

ReadFromUnix acts like [UnixConn.ReadFrom] but returns a [UnixAddr].

func (c *UnixConn) ReadFromUnix(b []byte) (int, *UnixAddr, error)

ReadMsgIP method #

ReadMsgIP reads a message from c, copying the payload into b and the associated out-of-band data into oob. It returns the number of bytes copied into b, the number of bytes copied into oob, the flags that were set on the message and the source address of the message. The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be used to manipulate IP-level socket options in oob.

func (c *IPConn) ReadMsgIP(b []byte, oob []byte) (n int, oobn int, flags int, addr *IPAddr, err error)

ReadMsgUDP method #

ReadMsgUDP reads a message from c, copying the payload into b and the associated out-of-band data into oob. It returns the number of bytes copied into b, the number of bytes copied into oob, the flags that were set on the message and the source address of the message. The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be used to manipulate IP-level socket options in oob.

func (c *UDPConn) ReadMsgUDP(b []byte, oob []byte) (n int, oobn int, flags int, addr *UDPAddr, err error)

ReadMsgUDPAddrPort method #

ReadMsgUDPAddrPort is like [UDPConn.ReadMsgUDP] but returns an [netip.AddrPort] instead of a [UDPAddr].

func (c *UDPConn) ReadMsgUDPAddrPort(b []byte, oob []byte) (n int, oobn int, flags int, addr netip.AddrPort, err error)

ReadMsgUnix method #

ReadMsgUnix reads a message from c, copying the payload into b and the associated out-of-band data into oob. It returns the number of bytes copied into b, the number of bytes copied into oob, the flags that were set on the message and the source address of the message. Note that if len(b) == 0 and len(oob) > 0, this function will still read (and discard) 1 byte from the connection.

func (c *UnixConn) ReadMsgUnix(b []byte, oob []byte) (n int, oobn int, flags int, addr *UnixAddr, err error)

RemoteAddr method #

func (*pipe) RemoteAddr() Addr

RemoteAddr method #

RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.

func (c *conn) RemoteAddr() Addr

Reset method #

Reset attempts to reset the timer. If the timer has already expired, Reset returns false.

func (dt *deadlineTimer) Reset(deadline time.Time) bool

ResolveIPAddr function #

ResolveIPAddr returns an address of IP end point. The network must be an IP network name. If the host in the address parameter is not a literal IP address, ResolveIPAddr resolves the address to an address of IP end point. Otherwise, it parses the address as a literal IP address. The address parameter can use a host name, but this is not recommended, because it will return at most one of the host name's IP addresses. See func [Dial] for a description of the network and address parameters.

func ResolveIPAddr(network string, address string) (*IPAddr, error)

ResolveTCPAddr function #

ResolveTCPAddr returns an address of TCP end point. The network must be a TCP network name. If the host in the address parameter is not a literal IP address or the port is not a literal port number, ResolveTCPAddr resolves the address to an address of TCP end point. Otherwise, it parses the address as a pair of literal IP address and port number. The address parameter can use a host name, but this is not recommended, because it will return at most one of the host name's IP addresses. See func [Dial] for a description of the network and address parameters.

func ResolveTCPAddr(network string, address string) (*TCPAddr, error)

ResolveUDPAddr function #

ResolveUDPAddr returns an address of UDP end point. The network must be a UDP network name. If the host in the address parameter is not a literal IP address or the port is not a literal port number, ResolveUDPAddr resolves the address to an address of UDP end point. Otherwise, it parses the address as a pair of literal IP address and port number. The address parameter can use a host name, but this is not recommended, because it will return at most one of the host name's IP addresses. See func [Dial] for a description of the network and address parameters.

func ResolveUDPAddr(network string, address string) (*UDPAddr, error)

ResolveUnixAddr function #

ResolveUnixAddr returns an address of Unix domain socket end point. The network must be a Unix network name. See func [Dial] for a description of the network and address parameters.

func ResolveUnixAddr(network string, address string) (*UnixAddr, error)

SetDeadline method #

func (fd *netFD) SetDeadline(t time.Time) error

SetDeadline method #

func (p *pipe) SetDeadline(t time.Time) error

SetDeadline method #

func (ffd *fakeNetFD) SetDeadline(t time.Time) error

SetDeadline method #

SetDeadline implements the Conn SetDeadline method.

func (c *conn) SetDeadline(t time.Time) error

SetDeadline method #

SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline.

func (l *UnixListener) SetDeadline(t time.Time) error

SetDeadline method #

SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline.

func (l *TCPListener) SetDeadline(t time.Time) error

SetDeadline method #

func (fd *netFD) SetDeadline(t time.Time) error

SetDeadline method #

func (fd *netFD) SetDeadline(t time.Time) error

SetKeepAlive method #

SetKeepAlive sets whether the operating system should send keep-alive messages on the connection.

func (c *TCPConn) SetKeepAlive(keepalive bool) error

SetKeepAliveConfig method #

SetKeepAliveConfig configures keep-alive messages sent by the operating system.

func (c *TCPConn) SetKeepAliveConfig(config KeepAliveConfig) error

SetKeepAliveConfig method #

SetKeepAliveConfig configures keep-alive messages sent by the operating system.

func (c *TCPConn) SetKeepAliveConfig(config KeepAliveConfig) error

SetKeepAliveConfig method #

SetKeepAliveConfig configures keep-alive messages sent by the operating system.

func (c *TCPConn) SetKeepAliveConfig(config KeepAliveConfig) error

SetKeepAlivePeriod method #

SetKeepAlivePeriod sets the duration the connection needs to remain idle before TCP starts sending keepalive probes. Note that calling this method on Windows prior to Windows 10 version 1709 will reset the KeepAliveInterval to the default system value, which is normally 1 second.

func (c *TCPConn) SetKeepAlivePeriod(d time.Duration) error

SetLinger method #

SetLinger sets the behavior of Close on a connection which still has data waiting to be sent or to be acknowledged. If sec < 0 (the default), the operating system finishes sending the data in the background. If sec == 0, the operating system discards any unsent or unacknowledged data. If sec > 0, the data is sent in the background as with sec < 0. On some operating systems including Linux, this may cause Close to block until all data has been sent or discarded. On some operating systems after sec seconds have elapsed any remaining unsent data may be discarded.

func (c *TCPConn) SetLinger(sec int) error

SetMultipathTCP method #

SetMultipathTCP directs the [Listen] method to use, or not use, MPTCP, if supported by the operating system. This method overrides the system default and the GODEBUG=multipathtcp=... setting if any. If MPTCP is not available on the host or not supported by the client, the Listen method will fall back to TCP.

func (lc *ListenConfig) SetMultipathTCP(use bool)

SetMultipathTCP method #

SetMultipathTCP directs the [Dial] methods to use, or not use, MPTCP, if supported by the operating system. This method overrides the system default and the GODEBUG=multipathtcp=... setting if any. If MPTCP is not available on the host or not supported by the server, the Dial methods will fall back to TCP.

func (d *Dialer) SetMultipathTCP(use bool)

SetNoDelay method #

SetNoDelay controls whether the operating system should delay packet transmission in hopes of sending fewer packets (Nagle's algorithm). The default is true (no delay), meaning that data is sent as soon as possible after a Write.

func (c *TCPConn) SetNoDelay(noDelay bool) error

SetReadBuffer method #

SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.

func (c *conn) SetReadBuffer(bytes int) error

SetReadDeadline method #

func (fd *netFD) SetReadDeadline(t time.Time) error

SetReadDeadline method #

func (fd *netFD) SetReadDeadline(t time.Time) error

SetReadDeadline method #

func (p *pipe) SetReadDeadline(t time.Time) error

SetReadDeadline method #

SetReadDeadline implements the Conn SetReadDeadline method.

func (c *conn) SetReadDeadline(t time.Time) error

SetReadDeadline method #

func (fd *netFD) SetReadDeadline(t time.Time) error

SetReadDeadline method #

func (ffd *fakeNetFD) SetReadDeadline(t time.Time) error

SetUnlinkOnClose method #

SetUnlinkOnClose sets whether the underlying socket file should be removed from the file system when the listener is closed. The default behavior is to unlink the socket file only when package net created it. That is, when the listener and the underlying socket file were created by a call to Listen or ListenUnix, then by default closing the listener will remove the socket file. but if the listener was created by a call to FileListener to use an already existing socket file, then by default closing the listener will not remove the socket file.

func (l *UnixListener) SetUnlinkOnClose(unlink bool)

SetWriteBuffer method #

SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.

func (c *conn) SetWriteBuffer(bytes int) error

SetWriteDeadline method #

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (c *conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

func (fd *netFD) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

func (fd *netFD) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

func (ffd *fakeNetFD) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

func (p *pipe) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

func (fd *netFD) SetWriteDeadline(t time.Time) error

Size method #

Size returns the number of leading ones and total bits in the mask. If the mask is not in the canonical form--ones followed by zeros--then Size returns 0, 0.

func (m IPMask) Size() (ones int, bits int)

SplitHostPort function #

SplitHostPort splits a network address of the form "host:port", "host%zone:port", "[host]:port" or "[host%zone]:port" into host or host%zone and port. A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80". See func Dial for a description of the hostport parameter, and host and port results.

func SplitHostPort(hostport string) (host string, port string, err error)

String method #

func (pipeAddr) String() string

String method #

String returns the hexadecimal form of m, with no punctuation.

func (m IPMask) String() string

String method #

func (f fileAddr) String() string

String method #

func (a HardwareAddr) String() string

String method #

func (unknownAddr) String() string

String method #

String returns the string form of the IP address ip. It returns one of 4 forms: - "", if ip has length 0 - dotted decimal ("192.0.2.1"), if ip is an IPv4 or IP4-mapped IPv6 address - IPv6 conforming to RFC 5952 ("2001:db8::1"), if ip is a valid IPv6 address - the hexadecimal form of ip, without punctuation, if no other cases apply

func (ip IP) String() string

String method #

func (a *TCPAddr) String() string

String method #

func (o hostLookupOrder) String() string

String method #

func (a *IPAddr) String() string

String method #

func (a *UnixAddr) String() string

String method #

String returns the CIDR notation of n like "192.0.2.0/24" or "2001:db8::/48" as defined in RFC 4632 and RFC 4291. If the mask is not in the canonical form, it returns the string which consists of an IP address, followed by a slash character and a mask expressed as hexadecimal form with no punctuation like "198.51.100.0/c000ff00".

func (n *IPNet) String() string

String method #

func (f Flags) String() string

String method #

func (a *UDPAddr) String() string

SyscallConn method #

SyscallConn returns a raw network connection. This implements the [syscall.Conn] interface. The returned RawConn only supports calling Control. Read and Write return an error.

func (l *UnixListener) SyscallConn() (syscall.RawConn, error)

SyscallConn method #

SyscallConn returns a raw network connection. This implements the [syscall.Conn] interface.

func (c *TCPConn) SyscallConn() (syscall.RawConn, error)

SyscallConn method #

SyscallConn returns a raw network connection. This implements the [syscall.Conn] interface.

func (c *UDPConn) SyscallConn() (syscall.RawConn, error)

SyscallConn method #

SyscallConn returns a raw network connection. This implements the [syscall.Conn] interface. The returned RawConn only supports calling Control. Read and Write return an error.

func (l *TCPListener) SyscallConn() (syscall.RawConn, error)

SyscallConn method #

SyscallConn returns a raw network connection. This implements the [syscall.Conn] interface.

func (c *UnixConn) SyscallConn() (syscall.RawConn, error)

SyscallConn method #

SyscallConn returns a raw network connection. This implements the [syscall.Conn] interface.

func (c *IPConn) SyscallConn() (syscall.RawConn, error)

TCPAddrFromAddrPort function #

TCPAddrFromAddrPort returns addr as a [TCPAddr]. If addr.IsValid() is false, then the returned TCPAddr will contain a nil IP field, indicating an address family-agnostic unspecified address.

func TCPAddrFromAddrPort(addr netip.AddrPort) *TCPAddr

Temporary method #

func (e *temporaryError) Temporary() bool

Temporary method #

Temporary reports whether the DNS error is known to be temporary. This is not always known; a DNS lookup may fail due to a temporary error and return a [DNSError] for which Temporary returns false.

func (e *DNSError) Temporary() bool

Temporary method #

func (e *OpError) Temporary() bool

Temporary method #

func (e *ParseError) Temporary() bool

Temporary method #

func (e *AddrError) Temporary() bool

Temporary method #

func (e UnknownNetworkError) Temporary() bool

Temporary method #

func (e InvalidAddrError) Temporary() bool

Temporary method #

func (e *DNSConfigError) Temporary() bool

Temporary method #

func (e *timeoutError) Temporary() bool

Temporary method #

func (eai addrinfoErrno) Temporary() bool

Timeout method #

func (e *AddrError) Timeout() bool

Timeout method #

func (eai addrinfoErrno) Timeout() bool

Timeout method #

func (e *DNSConfigError) Timeout() bool

Timeout method #

func (e *timeoutError) Timeout() bool

Timeout method #

func (e *OpError) Timeout() bool

Timeout method #

Timeout reports whether the DNS lookup is known to have timed out. This is not always known; a DNS lookup may fail due to a timeout and return a [DNSError] for which Timeout returns false.

func (e *DNSError) Timeout() bool

Timeout method #

func (e *ParseError) Timeout() bool

Timeout method #

func (e InvalidAddrError) Timeout() bool

Timeout method #

func (e UnknownNetworkError) Timeout() bool

Timeout method #

func (e *temporaryError) Timeout() bool

To16 method #

To16 converts the IP address ip to a 16-byte representation. If ip is not an IP address (it is the wrong length), To16 returns nil.

func (ip IP) To16() IP

To4 method #

To4 converts the IPv4 address ip to a 4-byte representation. If ip is not an IPv4 address, To4 returns nil.

func (ip IP) To4() IP

UDPAddrFromAddrPort function #

UDPAddrFromAddrPort returns addr as a [UDPAddr]. If addr.IsValid() is false, then the returned UDPAddr will contain a nil IP field, indicating an address family-agnostic unspecified address.

func UDPAddrFromAddrPort(addr netip.AddrPort) *UDPAddr

UnmarshalText method #

UnmarshalText implements the [encoding.TextUnmarshaler] interface. The IP address is expected in a form accepted by [ParseIP].

func (ip *IP) UnmarshalText(text []byte) error

Unwrap method #

func (e *DNSConfigError) Unwrap() error

Unwrap method #

Unwrap returns e.UnwrapErr.

func (e *DNSError) Unwrap() error

Unwrap method #

func (e *OpError) Unwrap() error

Value method #

Value performs a lookup if the original context hasn't expired.

func (ovc *onlyValuesCtx) Value(key any) any

Write method #

func (c *rawConn) Write(f func(uintptr) bool) error

Write method #

func (ffd *fakeNetFD) Write(p []byte) (nn int, err error)

Write method #

func (fd *netFD) Write(p []byte) (nn int, err error)

Write method #

func (fd *netFD) Write(p []byte) (nn int, err error)

Write method #

func (p *pipe) Write(b []byte) (int, error)

Write method #

Write implements the Conn Write method.

func (c *conn) Write(b []byte) (int, error)

Write method #

func (l *rawListener) Write(func(uintptr) bool) error

Write method #

func (fd *netFD) Write(b []byte) (n int, err error)

WriteMsgIP method #

WriteMsgIP writes a message to addr via c, copying the payload from b and the associated out-of-band data from oob. It returns the number of payload and out-of-band bytes written. The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be used to manipulate IP-level socket options in oob.

func (c *IPConn) WriteMsgIP(b []byte, oob []byte, addr *IPAddr) (n int, oobn int, err error)

WriteMsgUDP method #

WriteMsgUDP writes a message to addr via c if c isn't connected, or to c's remote address if c is connected (in which case addr must be nil). The payload is copied from b and the associated out-of-band data is copied from oob. It returns the number of payload and out-of-band bytes written. The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be used to manipulate IP-level socket options in oob.

func (c *UDPConn) WriteMsgUDP(b []byte, oob []byte, addr *UDPAddr) (n int, oobn int, err error)

WriteMsgUDPAddrPort method #

WriteMsgUDPAddrPort is like [UDPConn.WriteMsgUDP] but takes a [netip.AddrPort] instead of a [UDPAddr].

func (c *UDPConn) WriteMsgUDPAddrPort(b []byte, oob []byte, addr netip.AddrPort) (n int, oobn int, err error)

WriteMsgUnix method #

WriteMsgUnix writes a message to addr via c, copying the payload from b and the associated out-of-band data from oob. It returns the number of payload and out-of-band bytes written. Note that if len(b) == 0 and len(oob) > 0, this function will still write 1 byte to the connection.

func (c *UnixConn) WriteMsgUnix(b []byte, oob []byte, addr *UnixAddr) (n int, oobn int, err error)

WriteTo method #

WriteTo implements the [PacketConn] WriteTo method.

func (c *IPConn) WriteTo(b []byte, addr Addr) (int, error)

WriteTo method #

WriteTo hides another WriteTo method. It should never be called.

func (noWriteTo) WriteTo(io.Writer) (int64, error)

WriteTo method #

WriteTo implements the [PacketConn] WriteTo method.

func (c *UnixConn) WriteTo(b []byte, addr Addr) (int, error)

WriteTo method #

WriteTo implements the io.WriterTo WriteTo method.

func (c *TCPConn) WriteTo(w io.Writer) (int64, error)

WriteTo method #

WriteTo writes contents of the buffers to w. WriteTo implements [io.WriterTo] for [Buffers]. WriteTo modifies the slice v as well as v[i] for 0 <= i < len(v), but does not modify v[i][j] for any i, j.

func (v *Buffers) WriteTo(w io.Writer) (n int64, err error)

WriteTo method #

WriteTo implements the [PacketConn] WriteTo method.

func (c *UDPConn) WriteTo(b []byte, addr Addr) (int, error)

WriteToIP method #

WriteToIP acts like [IPConn.WriteTo] but takes an [IPAddr].

func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (int, error)

WriteToUDP method #

WriteToUDP acts like [UDPConn.WriteTo] but takes a [UDPAddr].

func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error)

WriteToUDPAddrPort method #

WriteToUDPAddrPort acts like [UDPConn.WriteTo] but takes a [netip.AddrPort].

func (c *UDPConn) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error)

WriteToUnix method #

WriteToUnix acts like [UnixConn.WriteTo] but takes a [UnixAddr].

func (c *UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (int, error)

_C_ai_addr function #

func _C_ai_addr(ai *_C_struct_addrinfo) **_C_struct_sockaddr

_C_ai_addr function #

func _C_ai_addr(ai *_C_struct_addrinfo) **_C_struct_sockaddr

_C_ai_family function #

func _C_ai_family(ai *_C_struct_addrinfo) *_C_int

_C_ai_family function #

func _C_ai_family(ai *_C_struct_addrinfo) *_C_int

_C_ai_flags function #

func _C_ai_flags(ai *_C_struct_addrinfo) *_C_int

_C_ai_flags function #

func _C_ai_flags(ai *_C_struct_addrinfo) *_C_int

_C_ai_next function #

func _C_ai_next(ai *_C_struct_addrinfo) **_C_struct_addrinfo

_C_ai_next function #

func _C_ai_next(ai *_C_struct_addrinfo) **_C_struct_addrinfo

_C_ai_protocol function #

func _C_ai_protocol(ai *_C_struct_addrinfo) *_C_int

_C_ai_protocol function #

func _C_ai_protocol(ai *_C_struct_addrinfo) *_C_int

_C_ai_socktype function #

func _C_ai_socktype(ai *_C_struct_addrinfo) *_C_int

_C_ai_socktype function #

func _C_ai_socktype(ai *_C_struct_addrinfo) *_C_int

_C_free function #

func _C_free(p unsafe.Pointer)

_C_free function #

func _C_free(p unsafe.Pointer)

_C_freeaddrinfo function #

func _C_freeaddrinfo(ai *_C_struct_addrinfo)

_C_freeaddrinfo function #

func _C_freeaddrinfo(ai *_C_struct_addrinfo)

_C_gai_strerror function #

func _C_gai_strerror(eai _C_int) string

_C_gai_strerror function #

func _C_gai_strerror(eai _C_int) string

_C_getaddrinfo function #

func _C_getaddrinfo(hostname *byte, servname *byte, hints *_C_struct_addrinfo, res **_C_struct_addrinfo) (int, error)

_C_getaddrinfo function #

func _C_getaddrinfo(hostname *_C_char, servname *_C_char, hints *_C_struct_addrinfo, res **_C_struct_addrinfo) (int, error)

_C_malloc function #

func _C_malloc(n uintptr) unsafe.Pointer

_C_malloc function #

func _C_malloc(n uintptr) unsafe.Pointer

_C_res_nclose function #

func _C_res_nclose(state *_C_struct___res_state)

_C_res_nclose function #

func _C_res_nclose(state *_C_struct___res_state)

_C_res_nclose function #

func _C_res_nclose(state *_C_struct___res_state)

_C_res_ninit function #

func _C_res_ninit(state *_C_struct___res_state) error

_C_res_ninit function #

func _C_res_ninit(state *_C_struct___res_state) error

_C_res_ninit function #

func _C_res_ninit(state *_C_struct___res_state) error

_C_res_nsearch function #

func _C_res_nsearch(state *_C_struct___res_state, dname *_C_char, class int, typ int, ans *_C_char, anslen int) int

_C_res_nsearch function #

func _C_res_nsearch(state *_C_struct___res_state, dname *_C_char, class int, typ int, ans *_C_uchar, anslen int) int

_C_res_nsearch function #

func _C_res_nsearch(state *_C_struct___res_state, dname *_C_char, class int, typ int, ans *_C_uchar, anslen int) int

absDomainName function #

absDomainName returns an absolute domain name which ends with a trailing dot to match pure Go reverse resolver and all other lookup routines. See golang.org/issue/12189. But we don't want to add dots for local names from /etc/hosts. It's hard to tell so we settle on the heuristic that names without dots (like "localhost" or "myhost") do not get trailing dots, but any other names do.

func absDomainName(s string) string

accept method #

func (fd *netFD) accept() (netfd *netFD, err error)

accept method #

func (ln *UnixListener) accept() (*UnixConn, error)

accept method #

func (ln *TCPListener) accept() (*TCPConn, error)

accept method #

func (ffd *fakeNetFD) accept(laddr Addr) (*netFD, error)

accept method #

func (fd *netFD) accept() (netfd *netFD, err error)

accept method #

func (ln *UnixListener) accept() (*UnixConn, error)

accept method #

func (ln *TCPListener) accept() (*TCPConn, error)

accept method #

func (fd *netFD) accept() (*netFD, error)

acceptPlan9 method #

func (fd *netFD) acceptPlan9() (nfd *netFD, err error)

acquireSema method #

func (conf *nsswitchConfig) acquireSema()

acquireThread function #

func acquireThread(ctx context.Context) error

adapterAddresses function #

adapterAddresses returns a list of IP adapter and address structures. The structure contains an IP adapter and flattened multiple IP addresses including unicast, anycast and multicast addresses.

func adapterAddresses() ([]*windows.IpAdapterAddresses, error)

addrFunc method #

func (fd *netFD) addrFunc() (func(syscall.Sockaddr) Addr)

addrLookupOrder method #

addrLookupOrder determines which strategy to use to resolve addresses. The provided Resolver is optional. nil means to not consider its options. It also returns dnsConfig when it was used to determine the lookup order.

func (c *conf) addrLookupOrder(r *Resolver, addr string) (ret hostLookupOrder, dnsConf *dnsConfig)

addrPortToSockaddrInet4 function #

func addrPortToSockaddrInet4(ap netip.AddrPort) (syscall.SockaddrInet4, error)

addrPortToSockaddrInet6 function #

func addrPortToSockaddrInet6(ap netip.AddrPort) (syscall.SockaddrInet6, error)

addrTable function #

func addrTable(ifi *Interface, msgs []syscall.NetlinkMessage) ([]Addr, error)

allFF function #

func allFF(b []byte) bool

appendTo method #

appendTo appends the string representation of ip to b and returns the expanded b If len(ip) != IPv4len or IPv6len, it appends nothing.

func (ip IP) appendTo(b []byte) []byte

assignFakeAddr method #

func (ffd *fakeNetFD) assignFakeAddr(addr sockaddr) error

avoidDNS function #

avoidDNS reports whether this is a hostname for which we should not use DNS. Currently this includes only .onion, per RFC 7686. See golang.org/issue/13705. Does not cover .local names (RFC 6762), see golang.org/issue/16739.

func avoidDNS(name string) bool

boolint function #

Boolean to int.

func boolint(b bool) int

canUseConnectEx function #

canUseConnectEx reports whether we can use the ConnectEx Windows API call for the given network type.

func canUseConnectEx(net string) bool

cgoLookupAddrPTR function #

func cgoLookupAddrPTR(addr string, sa *_C_struct_sockaddr, salen _C_socklen_t) (names []string, err error)

cgoLookupCNAME function #

func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool)

cgoLookupCNAME function #

func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool)

cgoLookupHost function #

func cgoLookupHost(ctx context.Context, name string) (addrs []string, err error)

cgoLookupHost function #

func cgoLookupHost(ctx context.Context, name string) (hosts []string, err error)

cgoLookupHostIP function #

func cgoLookupHostIP(network string, name string) (addrs []IPAddr, err error)

cgoLookupIP function #

func cgoLookupIP(ctx context.Context, network string, name string) (addrs []IPAddr, err error)

cgoLookupIP function #

func cgoLookupIP(ctx context.Context, network string, name string) (addrs []IPAddr, err error)

cgoLookupPTR function #

func cgoLookupPTR(ctx context.Context, addr string) (names []string, err error)

cgoLookupPTR function #

func cgoLookupPTR(ctx context.Context, addr string) (ptrs []string, err error)

cgoLookupPort function #

func cgoLookupPort(ctx context.Context, network string, service string) (port int, err error)

cgoLookupPort function #

func cgoLookupPort(ctx context.Context, network string, service string) (port int, err error)

cgoLookupServicePort function #

func cgoLookupServicePort(hints *_C_struct_addrinfo, network string, service string) (port int, err error)

cgoNameinfoPTR function #

func cgoNameinfoPTR(b []byte, sa *C.struct_sockaddr, salen C.socklen_t) (int, error)

cgoNameinfoPTR function #

func cgoNameinfoPTR(b []byte, sa *syscall.RawSockaddr, salen int) (int, error)

cgoNameinfoPTR function #

func cgoNameinfoPTR(b []byte, sa *C.struct_sockaddr, salen C.socklen_t) (int, error)

cgoNameinfoPTR function #

func cgoNameinfoPTR(b []byte, sa *C.struct_sockaddr, salen C.socklen_t) (int, error)

cgoResSearch function #

func cgoResSearch(hostname string, rtype int, class int) ([]dnsmessage.Resource, error)

cgoSockaddr function #

func cgoSockaddr(ip IP, zone string) (*_C_struct_sockaddr, _C_socklen_t)

cgoSockaddrInet4 function #

func cgoSockaddrInet4(ip IP) *C.struct_sockaddr

cgoSockaddrInet4 function #

func cgoSockaddrInet4(ip IP) *syscall.RawSockaddr

cgoSockaddrInet4 function #

func cgoSockaddrInet4(ip IP) *C.struct_sockaddr

cgoSockaddrInet6 function #

func cgoSockaddrInet6(ip IP, zone int) *C.struct_sockaddr

cgoSockaddrInet6 function #

func cgoSockaddrInet6(ip IP, zone int) *C.struct_sockaddr

cgoSockaddrInet6 function #

func cgoSockaddrInet6(ip IP, zone int) *syscall.RawSockaddr

checkHeader function #

checkHeader performs basic sanity checks on the header.

func checkHeader(p *dnsmessage.Parser, h dnsmessage.Header) error

checkResponse function #

func checkResponse(reqID uint16, reqQues dnsmessage.Question, respHdr dnsmessage.Header, respQues dnsmessage.Question) bool

classifyScope function #

func classifyScope(ip netip.Addr) scope

clear method #

func (p *packet) clear()

close method #

func (f *file) close()

close method #

func (ln *TCPListener) close() error

close method #

func (ln *UnixListener) close() error

close method #

func (ln *TCPListener) close() error

close method #

func (ln *UnixListener) close() error

closeRead method #

func (fd *netFD) closeRead() error

closeRead method #

func (fd *netFD) closeRead() error

closeRead method #

func (ffd *fakeNetFD) closeRead() error

closeRead method #

func (pq *packetQueue) closeRead() error

closeRead method #

func (fd *netFD) closeRead() error

closeRead method #

func (fd *netFD) closeRead() error

closeWrite method #

func (fd *netFD) closeWrite() error

closeWrite method #

func (fd *netFD) closeWrite() error

closeWrite method #

func (fd *netFD) closeWrite() error

closeWrite method #

func (pq *packetQueue) closeWrite() error

closeWrite method #

func (fd *netFD) closeWrite() error

closeWrite method #

func (ffd *fakeNetFD) closeWrite() error

commonPrefixLen function #

commonPrefixLen reports the length of the longest prefix (looking at the most significant, or leftmost, bits) that the two addresses have in common, up to the length of a's prefix (i.e., the portion of the address not including the interface ID). If a or b is an IPv4 address as an IPv6 address, the IPv4 addresses are compared (with max common prefix length of 32). If a and b are different IP versions, 0 is returned. See https://tools.ietf.org/html/rfc6724#section-2.2

func commonPrefixLen(a netip.Addr, b IP) (cpl int)

compareByRFC6724 function #

compareByRFC6724 compares two byRFC6724Info records and returns an integer indicating the order. It follows the algorithm and variable names from RFC 6724 section 6. Returns -1 if a is preferred, 1 if b is preferred, and 0 if they are equal.

func compareByRFC6724(a byRFC6724Info, b byRFC6724Info) int

concurrentThreadsLimit function #

concurrentThreadsLimit returns the number of threads we permit to run concurrently doing DNS lookups via cgo. A DNS lookup may use a file descriptor so we limit this to less than the number of permitted open files. On some systems, notably Darwin, if getaddrinfo is unable to open a file descriptor it simply returns EAI_NONAME rather than a useful error. Limiting the number of concurrent getaddrinfo calls to less than the permitted number of file descriptors makes that error less likely. We don't bother to apply the same limit to DNS lookups run directly from Go, because there we will return a meaningful "too many open files" error.

func concurrentThreadsLimit() int

concurrentThreadsLimit function #

concurrentThreadsLimit returns the number of threads we permit to run concurrently doing DNS lookups.

func concurrentThreadsLimit() int

concurrentThreadsLimit function #

concurrentThreadsLimit returns the number of threads we permit to run concurrently doing DNS lookups.

func concurrentThreadsLimit() int

concurrentThreadsLimit function #

concurrentThreadsLimit returns the number of threads we permit to run concurrently doing DNS lookups.

func concurrentThreadsLimit() int

connect method #

Always returns nil for connected peer address result.

func (fd *netFD) connect(ctx context.Context, la syscall.Sockaddr, ra syscall.Sockaddr) (syscall.Sockaddr, error)

connect method #

func (fd *netFD) connect(ctx context.Context, la syscall.Sockaddr, ra syscall.Sockaddr) (rsa syscall.Sockaddr, ret error)

consume method #

func (v *Buffers) consume(n int64)

copyIP function #

func copyIP(x IP) IP

countAnyByte function #

Count occurrences in s of any bytes in t.

func countAnyByte(s string, t string) int

ctrlNetwork method #

func (fd *netFD) ctrlNetwork() string

deadline method #

deadline returns the earliest of: - now+Timeout - d.Deadline - the context's deadline Or zero, if none of Timeout, Deadline, or context's deadline is set.

func (d *Dialer) deadline(ctx context.Context, now time.Time) (earliest time.Time)

destroy method #

func (fd *netFD) destroy()

dial method #

dial makes a new connection to the provided server (which must be an IP address) with the provided network type, using either r.Dial (if both r and r.Dial are non-nil) or else Dialer.DialContext.

func (r *Resolver) dial(ctx context.Context, network string, server string) (Conn, error)

dial method #

func (fd *netFD) dial(ctx context.Context, laddr sockaddr, raddr sockaddr, ctrlCtxFn func(context.Context, string, string, syscall.RawConn) error) error

dialIP method #

func (sd *sysDialer) dialIP(ctx context.Context, laddr *IPAddr, raddr *IPAddr) (*IPConn, error)

dialIP method #

func (sd *sysDialer) dialIP(ctx context.Context, laddr *IPAddr, raddr *IPAddr) (*IPConn, error)

dialMPTCP method #

func (sd *sysDialer) dialMPTCP(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

dialMPTCP method #

func (sd *sysDialer) dialMPTCP(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

dialParallel method #

dialParallel races two copies of dialSerial, giving the first a head start. It returns the first established connection and closes the others. Otherwise it returns an error from the first primary address.

func (sd *sysDialer) dialParallel(ctx context.Context, primaries addrList, fallbacks addrList) (Conn, error)

dialPlan9 function #

func dialPlan9(ctx context.Context, net string, laddr Addr, raddr Addr) (fd *netFD, err error)

dialPlan9Blocking function #

func dialPlan9Blocking(ctx context.Context, net string, laddr Addr, raddr Addr) (fd *netFD, err error)

dialSerial method #

dialSerial connects to a list of addresses in sequence, returning either the first successful connection, or the first error.

func (sd *sysDialer) dialSerial(ctx context.Context, ras addrList) (Conn, error)

dialSingle method #

dialSingle attempts to establish and returns a single connection to the destination address.

func (sd *sysDialer) dialSingle(ctx context.Context, ra Addr) (c Conn, err error)

dialTCP method #

func (sd *sysDialer) dialTCP(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

dialTCP method #

func (sd *sysDialer) dialTCP(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

dialUDP method #

func (sd *sysDialer) dialUDP(ctx context.Context, laddr *UDPAddr, raddr *UDPAddr) (*UDPConn, error)

dialUDP method #

func (sd *sysDialer) dialUDP(ctx context.Context, laddr *UDPAddr, raddr *UDPAddr) (*UDPConn, error)

dialUnix method #

func (sd *sysDialer) dialUnix(ctx context.Context, laddr *UnixAddr, raddr *UnixAddr) (*UnixConn, error)

dialUnix method #

func (sd *sysDialer) dialUnix(ctx context.Context, laddr *UnixAddr, raddr *UnixAddr) (*UnixConn, error)

dnsDefaultSearch function #

func dnsDefaultSearch() []string

dnsPacketRoundTrip function #

func dnsPacketRoundTrip(c Conn, id uint16, query dnsmessage.Question, b []byte) (dnsmessage.Parser, dnsmessage.Header, error)

dnsReadConfig function #

See resolv.conf(5) on a Linux machine.

func dnsReadConfig(filename string) *dnsConfig

dnsReadConfig function #

func dnsReadConfig(ignoredFilename string) (conf *dnsConfig)

dnsStreamRoundTrip function #

func dnsStreamRoundTrip(c Conn, id uint16, query dnsmessage.Question, b []byte) (dnsmessage.Parser, dnsmessage.Header, error)

doBlockingWithCtx function #

doBlockingWithCtx executes a blocking function in a separate goroutine when the provided context is cancellable. It is intended for use with calls that don't support context cancellation (cgo, syscalls). blocking func may still be running after this function finishes. For the duration of the execution of the blocking function, the thread is 'acquired' using [acquireThread], blocking might not be executed when the context gets canceled early.

func doBlockingWithCtx(ctx context.Context, lookupName string, blocking func() (T, error)) (T, error)

doDialTCP method #

func (sd *sysDialer) doDialTCP(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

doDialTCP method #

func (sd *sysDialer) doDialTCP(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr) (*TCPConn, error)

doDialTCPProto method #

func (sd *sysDialer) doDialTCPProto(ctx context.Context, laddr *TCPAddr, raddr *TCPAddr, proto int) (*TCPConn, error)

dtoi function #

Decimal to integer. Returns number, characters consumed, success.

func dtoi(s string) (n int, i int, ok bool)

dualStack method #

func (d *Dialer) dualStack() bool

dup method #

This method is only called via Conn.

func (fd *netFD) dup() (*os.File, error)

dup method #

func (fd *netFD) dup() (*os.File, error)

dup method #

func (fd *netFD) dup() (f *os.File, err error)

dup method #

func (ffd *fakeNetFD) dup() (f *os.File, err error)

dup method #

func (l *TCPListener) dup() (*os.File, error)

dupSocket function #

func dupSocket(f *os.File) (int, error)

ensureRooted function #

func ensureRooted(s string) string

equalASCIIName function #

func equalASCIIName(x dnsmessage.Name, y dnsmessage.Name) bool

exchange method #

exchange sends a query on the connection and hopes for a response.

func (r *Resolver) exchange(ctx context.Context, server string, q dnsmessage.Question, timeout time.Duration, useTCP bool, ad bool) (dnsmessage.Parser, dnsmessage.Header, error)

extractExtendedRCode function #

extractExtendedRCode extracts the extended RCode from the OPT resource (EDNS(0)) If an OPT record is not found, the RCode from the hdr is returned. Another return value indicates whether an additional resource was found.

func extractExtendedRCode(p dnsmessage.Parser, hdr dnsmessage.Header) (dnsmessage.RCode, bool)

fakeAddr function #

func fakeAddr(sa sockaddr) fakeSockAddr

fakeConnect function #

func fakeConnect(ctx context.Context, fd *netFD, laddr sockaddr, raddr sockaddr) error

fakeListen function #

func fakeListen(fd *netFD, laddr sockaddr) (err error)

fallbackDelay method #

func (d *Dialer) fallbackDelay() time.Duration

family method #

func (a *UnixAddr) family() int

family method #

func (a *IPAddr) family() int

family method #

func (a *UDPAddr) family() int

family method #

func (a *TCPAddr) family() int

favoriteAddrFamily function #

favoriteAddrFamily returns the appropriate address family for the given network, laddr, raddr and mode. If mode indicates "listen" and laddr is a wildcard, we assume that the user wants to make a passive-open connection with a wildcard address family, both AF_INET and AF_INET6, and a wildcard address like the following: - A listen for a wildcard communication domain, "tcp" or "udp", with a wildcard address: If the platform supports both IPv6 and IPv4-mapped IPv6 communication capabilities, or does not support IPv4, we use a dual stack, AF_INET6 and IPV6_V6ONLY=0, wildcard address listen. The dual stack wildcard address listen may fall back to an IPv6-only, AF_INET6 and IPV6_V6ONLY=1, wildcard address listen. Otherwise we prefer an IPv4-only, AF_INET, wildcard address listen. - A listen for a wildcard communication domain, "tcp" or "udp", with an IPv4 wildcard address: same as above. - A listen for a wildcard communication domain, "tcp" or "udp", with an IPv6 wildcard address: same as above. - A listen for an IPv4 communication domain, "tcp4" or "udp4", with an IPv4 wildcard address: We use an IPv4-only, AF_INET, wildcard address listen. - A listen for an IPv6 communication domain, "tcp6" or "udp6", with an IPv6 wildcard address: We use an IPv6-only, AF_INET6 and IPV6_V6ONLY=1, wildcard address listen. Otherwise guess: If the addresses are IPv4 then returns AF_INET, or else returns AF_INET6. It also returns a boolean value what designates IPV6_V6ONLY option. Note that the latest DragonFly BSD and OpenBSD kernels allow neither "net.inet6.ip6.v6only=1" change nor IPPROTO_IPV6 level IPV6_V6ONLY socket option setting. favoriteAddrFamily should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/database64128/tfo-go/v2 - github.com/metacubex/tfo-go - github.com/sagernet/tfo-go Do not remove or change the type signature. See go.dev/issue/67401. go:linkname favoriteAddrFamily

func favoriteAddrFamily(network string, laddr sockaddr, raddr sockaddr, mode string) (family int, ipv6only bool)

fd_fdstat_get_type function #

This helper is implemented in the syscall package. It means we don't have to redefine the fd_fdstat_get host import or the fdstat struct it populates. go:linkname fd_fdstat_get_type syscall.fd_fdstat_get_type

func fd_fdstat_get_type(fd int) (uint8, error)

file method #

func (ln *UnixListener) file() (*os.File, error)

file method #

func (ln *TCPListener) file() (*os.File, error)

file method #

func (ln *TCPListener) file() (*os.File, error)

file method #

func (fd *netFD) file(f *os.File, s string) (*os.File, error)

file method #

func (ln *UnixListener) file() (*os.File, error)

fileConn function #

func fileConn(f *os.File) (Conn, error)

fileConn function #

func fileConn(f *os.File) (Conn, error)

fileConn function #

func fileConn(f *os.File) (Conn, error)

fileConn function #

func fileConn(f *os.File) (Conn, error)

fileConn function #

func fileConn(f *os.File) (Conn, error)

fileConnNet function #

func fileConnNet(filetype syscall.Filetype) (string, error)

fileListenNet function #

func fileListenNet(filetype syscall.Filetype) (string, error)

fileListener function #

func fileListener(f *os.File) (Listener, error)

fileListener function #

func fileListener(f *os.File) (Listener, error)

fileListener function #

func fileListener(f *os.File) (Listener, error)

fileListener function #

func fileListener(f *os.File) (Listener, error)

fileListener function #

func fileListener(f *os.File) (Listener, error)

filePacketConn function #

func filePacketConn(f *os.File) (PacketConn, error)

filePacketConn function #

func filePacketConn(f *os.File) (PacketConn, error)

filePacketConn function #

func filePacketConn(f *os.File) (PacketConn, error)

filePacketConn function #

func filePacketConn(f *os.File) (PacketConn, error)

filePacketConn function #

func filePacketConn(f *os.File) (PacketConn, error)

filterAddrList function #

filterAddrList applies a filter to a list of IP addresses, yielding a list of Addr objects. Known filters are nil, ipv4only, and ipv6only. It returns every address when the filter is nil. The result contains at least one address when error is nil.

func filterAddrList(filter func(IPAddr) bool, ips []IPAddr, inetaddr func(IPAddr) Addr, originalAddr string) (addrList, error)

first method #

first returns the first address which satisfies strategy, or if none do, then the first address of any kind.

func (addrs addrList) first(strategy func(Addr) bool) Addr

fixErr function #

func fixErr(err error)

forResolve method #

forResolve returns the most appropriate address in address for a call to ResolveTCPAddr, ResolveUDPAddr, or ResolveIPAddr. IPv4 is preferred, unless addr contains an IPv6 literal.

func (addrs addrList) forResolve(network string, addr string) Addr

foreachField function #

foreachField runs fn on each non-empty run of non-space bytes in x. It returns the first non-nil error returned by fn.

func foreachField(x string, fn func(field string) error) error

genericReadFrom function #

Fallback implementation of io.ReaderFrom's ReadFrom, when sendfile isn't applicable.

func genericReadFrom(c *TCPConn, r io.Reader) (n int64, err error)

genericWriteTo function #

Fallback implementation of io.WriterTo's WriteTo, when zero-copy isn't applicable.

func genericWriteTo(c *TCPConn, w io.Writer) (n int64, err error)

get method #

func (m *mptcpStatusListen) get() bool

get method #

func (pq *packetQueue) get() packetQueueState

get method #

func (m *mptcpStatusDial) get() bool

getFields function #

func getFields(s string) []string

getIfList function #

func getIfList() ([]byte, error)

getLineFromData method #

func (f *file) getLineFromData() (s string, ok bool)

getLookupGroup method #

func (r *Resolver) getLookupGroup() *singleflight.Group

getSystemDNSConfig function #

func getSystemDNSConfig() *dnsConfig

getSystemNSS function #

func getSystemNSS() *nssConf

getprotobyname function #

func getprotobyname(name string) (proto int, err error)

goDebugNetDNS function #

goDebugNetDNS parses the value of the GODEBUG "netdns" value. The netdns value can be of the form: 1 // debug level 1 2 // debug level 2 cgo // use cgo for DNS lookups go // use go for DNS lookups cgo+1 // use cgo for DNS lookups + debug level 1 1+cgo // same cgo+2 // same, but debug level 2 etc.

func goDebugNetDNS() (dnsMode string, debugLevel int)

goLookupCNAME method #

goLookupCNAME is the native Go (non-cgo) implementation of LookupCNAME.

func (r *Resolver) goLookupCNAME(ctx context.Context, host string, order hostLookupOrder, conf *dnsConfig) (string, error)

goLookupHostOrder method #

func (r *Resolver) goLookupHostOrder(ctx context.Context, name string, order hostLookupOrder, conf *dnsConfig) (addrs []string, err error)

goLookupIP method #

goLookupIP is the native Go implementation of LookupIP. The libc versions are in cgo_*.go.

func (r *Resolver) goLookupIP(ctx context.Context, network string, host string, order hostLookupOrder, conf *dnsConfig) (addrs []IPAddr, err error)

goLookupIPCNAMEOrder method #

func (r *Resolver) goLookupIPCNAMEOrder(ctx context.Context, network string, name string, order hostLookupOrder, conf *dnsConfig) (addrs []IPAddr, cname dnsmessage.Name, err error)

goLookupIPFiles function #

lookup entries from /etc/hosts

func goLookupIPFiles(name string) (addrs []IPAddr, canonical string)

goLookupMX method #

goLookupMX returns the MX records for name.

func (r *Resolver) goLookupMX(ctx context.Context, name string) ([]*MX, error)

goLookupNS method #

goLookupNS returns the NS records for name.

func (r *Resolver) goLookupNS(ctx context.Context, name string) ([]*NS, error)

goLookupPTR method #

goLookupPTR is the native Go implementation of LookupAddr.

func (r *Resolver) goLookupPTR(ctx context.Context, addr string, order hostLookupOrder, conf *dnsConfig) ([]string, error)

goLookupPort function #

goLookupPort is the native Go implementation of LookupPort.

func goLookupPort(network string, service string) (port int, err error)

goLookupSRV method #

goLookupSRV returns the SRV records for a target name, built either from its component service ("sip"), protocol ("tcp"), and name ("example.com."), or from name directly (if service and proto are both empty). In either case, the returned target name ("_sip._tcp.example.com.") is also returned on success. The records are sorted by weight.

func (r *Resolver) goLookupSRV(ctx context.Context, service string, proto string, name string) (target string, srvs []*SRV, err error)

goLookupTXT method #

goLookupTXT returns the TXT records from name.

func (r *Resolver) goLookupTXT(ctx context.Context, name string) ([]string, error)

goosPrefersCgo function #

goosPrefersCgo reports whether the GOOS value passed in prefers the cgo resolver.

func goosPrefersCgo() bool

handlePlan9DNSError function #

func handlePlan9DNSError(err error, name string) error

hangupCtlWrite function #

func hangupCtlWrite(ctx context.Context, proto string, ctl *os.File, msg string) error

hasFallenBack function #

hasFallenBack reports whether the MPTCP connection has fallen back to "plain" TCP. A connection can fallback to TCP for different reasons, e.g. the other peer doesn't support it, a middle box "accidentally" drops the option, etc. If the MPTCP protocol has not been requested when creating the socket, this method will return true: MPTCP is not being used. Kernel >= 5.16 returns EOPNOTSUPP/ENOPROTOOPT in case of fallback. Older kernels will always return them even if MPTCP is used: not usable.

func hasFallenBack(fd *netFD) bool

hasUpperCase function #

hasUpperCase tells whether the given string contains at least one upper-case.

func hasUpperCase(s string) bool

hexString function #

func hexString(b []byte) string

hostLookupOrder method #

hostLookupOrder determines which strategy to use to resolve hostname. The provided Resolver is optional. nil means to not consider its options. It also returns dnsConfig when it was used to determine the lookup order.

func (c *conf) hostLookupOrder(r *Resolver, hostname string) (ret hostLookupOrder, dnsConf *dnsConfig)

index method #

func (zc *ipv6ZoneCache) index(name string) int

init method #

func (fd *netFD) init() error

init method #

func (fd *netFD) init() error

init method #

init initializes conf and is only called via conf.initOnce.

func (conf *nsswitchConfig) init()

init function #

func init()

init method #

init initializes conf and is only called via conf.initOnce.

func (conf *resolverConfig) init()

init function #

func init()

init method #

func (fd *netFD) init() error

init method #

func (fd *netFD) init() error

initConfVal function #

initConfVal initializes confVal based on the environment that will not change during program execution.

func initConfVal()

initMPTCPavailable function #

Check that MPTCP is supported by attempting to create an MPTCP socket and by looking at the returned error if any.

func initMPTCPavailable()

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceAddrTable function #

If the ifi is nil, interfaceAddrTable returns addresses for all network interfaces. Otherwise it returns addresses for a specific interface.

func interfaceAddrTable(ifi *Interface) ([]Addr, error)

interfaceByIndex function #

func interfaceByIndex(ift []Interface, index int) (*Interface, error)

interfaceCount function #

func interfaceCount() (int, error)

interfaceMessages function #

func interfaceMessages(ifindex int) ([]route.Message, error)

interfaceMessages function #

func interfaceMessages(ifindex int) ([]route.Message, error)

interfaceMessages function #

func interfaceMessages(ifindex int) ([]route.Message, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceMulticastAddrTable function #

interfaceMulticastAddrTable returns addresses for a specific interface.

func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceTable function #

If the ifindex is zero, interfaceTable returns mappings of all network interfaces. Otherwise it returns a mapping of a specific interface.

func interfaceTable(ifindex int) ([]Interface, error)

interfaceToIPv4Addr function #

func interfaceToIPv4Addr(ifi *Interface) (IP, error)

internetAddrList method #

internetAddrList resolves addr, which may be a literal IP address or a DNS name, and returns a list of internet protocol family addresses. The result contains at least one address when error is nil.

func (r *Resolver) internetAddrList(ctx context.Context, net string, addr string) (addrList, error)

internetSocket function #

func internetSocket(ctx context.Context, net string, laddr sockaddr, raddr sockaddr, sotype int, proto int, mode string, ctrlCtxFn func(context.Context, string, string, syscall.RawConn) error) (fd *netFD, err error)

ipAddrsEface function #

ipAddrsEface returns an empty interface slice of addrs.

func ipAddrsEface(addrs []IPAddr) []any

ipAttrOf function #

func ipAttrOf(ip netip.Addr) ipAttr

ipEmptyString function #

ipEmptyString is like ip.String except that it returns an empty string when ip is unset.

func ipEmptyString(ip IP) string

ipToSockaddr function #

ipToSockaddr should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/database64128/tfo-go/v2 - github.com/metacubex/tfo-go - github.com/sagernet/tfo-go Do not remove or change the type signature. See go.dev/issue/67401. go:linkname ipToSockaddr

func ipToSockaddr(family int, ip IP, port int, zone string) (syscall.Sockaddr, error)

ipToSockaddrInet4 function #

func ipToSockaddrInet4(ip IP, port int) (syscall.SockaddrInet4, error)

ipToSockaddrInet6 function #

func ipToSockaddrInet6(ip IP, port int, zone string) (syscall.SockaddrInet6, error)

ipVersion function #

ipVersion returns the provided network's IP version: '4', '6' or 0 if network does not end in a '4' or '6' byte.

func ipVersion(network string) byte

ipv4only function #

ipv4only reports whether addr is an IPv4 address.

func ipv4only(addr IPAddr) bool

ipv6only function #

ipv6only reports whether addr is an IPv6 address except IPv4-mapped IPv6 address.

func ipv6only(addr IPAddr) bool

isAddrinfoErrno method #

isAddrinfoErrno is just for testing purposes.

func (eai addrinfoErrno) isAddrinfoErrno()

isClosedChan function #

func isClosedChan(c <-chan struct{...}) bool

isConnError function #

func isConnError(err error) bool

isConnError function #

func isConnError(err error) bool

isConnError function #

func isConnError(err error) bool

isDomainName function #

isDomainName checks if a string is a presentation-format domain name (currently restricted to hostname-compatible "preferred name" LDH labels and SRV-like "underscore labels"; see golang.org/issue/12421). isDomainName should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/sagernet/sing Do not remove or change the type signature. See go.dev/issue/67401. go:linkname isDomainName

func isDomainName(s string) bool

isGateway function #

isGateway reports whether h should be considered a "gateway" name for the myhostname NSS module.

func isGateway(h string) bool

isIPv4 function #

isIPv4 reports whether addr contains an IPv4 address.

func isIPv4(addr Addr) bool

isLocalhost function #

isLocalhost reports whether h should be considered a "localhost" name for the myhostname NSS module.

func isLocalhost(h string) bool

isNotIPv4 function #

isNotIPv4 reports whether addr does not contain an IPv4 address.

func isNotIPv4(addr Addr) bool

isOutbound function #

isOutbound reports whether h should be considered an "outbound" name for the myhostname NSS module.

func isOutbound(h string) bool

isSpace function #

isSpace reports whether b is an ASCII space character.

func isSpace(b byte) bool

isUsingMPTCPProto function #

isUsingMPTCPProto reports whether the socket protocol is MPTCP. Compared to hasFallenBack method, here only the socket protocol being used is checked: it can be MPTCP but it doesn't mean MPTCP is used on the wire, maybe a fallback to TCP has been done.

func isUsingMPTCPProto(fd *netFD) bool

isUsingMultipathTCP function #

isUsingMultipathTCP reports whether MPTCP is still being used. Please look at the description of hasFallenBack (kernel >=5.16) and isUsingMPTCPProto methods for more details about what is being checked here.

func isUsingMultipathTCP(fd *netFD) bool

isUsingMultipathTCP function #

func isUsingMultipathTCP(fd *netFD) bool

isWildcard method #

func (a *UDPAddr) isWildcard() bool

isWildcard function #

func isWildcard(a Addr) bool

isWildcard method #

func (a *IPAddr) isWildcard() bool

isWildcard method #

func (a *TCPAddr) isWildcard() bool

isWildcard method #

func (a *UnixAddr) isWildcard() bool

isZeros function #

Is p all zeros?

func isZeros(p IP) bool

joinIPv4Group function #

func joinIPv4Group(fd *netFD, ifi *Interface, ip IP) error

joinIPv4Group function #

func joinIPv4Group(fd *netFD, ifi *Interface, ip IP) error

joinIPv6Group function #

func joinIPv6Group(fd *netFD, ifi *Interface, ip IP) error

joinIPv6Group function #

func joinIPv6Group(fd *netFD, ifi *Interface, ip IP) error

linkFlags function #

func linkFlags(rawFlags uint32) Flags

linkFlags function #

func linkFlags(rawFlags int) Flags

linkFlags function #

func linkFlags(rawFlags int32) Flags

linkFlags function #

func linkFlags(rawFlags int) Flags

listenDatagram method #

func (fd *netFD) listenDatagram(ctx context.Context, laddr sockaddr, ctrlCtxFn func(context.Context, string, string, syscall.RawConn) error) error

listenIP method #

func (sl *sysListener) listenIP(ctx context.Context, laddr *IPAddr) (*IPConn, error)

listenIP method #

func (sl *sysListener) listenIP(ctx context.Context, laddr *IPAddr) (*IPConn, error)

listenIPv4MulticastUDP function #

func listenIPv4MulticastUDP(c *UDPConn, ifi *Interface, ip IP) error

listenIPv6MulticastUDP function #

func listenIPv6MulticastUDP(c *UDPConn, ifi *Interface, ip IP) error

listenMPTCP method #

func (sl *sysListener) listenMPTCP(ctx context.Context, laddr *TCPAddr) (*TCPListener, error)

listenMPTCP method #

func (sl *sysListener) listenMPTCP(ctx context.Context, laddr *TCPAddr) (*TCPListener, error)

listenMulticastUDP method #

func (sl *sysListener) listenMulticastUDP(ctx context.Context, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error)

listenMulticastUDP method #

func (sl *sysListener) listenMulticastUDP(ctx context.Context, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error)

listenPlan9 function #

func listenPlan9(ctx context.Context, net string, laddr Addr) (fd *netFD, err error)

listenStream method #

func (fd *netFD) listenStream(ctx context.Context, laddr sockaddr, backlog int, ctrlCtxFn func(context.Context, string, string, syscall.RawConn) error) error

listenTCP method #

func (sl *sysListener) listenTCP(ctx context.Context, laddr *TCPAddr) (*TCPListener, error)

listenTCP method #

func (sl *sysListener) listenTCP(ctx context.Context, laddr *TCPAddr) (*TCPListener, error)

listenTCPProto method #

func (sl *sysListener) listenTCPProto(ctx context.Context, laddr *TCPAddr, proto int) (*TCPListener, error)

listenUDP method #

func (sl *sysListener) listenUDP(ctx context.Context, laddr *UDPAddr) (*UDPConn, error)

listenUDP method #

func (sl *sysListener) listenUDP(ctx context.Context, laddr *UDPAddr) (*UDPConn, error)

listenUnix method #

func (sl *sysListener) listenUnix(ctx context.Context, laddr *UnixAddr) (*UnixListener, error)

listenUnix method #

func (sl *sysListener) listenUnix(ctx context.Context, laddr *UnixAddr) (*UnixListener, error)

listenUnixgram method #

func (sl *sysListener) listenUnixgram(ctx context.Context, laddr *UnixAddr) (*UnixConn, error)

listenUnixgram method #

func (sl *sysListener) listenUnixgram(ctx context.Context, laddr *UnixAddr) (*UnixConn, error)

listenerBacklog function #

listenerBacklog is a caching wrapper around maxListenerBacklog. listenerBacklog should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/database64128/tfo-go/v2 - github.com/metacubex/tfo-go - github.com/sagernet/tfo-go Do not remove or change the type signature. See go.dev/issue/67401. go:linkname listenerBacklog

func listenerBacklog() int

lookup method #

func (r *Resolver) lookup(ctx context.Context, name string, qtype dnsmessage.Type, conf *dnsConfig) (dnsmessage.Parser, string, error)

lookupAddr method #

func (r *Resolver) lookupAddr(ctx context.Context, addr string) (name []string, err error)

lookupAddr method #

func (r *Resolver) lookupAddr(ctx context.Context, addr string) ([]string, error)

lookupAddr method #

func (r *Resolver) lookupAddr(ctx context.Context, addr string) ([]string, error)

lookupCNAME method #

func (r *Resolver) lookupCNAME(ctx context.Context, name string) (string, error)

lookupCNAME method #

func (r *Resolver) lookupCNAME(ctx context.Context, name string) (cname string, err error)

lookupCNAME method #

func (r *Resolver) lookupCNAME(ctx context.Context, name string) (string, error)

lookupHost method #

func (*Resolver) lookupHost(ctx context.Context, host string) (addrs []string, err error)

lookupHost method #

func (r *Resolver) lookupHost(ctx context.Context, name string) ([]string, error)

lookupHost method #

func (r *Resolver) lookupHost(ctx context.Context, host string) (addrs []string, err error)

lookupIP method #

func (r *Resolver) lookupIP(ctx context.Context, network string, name string) ([]IPAddr, error)

lookupIP method #

func (r *Resolver) lookupIP(ctx context.Context, network string, host string) (addrs []IPAddr, err error)

lookupIP method #

func (r *Resolver) lookupIP(ctx context.Context, network string, host string) (addrs []IPAddr, err error)

lookupIPAddr method #

lookupIPAddr looks up host using the local resolver and particular network. It returns a slice of that host's IPv4 and IPv6 addresses.

func (r *Resolver) lookupIPAddr(ctx context.Context, network string, host string) ([]IPAddr, error)

lookupIPReturn function #

lookupIPReturn turns the return values from singleflight.Do into the return values from LookupIP.

func lookupIPReturn(addrsi any, err error, shared bool) ([]IPAddr, error)

lookupMX method #

func (r *Resolver) lookupMX(ctx context.Context, name string) ([]*MX, error)

lookupMX method #

func (r *Resolver) lookupMX(ctx context.Context, name string) ([]*MX, error)

lookupMX method #

func (r *Resolver) lookupMX(ctx context.Context, name string) (mx []*MX, err error)

lookupNS method #

func (r *Resolver) lookupNS(ctx context.Context, name string) (ns []*NS, err error)

lookupNS method #

func (r *Resolver) lookupNS(ctx context.Context, name string) ([]*NS, error)

lookupNS method #

func (r *Resolver) lookupNS(ctx context.Context, name string) ([]*NS, error)

lookupOrder method #

func (c *conf) lookupOrder(r *Resolver, hostname string) (ret hostLookupOrder, dnsConf *dnsConfig)

lookupPort method #

func (r *Resolver) lookupPort(ctx context.Context, network string, service string) (int, error)

lookupPort method #

func (r *Resolver) lookupPort(ctx context.Context, network string, service string) (int, error)

lookupPort method #

func (r *Resolver) lookupPort(ctx context.Context, network string, service string) (port int, err error)

lookupPortMap function #

func lookupPortMap(network string, service string) (port int, error error)

lookupPortMapWithNetwork function #

func lookupPortMapWithNetwork(network string, errNetwork string, service string) (port int, error error)

lookupPortWithNetwork method #

func (*Resolver) lookupPortWithNetwork(ctx context.Context, network string, errNetwork string, service string) (port int, err error)

lookupProtocol function #

lookupProtocol looks up IP protocol name and returns correspondent protocol number.

func lookupProtocol(ctx context.Context, name string) (int, error)

lookupProtocol function #

lookupProtocol looks up IP protocol name in /etc/protocols and returns correspondent protocol number.

func lookupProtocol(_ context.Context, name string) (int, error)

lookupProtocol function #

lookupProtocol looks up IP protocol name and returns the corresponding protocol number.

func lookupProtocol(ctx context.Context, name string) (proto int, err error)

lookupProtocolMap function #

func lookupProtocolMap(name string) (int, error)

lookupSRV method #

func (r *Resolver) lookupSRV(ctx context.Context, service string, proto string, name string) (cname string, addrs []*SRV, err error)

lookupSRV method #

func (r *Resolver) lookupSRV(ctx context.Context, service string, proto string, name string) (string, []*SRV, error)

lookupSRV method #

func (r *Resolver) lookupSRV(ctx context.Context, service string, proto string, name string) (string, []*SRV, error)

lookupStaticAddr function #

lookupStaticAddr looks up the hosts for the given address from /etc/hosts.

func lookupStaticAddr(addr string) []string

lookupStaticHost function #

lookupStaticHost looks up the addresses and the canonical name for the given host from /etc/hosts.

func lookupStaticHost(host string) ([]string, string)

lookupTXT method #

func (r *Resolver) lookupTXT(ctx context.Context, name string) ([]string, error)

lookupTXT method #

func (r *Resolver) lookupTXT(ctx context.Context, name string) (txt []string, err error)

lookupTXT method #

func (r *Resolver) lookupTXT(ctx context.Context, name string) ([]string, error)

loopbackIP function #

loopbackIP should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/database64128/tfo-go/v2 - github.com/metacubex/tfo-go - github.com/sagernet/tfo-go Do not remove or change the type signature. See go.dev/issue/67401. go:linkname loopbackIP

func loopbackIP(net string) IP

lowerASCII function #

lowerASCII returns the ASCII lowercase version of b.

func lowerASCII(b byte) byte

lowerASCIIBytes function #

lowerASCIIBytes makes x ASCII lowercase in-place.

func lowerASCIIBytes(x []byte)

makePipeDeadline function #

func makePipeDeadline() pipeDeadline

mapErr function #

mapErr maps from the context errors to the historical internal net error values.

func mapErr(err error) error

matchAddrFamily method #

func (ip IP) matchAddrFamily(x IP) bool

matchIPFamily function #

func matchIPFamily(family int, addr sockaddr) sockaddr

maxAckBacklog function #

Linux stores the backlog as: - uint16 in kernel version < 4.1, - uint32 in kernel version >= 4.1 Truncate number to avoid wrapping. See issue 5030 and 41470.

func maxAckBacklog(n int) int

maxListenerBacklog function #

func maxListenerBacklog() int

maxListenerBacklog function #

func maxListenerBacklog() int

maxListenerBacklog function #

func maxListenerBacklog() int

maxListenerBacklog function #

func maxListenerBacklog() int

maxListenerBacklog function #

func maxListenerBacklog() int

minNonzeroTime function #

func minNonzeroTime(a time.Time, b time.Time) time.Time

mustUseGoResolver method #

mustUseGoResolver reports whether a DNS lookup of any sort is required to use the go resolver. The provided Resolver is optional. This will report true if the cgo resolver is not available.

func (c *conf) mustUseGoResolver(r *Resolver) bool

name method #

func (fd *netFD) name() string

name method #

func (fd *netFD) name() string

name method #

func (zc *ipv6ZoneCache) name(index int) string

name method #

func (fd *netFD) name() string

nameList method #

nameList returns a list of names for sequential DNS queries.

func (conf *dnsConfig) nameList(name string) []string

netFD method #

func (fd *netFD) netFD() (*netFD, error)

networkNumberAndMask function #

func networkNumberAndMask(n *IPNet) (ip IP, m IPMask)

newAddr function #

func newAddr(ifam *syscall.IfAddrmsg, attrs []syscall.NetlinkRouteAttr) Addr

newDNSError function #

newDNSError creates a new *DNSError. Based on the err, it sets the UnwrapErr, IsTimeout, IsTemporary, IsNotFound fields.

func newDNSError(err error, name string, server string) *DNSError

newDeadlineTimer function #

func newDeadlineTimer(deadline time.Time) *deadlineTimer

newFD function #

func newFD(net string, name string, listen *os.File, ctl *os.File, data *os.File, laddr Addr, raddr Addr) (*netFD, error)

newFD function #

func newFD(sysfd syscall.Handle, family int, sotype int, net string) (*netFD, error)

newFD function #

func newFD(sysfd int, family int, sotype int, net string) (*netFD, error)

newFD function #

func newFD(net string, sysfd int) *netFD

newFakeNetFD function #

func newFakeNetFD(fd *netFD) *fakeNetFD

newFileConn function #

func newFileConn(fd *netFD) Conn

newFileFD function #

func newFileFD(f *os.File) (net *netFD, err error)

newFileFD function #

func newFileFD(f *os.File) (*netFD, error)

newFileListener function #

func newFileListener(fd *netFD) Listener

newIPConn function #

func newIPConn(fd *netFD) *IPConn

newPacketQueue function #

func newPacketQueue(readBufferBytes int) *packetQueue

newPollFD function #

func newPollFD(net string, pfd poll.FD) *netFD

newRawConn function #

func newRawConn(fd *netFD) *rawConn

newRawListener function #

func newRawListener(fd *netFD) *rawListener

newRequest function #

func newRequest(q dnsmessage.Question, ad bool) (id uint16, udpReq []byte, tcpReq []byte, err error)

newTCPConn function #

func newTCPConn(fd *netFD, keepAliveIdle time.Duration, keepAliveCfg KeepAliveConfig, preKeepAliveHook func(*netFD), keepAliveHook func(KeepAliveConfig)) *TCPConn

newUDPConn function #

func newUDPConn(fd *netFD) *UDPConn

newUnixConn function #

func newUnixConn(fd *netFD) *UnixConn

newUnixFile function #

Defined in os package.

func newUnixFile(fd int, name string) *os.File

ok method #

func (ln *TCPListener) ok() bool

ok method #

func (c *conn) ok() bool

ok method #

func (fd *netFD) ok() bool

ok method #

func (ln *TCPListener) ok() bool

ok method #

func (ln *UnixListener) ok() bool

ok method #

func (c *rawConn) ok() bool

opAddr method #

func (a *TCPAddr) opAddr() Addr

opAddr method #

func (a *IPAddr) opAddr() Addr

opAddr method #

func (a *UDPAddr) opAddr() Addr

opAddr method #

func (a *UnixAddr) opAddr() Addr

open function #

func open(name string) (*file, error)

parseCNAMEFromResources function #

func parseCNAMEFromResources(resources []dnsmessage.Resource) (string, error)

parseCriteria function #

parses "foo=bar !foo=bar"

func parseCriteria(x string) (c []nssCriterion, err error)

parseIP function #

func parseIP(s string) ([16]byte, bool)

parseLiteralIP function #

func parseLiteralIP(addr string) string

parseNSSConf function #

func parseNSSConf(f *file) *nssConf

parseNSSConfFile function #

func parseNSSConfFile(file string) *nssConf

parseNetwork function #

func parseNetwork(ctx context.Context, network string, needsProto bool) (afnet string, proto int, err error)

parsePlan9Addr function #

parsePlan9Addr parses address of the form [ip!]port (e.g. 127.0.0.1!80).

func parsePlan9Addr(s string) (ip IP, iport int, err error)

parsePort function #

parsePort parses service as a decimal integer and returns the corresponding value as port. It is the caller's responsibility to parse service as a non-decimal integer when needsLookup is true. Some system resolvers will return a valid port number when given a number over 65536 (see https://golang.org/issues/11715). Alas, the parser can't bail early on numbers > 65536. Therefore reasonably large/small numbers are parsed in full and rejected if invalid.

func parsePort(service string) (port int, needsLookup bool)

parseProcNetIGMP function #

func parseProcNetIGMP(path string, ifi *Interface) []Addr

parseProcNetIGMP6 function #

func parseProcNetIGMP6(path string, ifi *Interface) []Addr

partialDeadline function #

partialDeadline returns the deadline to use for a single address, when multiple addresses are pending.

func partialDeadline(now time.Time, deadline time.Time, addrsRemaining int) (time.Time, error)

partition method #

partition divides an address list into two categories, using a strategy function to assign a boolean label to each address. The first address, and any with a matching label, are returned as primaries, while addresses with the opposite label are returned as fallbacks. For non-empty inputs, primaries is guaranteed to be non-empty.

func (addrs addrList) partition(strategy func(Addr) bool) (primaries addrList, fallbacks addrList)

plan9LocalAddr function #

plan9LocalAddr returns a Plan 9 local address string. See setladdrport at https://9p.io/sources/plan9/sys/src/9/ip/devip.c.

func plan9LocalAddr(addr Addr) string

preferGo method #

func (r *Resolver) preferGo() bool

probe method #

probe probes IPv4, IPv6 and IPv4-mapped IPv6 communication capabilities which are controlled by the IPV6_V6ONLY socket option and kernel configuration. Should we try to use the IPv4 socket interface if we're only dealing with IPv4 sockets? As long as the host system understands IPv4-mapped IPv6, it's okay to pass IPv4-mapped IPv6 addresses to the IPv6 interface. That simplifies our code and is most general. Unfortunately, we need to run on kernels built without IPv6 support too. So probe the kernel to figure it out.

func (p *ipStackCapabilities) probe()

probe method #

probe probes IPv4, IPv6 and IPv4-mapped IPv6 communication capabilities. Plan 9 uses IPv6 natively, see ip(3).

func (p *ipStackCapabilities) probe()

probe function #

func probe(filename string, query string) bool

put method #

func (pq *packetQueue) put(q packetQueueState)

query function #

func query(ctx context.Context, filename string, query string, bufSize int) (addrs []string, err error)

queryCS function #

func queryCS(ctx context.Context, net string, host string, service string) (res []string, err error)

queryCS1 function #

func queryCS1(ctx context.Context, net string, ip IP, port int) (clone string, dest string, err error)

queryDNS function #

func queryDNS(ctx context.Context, addr string, typ string) (res []string, err error)

randInt function #

func randInt() int

randIntn function #

func randIntn(n int) int

read method #

func (p *pipe) read(b []byte) (n int, err error)

readFrom method #

func (c *UDPConn) readFrom(b []byte, addr *UDPAddr) (int, *UDPAddr, error)

readFrom method #

func (c *TCPConn) readFrom(r io.Reader) (int64, error)

readFrom method #

func (c *UDPConn) readFrom(b []byte, addr *UDPAddr) (int, *UDPAddr, error)

readFrom method #

func (c *IPConn) readFrom(b []byte) (int, *IPAddr, error)

readFrom method #

func (fd *netFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error)

readFrom method #

func (c *UnixConn) readFrom(b []byte) (int, *UnixAddr, error)

readFrom method #

func (ffd *fakeNetFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error)

readFrom method #

func (c *IPConn) readFrom(b []byte) (int, *IPAddr, error)

readFrom method #

func (c *UnixConn) readFrom(b []byte) (int, *UnixAddr, error)

readFrom method #

func (c *TCPConn) readFrom(r io.Reader) (int64, error)

readFromAddrPort method #

func (c *UDPConn) readFromAddrPort(b []byte) (int, netip.AddrPort, error)

readFromAddrPort method #

func (c *UDPConn) readFromAddrPort(b []byte) (n int, addr netip.AddrPort, err error)

readFromInet4 method #

func (ffd *fakeNetFD) readFromInet4(p []byte, sa *syscall.SockaddrInet4) (n int, err error)

readFromInet4 method #

func (fd *netFD) readFromInet4(p []byte, from *syscall.SockaddrInet4) (n int, err error)

readFromInet6 method #

func (ffd *fakeNetFD) readFromInet6(p []byte, sa *syscall.SockaddrInet6) (n int, err error)

readFromInet6 method #

func (fd *netFD) readFromInet6(p []byte, from *syscall.SockaddrInet6) (n int, err error)

readFromUDP method #

readFromUDP implements ReadFromUDP.

func (c *UDPConn) readFromUDP(b []byte, addr *UDPAddr) (int, *UDPAddr, error)

readHosts function #

func readHosts()

readInterface function #

func readInterface(i int) (*Interface, error)

readLine method #

func (f *file) readLine() (s string, ok bool)

readMsg method #

func (c *IPConn) readMsg(b []byte, oob []byte) (n int, oobn int, flags int, addr *IPAddr, err error)

readMsg method #

func (c *UDPConn) readMsg(b []byte, oob []byte) (n int, oobn int, flags int, addr netip.AddrPort, err error)

readMsg method #

func (c *UnixConn) readMsg(b []byte, oob []byte) (n int, oobn int, flags int, addr *UnixAddr, err error)

readMsg method #

func (c *IPConn) readMsg(b []byte, oob []byte) (n int, oobn int, flags int, addr *IPAddr, err error)

readMsg method #

func (c *UnixConn) readMsg(b []byte, oob []byte) (n int, oobn int, flags int, addr *UnixAddr, err error)

readMsg method #

func (ffd *fakeNetFD) readMsg(p []byte, oob []byte, flags int) (n int, oobn int, retflags int, sa syscall.Sockaddr, err error)

readMsg method #

func (c *UDPConn) readMsg(b []byte, oob []byte) (n int, oobn int, flags int, addr netip.AddrPort, err error)

readMsg method #

func (fd *netFD) readMsg(p []byte, oob []byte, flags int) (n int, oobn int, retflags int, sa syscall.Sockaddr, err error)

readMsgInet4 method #

func (ffd *fakeNetFD) readMsgInet4(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet4) (n int, oobn int, retflags int, err error)

readMsgInet4 method #

func (fd *netFD) readMsgInet4(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet4) (n int, oobn int, retflags int, err error)

readMsgInet6 method #

func (ffd *fakeNetFD) readMsgInet6(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet6) (n int, oobn int, retflags int, err error)

readMsgInet6 method #

func (fd *netFD) readMsgInet6(p []byte, oob []byte, flags int, sa *syscall.SockaddrInet6) (n int, oobn int, retflags int, err error)

readPlan9Addr function #

func readPlan9Addr(net string, filename string) (addr Addr, err error)

readProtocols function #

readProtocols loads contents of /etc/protocols into protocols map for quick access.

func readProtocols()

readServices function #

func readServices()

recvfrom method #

func (pq *packetQueue) recvfrom(dt *deadlineTimer, b []byte, wholePacket bool, checkFrom func(sockaddr) error) (n int, from sockaddr, err error)

releaseSema method #

func (conf *resolverConfig) releaseSema()

releaseSema method #

func (conf *nsswitchConfig) releaseSema()

releaseThread function #

func releaseThread()

removeComment function #

removeComment returns line, removing any '#' byte and any following bytes.

func removeComment(line string) string

resSearch function #

resSearch will make a call to the 'res_nsearch' routine in the C library and parse the output as a slice of DNS resources.

func resSearch(ctx context.Context, hostname string, rtype int, class int) ([]dnsmessage.Resource, error)

resolveAddrList method #

resolveAddrList resolves addr using hint and returns a list of addresses. The result contains at least one address when error is nil.

func (r *Resolver) resolveAddrList(ctx context.Context, op string, network string, addr string, hint Addr) (addrList, error)

resolveCNAME function #

returns the last CNAME in chain.

func resolveCNAME(name *uint16, r *syscall.DNSRecord) *uint16

resolver method #

func (d *Dialer) resolver() *Resolver

reverseaddr function #

reverseaddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP address addr suitable for rDNS (PTR) record lookup or an error if it fails to parse the IP address.

func reverseaddr(addr string) (arpa string, err error)

roundDurationUp function #

roundDurationUp rounds d to the next multiple of to.

func roundDurationUp(d time.Duration, to time.Duration) time.Duration

runtime_rand function #

provided by runtime go:linkname runtime_rand runtime.rand

func runtime_rand() uint64

selfConnect function #

func selfConnect(fd *netFD, err error) bool

send method #

func (pq *packetQueue) send(dt *deadlineTimer, b []byte, from sockaddr, block bool) (n int, err error)

sendFile function #

sendFile copies the contents of r to c using the sendfile system call to minimize copies. if handled == true, sendFile returns the number (potentially zero) of bytes copied and any non-EOF error. if handled == false, sendFile performed no work.

func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool)

sendFile function #

sendFile copies the contents of r to c using the sendfile system call to minimize copies. if handled == true, sendFile returns the number (potentially zero) of bytes copied and any non-EOF error. if handled == false, sendFile performed no work.

func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool)

sendFile function #

sendFile copies the contents of r to c using the TransmitFile system call to minimize copies. if handled == true, sendFile returns the number of bytes copied and any non-EOF error. if handled == false, sendFile performed no work.

func sendFile(fd *netFD, r io.Reader) (written int64, err error, handled bool)

sendFile function #

func sendFile(c *netFD, r io.Reader) (n int64, err error, handled bool)

serverOffset method #

serverOffset returns an offset that can be used to determine indices of servers in c.servers when making queries. When the rotate option is enabled, this offset increases. Otherwise it is always 0.

func (c *dnsConfig) serverOffset() uint32

set method #

set sets the point in time when the deadline will time out. A timeout event is signaled by closing the channel returned by waiter. Once a timeout has occurred, the deadline can be refreshed by specifying a t value in the future. A zero value for t prevents timeout.

func (d *pipeDeadline) set(t time.Time)

set method #

func (m *mptcpStatusListen) set(use bool)

set method #

func (m *mptcpStatusDial) set(use bool)

setAddr method #

func (fd *netFD) setAddr(laddr Addr, raddr Addr)

setAddr method #

func (fd *netFD) setAddr(laddr Addr, raddr Addr)

setDefaultListenerSockopts function #

func setDefaultListenerSockopts(s int) error

setDefaultListenerSockopts function #

func setDefaultListenerSockopts(s int) error

setDefaultListenerSockopts function #

func setDefaultListenerSockopts(s int) error

setDefaultListenerSockopts function #

func setDefaultListenerSockopts(s syscall.Handle) error

setDefaultListenerSockopts function #

func setDefaultListenerSockopts(s int) error

setDefaultListenerSockopts function #

func setDefaultListenerSockopts(s int) error

setDefaultMulticastSockopts function #

func setDefaultMulticastSockopts(s int) error

setDefaultMulticastSockopts function #

func setDefaultMulticastSockopts(s syscall.Handle) error

setDefaultMulticastSockopts function #

func setDefaultMulticastSockopts(s int) error

setDefaultMulticastSockopts function #

func setDefaultMulticastSockopts(s int) error

setDefaultMulticastSockopts function #

func setDefaultMulticastSockopts(s int) error

setDefaultMulticastSockopts function #

func setDefaultMulticastSockopts(s int) error

setDefaultSockopts function #

func setDefaultSockopts(s int, family int, sotype int, ipv6only bool) error

setDefaultSockopts function #

func setDefaultSockopts(s int, family int, sotype int, ipv6only bool) error

setDefaultSockopts function #

func setDefaultSockopts(s syscall.Handle, family int, sotype int, ipv6only bool) error

setDefaultSockopts function #

func setDefaultSockopts(s int, family int, sotype int, ipv6only bool) error

setDefaultSockopts function #

func setDefaultSockopts(s int, family int, sotype int, ipv6only bool) error

setDefaultSockopts function #

func setDefaultSockopts(s int, family int, sotype int, ipv6only bool) error

setIPv4MreqToInterface function #

func setIPv4MreqToInterface(mreq *syscall.IPMreq, ifi *Interface) error

setIPv4MulticastInterface function #

func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error

setIPv4MulticastInterface function #

func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error

setIPv4MulticastInterface function #

func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error

setIPv4MulticastInterface function #

func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error

setIPv4MulticastLoopback function #

func setIPv4MulticastLoopback(fd *netFD, v bool) error

setIPv4MulticastLoopback function #

func setIPv4MulticastLoopback(fd *netFD, v bool) error

setIPv4MulticastLoopback function #

func setIPv4MulticastLoopback(fd *netFD, v bool) error

setIPv4MulticastLoopback function #

func setIPv4MulticastLoopback(fd *netFD, v bool) error

setIPv6MulticastInterface function #

func setIPv6MulticastInterface(fd *netFD, ifi *Interface) error

setIPv6MulticastInterface function #

func setIPv6MulticastInterface(fd *netFD, ifi *Interface) error

setIPv6MulticastLoopback function #

func setIPv6MulticastLoopback(fd *netFD, v bool) error

setIPv6MulticastLoopback function #

func setIPv6MulticastLoopback(fd *netFD, v bool) error

setKeepAlive function #

func setKeepAlive(fd *netFD, keepalive bool) error

setKeepAlive function #

func setKeepAlive(fd *netFD, keepalive bool) error

setKeepAlive function #

func setKeepAlive(fd *netFD, keepalive bool) error

setKeepAliveCount function #

func setKeepAliveCount(_ *netFD, n int) error

setKeepAliveCount function #

func setKeepAliveCount(_ *netFD, n int) error

setKeepAliveCount function #

func setKeepAliveCount(fd *netFD, n int) error

setKeepAliveCount function #

func setKeepAliveCount(fd *netFD, n int) error

setKeepAliveCount function #

func setKeepAliveCount(fd *netFD, n int) error

setKeepAliveCount function #

func setKeepAliveCount(fd *netFD, n int) error

setKeepAliveCount function #

func setKeepAliveCount(fd *netFD, n int) error

setKeepAliveIdle function #

func setKeepAliveIdle(fd *netFD, d time.Duration) error

setKeepAliveIdle function #

func setKeepAliveIdle(fd *netFD, d time.Duration) error

setKeepAliveIdle function #

func setKeepAliveIdle(fd *netFD, d time.Duration) error

setKeepAliveIdle function #

func setKeepAliveIdle(fd *netFD, d time.Duration) error

setKeepAliveIdle function #

Set keep alive period.

func setKeepAliveIdle(fd *netFD, d time.Duration) error

setKeepAliveIdle function #

func setKeepAliveIdle(_ *netFD, d time.Duration) error

setKeepAliveIdle function #

func setKeepAliveIdle(fd *netFD, d time.Duration) error

setKeepAliveIdleAndInterval function #

setKeepAliveIdleAndInterval serves for kernels prior to Windows 10, version 1709.

func setKeepAliveIdleAndInterval(fd *netFD, idle time.Duration, interval time.Duration) error

setKeepAliveIdleAndIntervalAndCount function #

setKeepAliveIdleAndIntervalAndCount serves for Solaris prior to 11.4 by simulating the TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT with `TCP_KEEPALIVE_THRESHOLD` + `TCP_KEEPALIVE_ABORT_THRESHOLD`.

func setKeepAliveIdleAndIntervalAndCount(fd *netFD, idle time.Duration, interval time.Duration, count int) error

setKeepAliveInterval function #

func setKeepAliveInterval(_ *netFD, d time.Duration) error

setKeepAliveInterval function #

func setKeepAliveInterval(fd *netFD, d time.Duration) error

setKeepAliveInterval function #

func setKeepAliveInterval(fd *netFD, d time.Duration) error

setKeepAliveInterval function #

func setKeepAliveInterval(fd *netFD, d time.Duration) error

setKeepAliveInterval function #

func setKeepAliveInterval(fd *netFD, d time.Duration) error

setKeepAliveInterval function #

func setKeepAliveInterval(fd *netFD, d time.Duration) error

setKeepAliveInterval function #

func setKeepAliveInterval(_ *netFD, d time.Duration) error

setLinger method #

func (pq *packetQueue) setLinger(linger bool) error

setLinger function #

func setLinger(fd *netFD, sec int) error

setLinger function #

func setLinger(fd *netFD, sec int) error

setLinger method #

func (ffd *fakeNetFD) setLinger(sec int) error

setLinger function #

func setLinger(fd *netFD, sec int) error

setNoDelay function #

func setNoDelay(fd *netFD, noDelay bool) error

setNoDelay function #

func setNoDelay(fd *netFD, noDelay bool) error

setNoDelay function #

func setNoDelay(_ *netFD, _ bool) error

setReadBuffer function #

func setReadBuffer(fd *netFD, bytes int) error

setReadBuffer method #

setReadBuffer sets a soft limit on the number of bytes available to read from the pipe.

func (pq *packetQueue) setReadBuffer(bytes int) error

setReadBuffer function #

func setReadBuffer(fd *netFD, bytes int) error

setReadBuffer method #

func (ffd *fakeNetFD) setReadBuffer(bytes int) error

setReadBuffer function #

func setReadBuffer(fd *netFD, bytes int) error

setReadMsgCloseOnExec function #

func setReadMsgCloseOnExec(oob []byte)

setReadMsgCloseOnExec function #

func setReadMsgCloseOnExec(oob []byte)

setReadMsgCloseOnExec function #

func setReadMsgCloseOnExec(oob []byte)

setWriteBuffer function #

func setWriteBuffer(fd *netFD, bytes int) error

setWriteBuffer function #

func setWriteBuffer(fd *netFD, bytes int) error

setWriteBuffer method #

func (ffd *fakeNetFD) setWriteBuffer(bytes int) error

setWriteBuffer function #

func setWriteBuffer(fd *netFD, bytes int) error

shuffleByWeight method #

shuffleByWeight shuffles SRV records by weight using the algorithm described in RFC 2782.

func (addrs byPriorityWeight) shuffleByWeight()

shutdown method #

func (fd *netFD) shutdown(how int) error

shutdown method #

func (fd *netFD) shutdown(how int) error

simpleMaskLength function #

If mask is a sequence of 1 bits followed by 0 bits, return the number of 1 bits.

func simpleMaskLength(mask IPMask) int

skipToAnswer function #

func skipToAnswer(p *dnsmessage.Parser, qtype dnsmessage.Type) error

sockaddr method #

func (a *UDPAddr) sockaddr(family int) (syscall.Sockaddr, error)

sockaddr method #

func (a *IPAddr) sockaddr(family int) (syscall.Sockaddr, error)

sockaddr method #

func (a *UnixAddr) sockaddr(family int) (syscall.Sockaddr, error)

sockaddr method #

func (a *TCPAddr) sockaddr(family int) (syscall.Sockaddr, error)

sockaddrToIP function #

func sockaddrToIP(sa syscall.Sockaddr) Addr

sockaddrToTCP function #

func sockaddrToTCP(sa syscall.Sockaddr) Addr

sockaddrToUDP function #

func sockaddrToUDP(sa syscall.Sockaddr) Addr

sockaddrToUnix function #

func sockaddrToUnix(sa syscall.Sockaddr) Addr

sockaddrToUnixgram function #

func sockaddrToUnixgram(sa syscall.Sockaddr) Addr

sockaddrToUnixpacket function #

func sockaddrToUnixpacket(sa syscall.Sockaddr) Addr

socket function #

socket returns a network file descriptor that is ready for I/O using the fake network.

func socket(ctx context.Context, net string, family int, sotype int, proto int, ipv6only bool, laddr sockaddr, raddr sockaddr, ctrlCtxFn func(context.Context, string, string, syscall.RawConn) error) (*netFD, error)

socket function #

socket returns a network file descriptor that is ready for asynchronous I/O using the network poller.

func socket(ctx context.Context, net string, family int, sotype int, proto int, ipv6only bool, laddr sockaddr, raddr sockaddr, ctrlCtxFn func(context.Context, string, string, syscall.RawConn) error) (fd *netFD, err error)

sort method #

sort reorders MX records as specified in RFC 5321.

func (s byPref) sort()

sort method #

sort reorders SRV records as specified in RFC 2782.

func (addrs byPriorityWeight) sort()

sortByRFC6724 function #

func sortByRFC6724(addrs []IPAddr)

sortByRFC6724withSrcs function #

func sortByRFC6724withSrcs(addrs []IPAddr, srcs []netip.Addr)

sotypeToNet function #

func sotypeToNet(sotype int) string

spliceFrom function #

func spliceFrom(_ *netFD, _ io.Reader) (int64, error, bool)

spliceFrom function #

spliceFrom transfers data from r to c using the splice system call to minimize copies from and to userspace. c must be a TCP connection. Currently, spliceFrom is only enabled if r is a TCP or a stream-oriented Unix connection. If spliceFrom returns handled == false, it has performed no work.

func spliceFrom(c *netFD, r io.Reader) (written int64, err error, handled bool)

spliceTo function #

func spliceTo(_ io.Writer, _ *netFD) (int64, error, bool)

spliceTo function #

spliceTo transfers data from c to w using the splice system call to minimize copies from and to userspace. c must be a TCP connection. Currently, spliceTo is only enabled if w is a stream-oriented Unix connection. If spliceTo returns handled == false, it has performed no work.

func spliceTo(w io.Writer, c *netFD) (written int64, err error, handled bool)

splitAtBytes function #

Split s at any bytes in t.

func splitAtBytes(s string, t string) []string

splitHostZone function #

func splitHostZone(s string) (host string, zone string)

spuriousENOTAVAIL function #

func spuriousENOTAVAIL(err error) bool

srcAddrs function #

srcAddrs tries to UDP-connect to each address to see if it has a route. (This doesn't send any packets). The destination port number is irrelevant.

func srcAddrs(addrs []IPAddr) []netip.Addr

standardCriteria method #

standardCriteria reports all specified criteria have the default status actions.

func (s nssSource) standardCriteria() bool

standardStatusAction method #

standardStatusAction reports whether c is equivalent to not specifying the criterion at all. last is whether this criteria is the last in the list.

func (c nssCriterion) standardStatusAction(last bool) bool

startPlan9 function #

func startPlan9(ctx context.Context, net string, addr Addr) (ctl *os.File, dest string, proto string, name string, err error)

stat method #

func (f *file) stat() (mtime time.Time, size int64, err error)

stat function #

func stat(name string) (mtime time.Time, size int64, err error)

status method #

func (fd *netFD) status(ln int) (string, error)

strictErrors method #

func (r *Resolver) strictErrors() bool

stringsEqualFold function #

stringsEqualFold is strings.EqualFold, ASCII only. It reports whether s and t are equal, ASCII-case-insensitively.

func stringsEqualFold(s string, t string) bool

stringsHasSuffixFold function #

stringsHasSuffixFold reports whether s ends in suffix, ASCII-case-insensitively.

func stringsHasSuffixFold(s string, suffix string) bool

stripIPv4Header function #

func stripIPv4Header(n int, b []byte) int

supportsIPv4 function #

supportsIPv4 reports whether the platform supports IPv4 networking functionality.

func supportsIPv4() bool

supportsIPv4map function #

supportsIPv4map reports whether the platform supports mapping an IPv4 address inside an IPv6 address at transport layer protocols. See RFC 4291, RFC 4038 and RFC 3493.

func supportsIPv4map() bool

supportsIPv6 function #

supportsIPv6 reports whether the platform supports IPv6 networking functionality.

func supportsIPv6() bool

supportsMultipathTCP function #

func supportsMultipathTCP() bool

sysSocket function #

Wrapper around the socket system call that marks the returned file descriptor as nonblocking and close-on-exec.

func sysSocket(family int, sotype int, proto int) (int, error)

sysSocket function #

Wrapper around the socket system call that marks the returned file descriptor as nonblocking and close-on-exec.

func sysSocket(family int, sotype int, proto int) (int, error)

sysSocket function #

func sysSocket(family int, sotype int, proto int) (int, error)

sysSocket function #

func sysSocket(family int, sotype int, proto int) (syscall.Handle, error)

sysSocket function #

Wrapper around the socket system call that marks the returned file descriptor as nonblocking and close-on-exec.

func sysSocket(family int, sotype int, proto int) (int, error)

systemConf function #

systemConf returns the machine's network configuration.

func systemConf() *conf

toLocal method #

func (a *UnixAddr) toLocal(net string) sockaddr

toLocal method #

func (a *IPAddr) toLocal(net string) sockaddr

toLocal method #

func (a *TCPAddr) toLocal(net string) sockaddr

toLocal function #

func toLocal(a Addr, net string) Addr

toLocal method #

func (a *UDPAddr) toLocal(net string) sockaddr

toLower function #

toLower returns a lower-case version of in. Restricting us to ASCII is sufficient to handle the IP protocol names and allow us to not depend on the strings and unicode packages.

func toLower(in string) string

trimSpace function #

trimSpace returns x without any leading or trailing ASCII whitespace.

func trimSpace(x string) string

tryAcquireSema method #

func (conf *resolverConfig) tryAcquireSema() bool

tryAcquireSema method #

func (conf *nsswitchConfig) tryAcquireSema() bool

tryOneName method #

Do a lookup for a single name, which must be rooted (otherwise answer will not find the answers).

func (r *Resolver) tryOneName(ctx context.Context, cfg *dnsConfig, name string, qtype dnsmessage.Type) (dnsmessage.Parser, string, error)

tryUpdate method #

tryUpdate tries to update conf with the named resolv.conf file. The name variable only exists for testing. It is otherwise always "/etc/resolv.conf".

func (conf *resolverConfig) tryUpdate(name string)

tryUpdate method #

tryUpdate tries to update conf.

func (conf *nsswitchConfig) tryUpdate()

unixSocket function #

func unixSocket(ctx context.Context, net string, laddr sockaddr, raddr sockaddr, mode string, ctxCtrlFn func(context.Context, string, string, syscall.RawConn) error) (*netFD, error)

unmarshalUDPHeader function #

func unmarshalUDPHeader(b []byte) (*udpHeader, []byte)

update method #

update refreshes the network interface information if the cache was last updated more than 1 minute ago, or if force is set. It reports whether the cache was updated.

func (zc *ipv6ZoneCache) update(ift []Interface, force bool) (updated bool)

validRecs function #

returns only results applicable to name and resolves CNAME entries.

func validRecs(r *syscall.DNSRecord, dnstype uint16, name string) []*syscall.DNSRecord

validateResolvedAddr function #

func validateResolvedAddr(net string, family int, sa sockaddr) error

wait method #

wait returns a channel that is closed when the deadline is exceeded.

func (d *pipeDeadline) wait() (chan struct{...})

winError function #

func winError(call string, err error) error

withUnexpiredValuesPreserved function #

withUnexpiredValuesPreserved returns a context.Context that only uses lookupCtx for its values, otherwise it is never canceled and has no deadline. If the lookup context expires, any looked up values will return nil. See Issue 28600.

func withUnexpiredValuesPreserved(lookupCtx context.Context) context.Context

wrapSyscallError function #

wrapSyscallError takes an error and a syscall name. If the error is a syscall.Errno, it wraps it in an os.SyscallError using the syscall name.

func wrapSyscallError(name string, err error) error

write method #

func (pq *packetQueue) write(dt *deadlineTimer, b []byte, from sockaddr) (n int, err error)

write method #

func (p *pipe) write(b []byte) (n int, err error)

writeBuffers method #

func (fd *netFD) writeBuffers(buf *Buffers) (int64, error)

writeBuffers method #

func (c *conn) writeBuffers(v *Buffers) (int64, error)

writeBuffers method #

func (c *conn) writeBuffers(v *Buffers) (int64, error)

writeBuffers method #

func (fd *netFD) writeBuffers(v *Buffers) (n int64, err error)

writeMsg method #

func (fd *netFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err error)

writeMsg method #

func (c *UnixConn) writeMsg(b []byte, oob []byte, addr *UnixAddr) (n int, oobn int, err error)

writeMsg method #

func (c *IPConn) writeMsg(b []byte, oob []byte, addr *IPAddr) (n int, oobn int, err error)

writeMsg method #

func (c *UnixConn) writeMsg(b []byte, oob []byte, addr *UnixAddr) (n int, oobn int, err error)

writeMsg method #

func (c *UDPConn) writeMsg(b []byte, oob []byte, addr *UDPAddr) (n int, oobn int, err error)

writeMsg method #

func (c *IPConn) writeMsg(b []byte, oob []byte, addr *IPAddr) (n int, oobn int, err error)

writeMsg method #

func (c *UDPConn) writeMsg(b []byte, oob []byte, addr *UDPAddr) (n int, oobn int, err error)

writeMsg method #

func (ffd *fakeNetFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err error)

writeMsgAddrPort method #

func (c *UDPConn) writeMsgAddrPort(b []byte, oob []byte, addr netip.AddrPort) (n int, oobn int, err error)

writeMsgAddrPort method #

func (c *UDPConn) writeMsgAddrPort(b []byte, oob []byte, addr netip.AddrPort) (n int, oobn int, err error)

writeMsgInet4 method #

func (ffd *fakeNetFD) writeMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (n int, oobn int, err error)

writeMsgInet4 method #

func (fd *netFD) writeMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (n int, oobn int, err error)

writeMsgInet6 method #

func (ffd *fakeNetFD) writeMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (n int, oobn int, err error)

writeMsgInet6 method #

func (fd *netFD) writeMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (n int, oobn int, err error)

writeTo method #

func (c *UnixConn) writeTo(b []byte, addr *UnixAddr) (int, error)

writeTo method #

func (c *TCPConn) writeTo(w io.Writer) (int64, error)

writeTo method #

func (c *IPConn) writeTo(b []byte, addr *IPAddr) (int, error)

writeTo method #

func (c *UDPConn) writeTo(b []byte, addr *UDPAddr) (int, error)

writeTo method #

func (c *UnixConn) writeTo(b []byte, addr *UnixAddr) (int, error)

writeTo method #

func (c *IPConn) writeTo(b []byte, addr *IPAddr) (int, error)

writeTo method #

func (c *UDPConn) writeTo(b []byte, addr *UDPAddr) (int, error)

writeTo method #

func (c *TCPConn) writeTo(w io.Writer) (int64, error)

writeTo method #

func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error)

writeTo method #

func (ffd *fakeNetFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error)

writeToAddrPort method #

func (c *UDPConn) writeToAddrPort(b []byte, addr netip.AddrPort) (int, error)

writeToAddrPort method #

func (c *UDPConn) writeToAddrPort(b []byte, addr netip.AddrPort) (int, error)

writeToInet4 method #

func (ffd *fakeNetFD) writeToInet4(p []byte, sa *syscall.SockaddrInet4) (n int, err error)

writeToInet4 method #

func (fd *netFD) writeToInet4(p []byte, sa *syscall.SockaddrInet4) (n int, err error)

writeToInet6 method #

func (fd *netFD) writeToInet6(p []byte, sa *syscall.SockaddrInet6) (n int, err error)

writeToInet6 method #

func (ffd *fakeNetFD) writeToInet6(p []byte, sa *syscall.SockaddrInet6) (n int, err error)

xtoi function #

Hexadecimal to integer. Returns number, characters consumed, success.

func xtoi(s string) (n int, i int, ok bool)

xtoi2 function #

xtoi2 converts the next two hex digits of s into a byte. If s is longer than 2 bytes then the third byte must be e. If the first two bytes of s are not hex digits or the third byte does not match e, false is returned.

func xtoi2(s string, e byte) (byte, bool)

Generated with Arrow