Documentation ¶
Overview ¶
Package network provides network-related utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveAddresses ¶
ActiveAddresses determines the best address for each active network interface. IPv4 addresses will be selected over IPv6 addresses on the same interface. Numeric addresses are resolved into names where possible.
func Address ¶
Address returns the best address for the network interface. IPv4 addresses will be selected over IPv6 addresses on the same interface. Numeric addresses are resolved into names where possible. An empty string will be returned if the network interface cannot be resolved into an IPv4 or IPv6 address.
func AddressesForHost ¶
AddressesForHost returns the addresses/names for the given host. If an IP number is passed in, then it will be returned. If a host name is passed in, the host name plus the IP address(es) it resolves to will be returned. If the empty string is passed in, then the host names and IP addresses for all active interfaces will be returned.
func ExternalIP ¶ added in v1.2.2
ExternalIP returns your IP address as seen by external sites. It does this by iterating through a list of websites that will return your IP address as they see it. The first response with a valid IP address will be returned. timeout sets the maximum amount of time for each attempt.
func PrimaryAddress ¶
func PrimaryAddress() (hostname, ipAddress, macAddress string)
PrimaryAddress returns the primary hostname and its associated IP address and MAC address.
func PrimaryIPAddress ¶
func PrimaryIPAddress() string
PrimaryIPAddress returns the primary IP address.
Types ¶
type TCPKeepAliveListener ¶
type TCPKeepAliveListener struct {
*net.TCPListener
}
TCPKeepAliveListener sets TCP keep-alive timeouts on accepted connections so that dead TCP connections (e.g. closing laptop mid-download) eventually go away. This code was mostly copied from the http package, with changes to make it publicly accessible and to check some errors that were ignored.
Directories ¶
Path | Synopsis |
---|---|
Package natpmp provides an implementation of NAT-PMP.
|
Package natpmp provides an implementation of NAT-PMP. |
Package xhttp provides HTTP-related utilities.
|
Package xhttp provides HTTP-related utilities. |
web
Package web provides a web server with some standardized logging and handler wrapping.
|
Package web provides a web server with some standardized logging and handler wrapping. |