correct IPAllocated()
This commit is contained in:
parent
e0f753d3d0
commit
cf93b219a1
1
add.go
1
add.go
@ -12,7 +12,6 @@ func Add(hostname string, owner string, description string) { //, publicKey stri
|
|||||||
publicKey := privateKey.PublicKey()
|
publicKey := privateKey.PublicKey()
|
||||||
|
|
||||||
IP := conf.MustChooseIP()
|
IP := conf.MustChooseIP()
|
||||||
check(err)
|
|
||||||
|
|
||||||
peer := PeerConfig{
|
peer := PeerConfig{
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
|
7
types.go
7
types.go
@ -2,7 +2,6 @@ package dsnet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@ -88,7 +87,7 @@ func (conf *DsnetConfig) MustAddPeer(peer PeerConfig) {
|
|||||||
|
|
||||||
for _, peerIPNet := range peer.AllowedIPs {
|
for _, peerIPNet := range peer.AllowedIPs {
|
||||||
if conf.IPAllocated(peerIPNet.IPNet.IP) {
|
if conf.IPAllocated(peerIPNet.IPNet.IP) {
|
||||||
ExitFail("%s is not unique", peerIPNet)
|
ExitFail("%s is already allocated", peerIPNet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +98,12 @@ func (conf DsnetConfig) IPAllocated(IP net.IP) bool {
|
|||||||
for _, peer := range conf.Peers {
|
for _, peer := range conf.Peers {
|
||||||
for _, peerIPNet := range peer.AllowedIPs {
|
for _, peerIPNet := range peer.AllowedIPs {
|
||||||
if IP.Equal(peerIPNet.IPNet.IP) {
|
if IP.Equal(peerIPNet.IPNet.IP) {
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// choose a free IP for a new Peer
|
// choose a free IP for a new Peer
|
||||||
|
Loading…
Reference in New Issue
Block a user