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
|
||||
func (n *network) UnmarshalText(data []byte) error {
|
||||
_, ipnet, err := net.ParseCIDR(string(data))
|
||||
ip, ipnet, err := net.ParseCIDR(string(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ipnet.IP = ip
|
||||
*n = network(*ipnet)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -64,12 +64,14 @@ func (s *State) assignOverlayAddr(ipnet *net.IPNet, name string) {
|
|||
ip := make([]byte, len(ipnet.IP))
|
||||
copy(ip, []byte(ipnet.IP))
|
||||
|
||||
h := fnv.New128a()
|
||||
h.Write([]byte(name))
|
||||
hb := h.Sum(nil)
|
||||
if ipnet.IP.Mask(ipnet.Mask).Equal(ipnet.IP) {
|
||||
h := fnv.New128a()
|
||||
h.Write([]byte(name))
|
||||
hb := h.Sum(nil)
|
||||
|
||||
for i := 1; i <= (size-bits)/8; i++ {
|
||||
ip[len(ip)-i] = hb[len(hb)-i]
|
||||
for i := 1; i <= (size-bits)/8; i++ {
|
||||
ip[len(ip)-i] = hb[len(hb)-i]
|
||||
}
|
||||
}
|
||||
|
||||
s.OverlayAddr = net.IPNet{
|
||||
|
|
Loading…
Reference in New Issue