Documentation ¶
Index ¶
- Variables
- func DialIP(network, address string, timeout time.Duration) (net.IP, error)
- func ExceptInterfaceNameFilter(names ...string) func(iface net.Interface) bool
- func ExpectInterfaceNameFilter(names ...string) func(iface net.Interface) bool
- func HostportOrDefault(hostport string, defHostport string) string
- func IP4toUInt32(ip net.IP) uint32
- func IPtoBigInt(ip net.IP) *big.Int
- func IsLoopbackHost(host string) bool
- func ListenAddr(filters ...func(iface net.Interface) bool) (net.HardwareAddr, net.IP, error)
- func ListenIP(filters ...func(iface net.Interface) bool) (net.IP, error)
- func ListenMac(filters ...func(iface net.Interface) bool) (net.HardwareAddr, error)
- func LoopbackListener(ports ...string) (net.Listener, error)
- func OnceCloseListener(l net.Listener) net.Listener
- func ParseIP(s string) net.IP
- func ParseIPV4(i uint32) net.IP
- func ParseIPV6(s string, base int) net.IP
- func RandomPort(host string) (int, error)
- func RoutedInterfaceNameFilter() func(iface net.Interface) bool
- func ScoreAddr(iface net.Interface, addr net.Addr) (int, net.IP)
- func ServeIP(networks, addresses []string, timeout time.Duration) (net.IP, error)
- func SplitHostPort(hostport string) (host, port string, err error)
- func TcpKeepAliveListener(l *net.TCPListener, d time.Duration) net.Listener
- type IPFormat
- type MultiListener
- type NotifyListener
Constants ¶
This section is empty.
Variables ¶
var ErrListenerClosed = errListenerClosed("net: listener closed")
ErrListenerClosed is returned from Listener.Accept when the underlying listener is closed.
var INet6AToN = IPtoBigInt
INet6AToN returns the numeric value of an IPv6 address
var INet6NToA = ParseIPV6
INet6NToA returns the IPv6 address from a numeric value
var INetAToN = IP4toUInt32
INetAToN returns the numeric value of an IP address
var INetNToA = ParseIPV4
INetNToA returns the IP address from a numeric value
var Ipv4LoopbackHosts = []string{"localhost", "127.0.0.1"}
var Ipv6LoopbackHosts = []string{"localhost", "[::1]", "::1"}
Functions ¶
func ExceptInterfaceNameFilter ¶
ExceptInterfaceNameFilter you can specify which interface _not_ to listen on
func ExpectInterfaceNameFilter ¶
ExpectInterfaceNameFilter If you want to listen specified interfaces (and the loopback) give the name of the interface (eg eth0) here.
func HostportOrDefault ¶
HostportOrDefault takes the user input target string and default port, returns formatted host and port info. If target doesn't specify a port, set the port to be the defaultPort. If target is in IPv6 format and host-name is enclosed in square brackets, brackets are stripped when setting the host. examples: target: "www.google.com" defaultPort: "443" returns host: "www.google.com", port: "443" target: "ipv4-host:80" defaultPort: "443" returns host: "ipv4-host", port: "80" target: "[ipv6-host]" defaultPort: "443" returns host: "ipv6-host", port: "443" target: ":80" defaultPort: "443" returns host: "localhost", port: "80"
func IP4toUInt32 ¶
func IsLoopbackHost ¶
func ListenAddr ¶
ListenAddr returns the Mac and IP to bind to in Listen. It tries to find an Mac and IP that can be used by other machines to reach this machine. filters is interface filters any return false if the interface is _not_ to listen on
func ListenIP ¶
ListenIP returns the IP to bind to in Listen. It tries to find an IP that can be used by other machines to reach this machine. filters is interface filters any return false if the interface is _not_ to listen on
func ListenMac ¶
ListenMac returns the Mac to bind to in Listen. It tries to find an Mac that can be used by other machines to reach this machine. filters is interface filters any return false if the interface is _not_ to listen on
func LoopbackListener ¶
LoopbackListener returns a loopback listener on a first usable port in ports or 0 if ports is empty
func OnceCloseListener ¶
OnceCloseListener wraps a net.Listener, protecting it from multiple Close calls.
func ParseIPV4 ¶
ParseIPV4 parses i as an IP address, returning the result. If i is not a valid integer representation of an IP address, ParseIP returns nil.
func RandomPort ¶
RandomPort returns a random port by a temporary listen on :0
func RoutedInterfaceNameFilter ¶
RoutedInterfaceNameFilter returns a network interface that can route IP traffic and satisfies flags.
The provided network must be "ip", "ip4" or "ip6".
func ScoreAddr ¶
ScoreAddr scores how likely the given addr is to be a remote address and returns the IP to use when listening. Any address which receives a negative score should not be used. Scores are calculated as: -1 for any unknown IP addreseses. +300 for IPv4 addresses +100 for non-local addresses, extra +100 for "up" interfaces. +100 for routable addresses -50 for local mac addr.
func ServeIP ¶
ServeIP returns the IP to bind to in Listen. It tries to find an IP that can be used by other machines to reach this machine. Order is by DialIP and ListenIP
func SplitHostPort ¶
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. Different to net.SplitHostPort, host or port can be not set
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 TcpKeepAliveListener ¶
TcpKeepAliveListener sets TCP keep-alive timeouts on accepted connections. It's used by ListenAndServe and ListenAndServeTLS so dead TCP connections (e.g. closing laptop mid-download) eventually go away.
Types ¶
type MultiListener ¶
type MultiListener struct { *NotifyListener // ErrorLog specifies an optional logger for errors accepting // connections, unexpected behavior from handlers, and // underlying FileSystem errors. // If nil, logging is done via the log package's standard logger. ErrorLog *log.Logger // contains filtered or unexported fields }
MultiListener is a net.Listener that accepts all the connections from all listeners.
func NewMultiListener ¶
func NewMultiListener(listeners ...net.Listener) *MultiListener
func (*MultiListener) Addr ¶
func (l *MultiListener) Addr() net.Addr
Addr returns the listener's network address.
func (*MultiListener) Close ¶
func (l *MultiListener) Close() error
type NotifyListener ¶
func NewNotifyListener ¶
func NewNotifyListener() *NotifyListener
NewNotifyListener creates a new Listener that will recv conns on its channel.
func (*NotifyListener) Addr ¶
func (l *NotifyListener) Addr() net.Addr
Addr returns the listener's network address.
func (*NotifyListener) Close ¶
func (l *NotifyListener) Close() error
Stop prevents the NotifyListener from firing. To ensure the channel is empty after a call to Close, check the return value and drain the channel.
func (*NotifyListener) DoneC ¶
func (l *NotifyListener) DoneC() <-chan struct{}
DoneC returns whether this listener has been closed for multi producers of C
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
https://tools.ietf.org/html/rfc7064 https://tools.ietf.org/html/rfc7064 3.2.
|
https://tools.ietf.org/html/rfc7064 https://tools.ietf.org/html/rfc7064 3.2. |
Package mux is a library to multiplex network connections based on their payload.
|
Package mux is a library to multiplex network connections based on their payload. |
unix
Package unix implements a resolver for unix targets.
|
Package unix implements a resolver for unix targets. |