Documentation ¶
Overview ¶
Package publicAddress contains a utility to retrieve the callers public IP address.
Index ¶
Constants ¶
const (
DefaultPollTimeout = 65 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func GetIP ¶
GetIP returns the caller's public IPv4 address. Multiple services are checked until one returns an IP address or the time out is reached.
func GetIpOverride ¶
GetIpOverride returns the public IP of the caller or the override IP, if it is supplied. If overrideIP is empty, then the caller's IP is looked up, joined with the port, and returned. If the overrideIP is supplied, then it is joined with the port and returned. If the overrideIP has a port, then it is returned as is.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service structure contains the URL to an IP lookup Service and which IP version it returns.
func MakeTestLookupService ¶
MakeTestLookupService creates a test server and service list containing the IP of that server. The server will respond with the provided address. This function is intended for testing only so that tests do not need to reach an external service to function. Once the returned server is used, it should be closed using ts.Close().