Documentation
¶
Index ¶
- func AllocateHostPort(ip string, minPort, maxPort int, skip func(port string) bool) string
- func BaseURLFromFullURL(fullURL string) string
- func GetLocalIPs() ([]string, error)
- func HasLocalIP(ipAddresses []net.IP) bool
- func IsHostPortFree(ip string, port int) bool
- func IsPortActive(port string) bool
- func IsPortUnreachable(port string) bool
- func NormalizeURL(rawURL string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateHostPort ¶ added in v1.25.5
AllocateHostPort returns a port in [minPort, maxPort] that is free on ip and not rejected by skip, scanning from a random offset so concurrent callers are unlikely to try the same port first. It returns "" when ip can't be bound locally (for example a remote Docker host), or when no port qualifies.
func BaseURLFromFullURL ¶ added in v1.23.5
BaseURLFromFullURL returns the base url (http://hostname.example.com) from a URL, without port
func GetLocalIPs ¶ added in v1.23.3
GetLocalIPs returns IP addresses associated with the machine
func HasLocalIP ¶ added in v1.23.5
HasLocalIP returns true if at least one of the provided IP addresses is assigned to the local computer
func IsHostPortFree ¶ added in v1.25.5
IsHostPortFree reports whether a TCP listener can bind ip:port right now. It binds instead of dialing, so on Linux it also catches a port held by a socket that isn't listening, such as the local end of an outgoing connection.
func IsPortActive ¶
IsPortActive checks to see if the given port on Docker IP is answering.
func IsPortUnreachable ¶ added in v1.25.6
IsPortUnreachable reports whether an HTTP port on a loopback Docker IP is unreachable: the connection is refused, or it is accepted and then closed or reset before any response, as Docker Desktop's port forwarding does when its target is stale. It returns false for anything less certain, such as a timeout or a Docker host that isn't on loopback.
func NormalizeURL ¶ added in v1.24.3
NormalizeURL removes the port from a URL if it is the default port for the scheme
Types ¶
This section is empty.