Allow specific address to be specified
This commit is contained in:
parent
f8fc765936
commit
a52d693f56
|
@ -85,10 +85,11 @@ type network net.IPNet
|
||||||
|
|
||||||
// UnmarshalText parses the provided byte array into the network receiver
|
// UnmarshalText parses the provided byte array into the network receiver
|
||||||
func (n *network) UnmarshalText(data []byte) error {
|
func (n *network) UnmarshalText(data []byte) error {
|
||||||
_, ipnet, err := net.ParseCIDR(string(data))
|
ip, ipnet, err := net.ParseCIDR(string(data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
ipnet.IP = ip
|
||||||
*n = network(*ipnet)
|
*n = network(*ipnet)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,12 +64,14 @@ func (s *State) assignOverlayAddr(ipnet *net.IPNet, name string) {
|
||||||
ip := make([]byte, len(ipnet.IP))
|
ip := make([]byte, len(ipnet.IP))
|
||||||
copy(ip, []byte(ipnet.IP))
|
copy(ip, []byte(ipnet.IP))
|
||||||
|
|
||||||
h := fnv.New128a()
|
if ipnet.IP.Mask(ipnet.Mask).Equal(ipnet.IP) {
|
||||||
h.Write([]byte(name))
|
h := fnv.New128a()
|
||||||
hb := h.Sum(nil)
|
h.Write([]byte(name))
|
||||||
|
hb := h.Sum(nil)
|
||||||
|
|
||||||
for i := 1; i <= (size-bits)/8; i++ {
|
for i := 1; i <= (size-bits)/8; i++ {
|
||||||
ip[len(ip)-i] = hb[len(hb)-i]
|
ip[len(ip)-i] = hb[len(hb)-i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.OverlayAddr = net.IPNet{
|
s.OverlayAddr = net.IPNet{
|
||||||
|
|
Loading…
Reference in New Issue