Documentation
¶
Index ¶
- Constants
- func AddressAndPort(address string, port int32) string
- func CheckPortAvailable(protocol apiv1.PortProtocol, address string, port int32, log logr.Logger) error
- func EnableStrictMruPortHandling(log logr.Logger)
- func GetEphemeralPortRange() (int, int, bool)
- func GetFreePort(protocol apiv1.PortProtocol, address string, log logr.Logger) (int32, error)
- func GetPreferredHostIps(host string) ([]net.IP, error)
- func GetProgramInstanceID() string
- func Hostname() (string, error)
- func IpToString(ip net.IP) string
- func IsBindablePort(port int) bool
- func IsEphemeralPort(port int32) bool
- func IsIPv4(address string) bool
- func IsIPv6(address string) bool
- func IsValidIP(ip net.IP) bool
- func IsValidIPv4(ip net.IP) bool
- func IsValidIPv6(ip net.IP) bool
- func IsValidPort(port int) bool
- func LookupIP(host string) ([]net.IP, error)
- func ToStandaloneAddress(address string) string
- type IpVersionPreference
Constants ¶
View Source
const ( IpVersionPreferenceNone IpVersionPreference = "None" IpVersionPreference4 IpVersionPreference = "IPv4" IpVersionPreference6 IpVersionPreference = "IPv6" Localhost = "localhost" IPv4LocalhostDefaultAddress = "127.0.0.1" IPv6LocalhostDefaultAddress = "[::1]" IPv4AllInterfaceAddress = "0.0.0.0" // Equivalent to net.IPv4zero IPv6AllInterfaceAddress = "[::]" // Equivalent to net.IPv6zero InvalidPort = 0 // Use a relatively short timeout for network operations such as IP lookup or socket open // because we are only interested in local addresses and ports, so the operation should be fast. NetworkOpTimeout = 2 * time.Second DCP_INSTANCE_ID_PREFIX = "DCP_INSTANCE_ID_PREFIX" )
View Source
const ( // Default ephemeral port range on Linux is 32768-60999. DefaultEphemeralPortRangeStart = 32768 DefaultEphemeralPortRangeEnd = 60999 )
Variables ¶
This section is empty.
Functions ¶
func AddressAndPort ¶
func CheckPortAvailable ¶
func EnableStrictMruPortHandling ¶
Used by tests, makes the use of the most recently used ports file mandatory
func GetEphemeralPortRange ¶
func GetFreePort ¶
Gets a free TCP or UDP port for a given address (defaults to localhost). Even if this method is called twice in a row, it should not return the same port.
func GetProgramInstanceID ¶
func GetProgramInstanceID() string
func IpToString ¶
func IsBindablePort ¶
func IsEphemeralPort ¶
func IsValidIPv4 ¶
func IsValidIPv6 ¶
func IsValidPort ¶
func ToStandaloneAddress ¶
Removes the brackets from an IPv6 address if they are present.
Note: in most cases an IPv6 address needs to be enclosed in brackets for disambiguation (e.g. inside URLs, whenever a port number follows). This is why inside DCP we mostly stick to bracketed IPv6 addresses. But certain APIs require a standalone address, i.e. without brackets.
Types ¶
type IpVersionPreference ¶
type IpVersionPreference string
func GetIpVersionPreference ¶
func GetIpVersionPreference() IpVersionPreference
Click to show internal directories.
Click to hide internal directories.