Documentation
¶
Overview ¶
Package loopback reports whether the host has loopback addresses beyond 127.0.0.1 (ADR 0005). Linux routes all of 127.0.0.0/8 to loopback; a macOS host has only 127.0.0.1 on lo0 until `gcpemu loopback install` adds aliases for 127.0.0.2 to 127.0.0.254.
Index ¶
Constants ¶
const DarwinPorts = goruntime.GOOS == "darwin"
DarwinPorts is set on macOS, which lets an unprivileged process bind a port below 1024 only on the wildcard address.
const Host = "127.0.0.1"
Host is the one loopback address every host has.
const InstallHint = "sudo gcpemu loopback install"
InstallHint is the command that adds the aliases on a host without them.
Variables ¶
This section is empty.
Functions ¶
func AddrInUse ¶
AddrInUse reports whether err is a bind failing because another socket holds the address.
func Aliases ¶
func Aliases() bool
Aliases reports whether 127.0.0.x addresses other than 127.0.0.1 can be bound, by binding 127.0.0.2:0.
func BindDenied ¶
BindDenied reports whether err is a bind refused for lack of permission, such as a privileged port.
func IsLoopback ¶
IsLoopback reports whether a is a loopback TCP address.
func Listen ¶
Listen binds ip:port for host clients. When the host refuses the port as privileged, it binds the wildcard address on the port on macOS, serving only connections to a loopback address, and otherwise (or when another socket holds the wildcard) a free port on ip. When another socket holds ip:port, it binds a free port on ip if inUse is set, and fails otherwise. addr is the address clients use: ip and the port served.
Types ¶
type LocalFilter ¶
LocalFilter serves only the connections whose local address Allow accepts, and closes the others unserved. It keeps a wildcard listener from serving clients on other hosts.