Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetIPByDomain ¶
GetIPByDomain performs a DNS lookup to retrieve the IP address associated with the provided domain. It takes the domain name as input and returns the IP address and nil error if successful, otherwise returns nil and an error.
func GetPublicIP ¶
GetPublicIP retrieves the public IP address using the default consensus and returns it. It returns the public IP address if successful, otherwise returns nil.
Types ¶
type Endpoint ¶
func ParseIPPort ¶ added in v1.2.1
ParseIpPort parses the given address and returns an Endpoint and an error. If the address is in the format "ip:port", it returns the IP and port as an Endpoint. If the address is in the format "protocol/ip4/host/udp/port", it returns the host and port as an Endpoint. If the IP provided is a loopback or unspecified IP, it replaces it with the public IP. Returns the parsed Endpoint and nil error if successful, otherwise returns nil and an error.
func ParsePeer ¶
ParsePeer parses the given address and returns an Endpoint and an error. If the address is in the format "/ip4/host/udp/port", it returns the host and port as an Endpoint. If the IP provided is a loopback or unspecified IP, it replaces it with the public IP. Returns the parsed Endpoint and nil error if successful, otherwise returns nil and an error.
func ParseURL ¶
ParseURL parses the given address and returns an Endpoint and an error. If the address does not start with "http", it adds "http://" to the beginning of the address. It then parses the address using the url.Parse function and constructs an Endpoint with the parsed information. Returns the parsed Endpoint and nil error if successful, otherwise returns nil and an error.
func (*Endpoint) GetHostWithPath ¶
GetHostWithPath returns the host with the path, if available. If the host is nil, it returns nil. Otherwise, it concatenates the host and path and returns the result. Returns a pointer to the concatenated host with the path.