Ejemplo n.º 1
0
// Return the IPv4 address of a network interface
func GetIfaceAddr(name string) (*net.IPNet, error) {
	iface, err := netlink.LinkByName(name)
	if err != nil {
		return nil, err
	}

	addrs, err := netlink.AddrList(iface, netlink.FAMILY_V4)
	if err != nil {
		return nil, err
	}

	if len(addrs) == 0 {
		return nil, fmt.Errorf("Interface %v has no IP addresses", name)
	}

	if len(addrs) > 1 {
		log.Info("Interface %v has more than 1 IPv4 address. Defaulting to using %v\n", name, addrs[0].IP)
	}

	return addrs[0].IPNet, nil
}
Ejemplo n.º 2
0
func (n notify) RemoveMember(addr net.IP) {
	log.Info("Member Left : ", addr)
	DeletePeer(addr.String())
}
Ejemplo n.º 3
0
func (n notify) NewMember(addr net.IP) {
	log.Info("New Member Added : ", addr)
	JoinDatastore(addr.String())
	AddPeer(addr.String())
}