Documentation ¶
Overview ¶
Package net provides tools for reading IPs, available Ports, extending HTTP requests, etc.
Index ¶
- Variables
- func BodyWithProgressMonitor(resp *http.Response, progress chan float64, done chan bool) io.Reader
- func CheckPortAvailability(port string) (err error)
- func DetectHasPrivateIP() (bool, string, error)
- func ExternalDomainFromRequest(r *net_http.Request) *url.URL
- func GetAvailableIPs() (ips []net.IP, e error)
- func GetAvailablePort() int
- func GetExternalIP() (net.IP, error)
- func GetOutboundIP() (net.IP, error)
- func GetTimeFromNtp() (time.Time, error)
- func HostsFileLookup() ([]string, error)
- func PeerAddressIsLocal(address string) bool
- func PeerAddressesAreSameNode(a1, a2 string) bool
- type ProgressMonitor
Constants ¶
This section is empty.
Variables ¶
var (
DefaultAdvertiseAddress string
)
Functions ¶
func BodyWithProgressMonitor ¶
BodyWithProgressMonitor creates a ProgressMonitor directly from an http.Response
func CheckPortAvailability ¶
CheckPortAvailability - check if given port is already in use. Note: The check method tries to listen on given port and closes it. It is possible to have a disconnected client in this tiny window of time.
func DetectHasPrivateIP ¶
func ExternalDomainFromRequest ¶
ExternalDomainFromRequest finds external URL based on request fields or headers
func GetAvailableIPs ¶
GetExternalIP retrieves the preferred outbound ip of this machine by scanning the network interfaces of this (virtual) machine
func GetAvailablePort ¶
func GetAvailablePort() int
GetAvailablePort finds an available TCP port on which to listen to.
func GetExternalIP ¶
GetExternalIP retrieves the preferred outbound ip of this machine by scanning the network interfaces of this (virtual) machine
func GetOutboundIP ¶
GetOutboundIP restrieves the preferred outbound ip of this machine by simply connecting to a well known ip of the internet.
func GetTimeFromNtp ¶
func HostsFileLookup ¶
HostsFileLookup loads host defined in /etc/hosts using jaytaylor/go-hostsfile library
func PeerAddressIsLocal ¶
PeerAddressIsLocal compares and address (can be an IP or Hostname) to the current server values
func PeerAddressesAreSameNode ¶
PeerAddressesAreSameNode compares two addresses composed of multiple segments (separated by |) and check if any segments are similar
Types ¶
type ProgressMonitor ¶
type ProgressMonitor struct { SizeChan chan uint64 // contains filtered or unexported fields }
ProgressMonitor provides a TeeReader to wrap a reader and send a progress inside a dedicated channel
func NewProgressMonitor ¶
func NewProgressMonitor(expected uint64, progress chan float64, done chan bool) *ProgressMonitor
NewProgressMonitor initialize a ProgressMonitor with the channels