Documentation ¶
Index ¶
- Constants
- func ChooseHostInterface() (net.IP, error)
- func ChooseHostInterfaceFromRoute(routes []Route, nw networkInterfacer) (net.IP, error)
- func ChooseIPFromHostInterfaces(nw networkInterfacer) (net.IP, error)
- func Command(name string, arg []string) (string, error)
- func ConvertStrToTime(strTime string) (time.Time, error)
- func GetCurPath() string
- func GetIPFromInterface(intfName string, forFamily AddressFamily, nw networkInterfacer) (net.IP, error)
- func GetMatchingGlobalIP(addrs []net.Addr, family AddressFamily) (net.IP, error)
- func IsInterfaceUp(intf *net.Interface) bool
- func IsLoopbackOrPointToPoint(intf *net.Interface) bool
- func MemberOf(ip net.IP, family AddressFamily) bool
- func NewSourcesReady() config.SourcesReady
- func ParseIP(str string, family AddressFamily) (net.IP, error)
- func ParseTimestampInt64(timestamp int64) metav1.Time
- func ParseTimestampStr2Int64(s string) (int64, error)
- func ReadDirNoStat(dirname string) ([]string, error)
- func ValidateNodeIP(nodeIP net.IP) error
- type AddressFamily
- type Route
- type RouteFile
Constants ¶
const ParseTimeErrorCode = -1
ParseTimeErrorCode is constant set to -1 to show error
Variables ¶
This section is empty.
Functions ¶
func ChooseHostInterface ¶
ChooseHostInterface is a method used fetch an IP for a daemon. If there is no routing info file, it will choose a global IP from the system interfaces. Otherwise, it will use IPv4 and IPv6 route information to return the IP of the interface with a gateway on it (with priority given to IPv4). For a node with no internet connection, it returns error.
func ChooseHostInterfaceFromRoute ¶
ChooseHostInterfaceFromRoute cycles through each default route provided, looking for a global IP address from the interface for the route. Will first look all each IPv4 route for an IPv4 IP, and then will look at each IPv6 route for an IPv6 IP.
func ChooseIPFromHostInterfaces ¶
ChooseIPFromHostInterfaces looks at all system interfaces, trying to find one that is up that has a global unicast address (non-loopback, non-link local, non-point2point), and returns the IP. Searches for IPv4 addresses, and then IPv6 addresses.
func ConvertStrToTime ¶
ConvertStrToTime converts time string object to inbuilt time object
func GetIPFromInterface ¶
func GetIPFromInterface(intfName string, forFamily AddressFamily, nw networkInterfacer) (net.IP, error)
GetIPFromInterface gets the IPs on an interface and returns a global unicast address, if any. The interface must be up, the IP must in the family requested, and the IP must be a global unicast address.
func GetMatchingGlobalIP ¶
GetMatchingGlobalIP returns the first valid global unicast address of the given 'family' from the list of 'addrs'.
func IsInterfaceUp ¶
IsInterfaceUp checks the interface is running or not
func IsLoopbackOrPointToPoint ¶
IsLoopbackOrPointToPoint checks interface is loopback or point to point
func MemberOf ¶
func MemberOf(ip net.IP, family AddressFamily) bool
MemberOf tells if the IP is of the desired family. Used for checking interface addresses.
func NewSourcesReady ¶
func NewSourcesReady() config.SourcesReady
NewSourcesReady returns a new sourceready object
func ParseIP ¶
func ParseIP(str string, family AddressFamily) (net.IP, error)
ParseIP takes the hex IP address string from route file and converts it to a net.IP address. For IPv4, the value must be converted to big endian.
func ParseTimestampInt64 ¶
ParseTimestampInt64 returns given int64 type time into matav1 type time
func ParseTimestampStr2Int64 ¶
ParseTimestampStr2Int64 returns given string time into int64 type
func ReadDirNoStat ¶
ReadDirNoStat returns a string of files/directories contained in dirname without calling lstat on them.
func ValidateNodeIP ¶
ValidateNodeIP validates given node IP belongs to the current host
Types ¶
type Route ¶
Route is to define object of connection route
func GetAllDefaultRoutes ¶
GetAllDefaultRoutes obtains IPv4 and IPv6 default routes on the node. If unable to read the IPv4 routing info file, we return an error. If unable to read the IPv6 routing info file (which is optional), we'll just use the IPv4 route information. Using all the routing info, if no default routes are found, an error is returned.
func GetIPv4DefaultRoutes ¶
GetIPv4DefaultRoutes obtains the IPv4 routes, and filters out non-default routes.