allocate IP to peer
This commit is contained in:
parent
faf0e59887
commit
af7484c84b
14
add.go
14
add.go
@ -1,5 +1,9 @@
|
|||||||
package dsnet
|
package dsnet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
func Add(hostname string, owner string, description string) { //, publicKey string) {
|
func Add(hostname string, owner string, description string) { //, publicKey string) {
|
||||||
conf := MustLoadDsnetConfig()
|
conf := MustLoadDsnetConfig()
|
||||||
|
|
||||||
@ -8,7 +12,6 @@ func Add(hostname string, owner string, description string) { //, publicKey stri
|
|||||||
publicKey := privateKey.PublicKey()
|
publicKey := privateKey.PublicKey()
|
||||||
|
|
||||||
IP, err := conf.ChooseIP()
|
IP, err := conf.ChooseIP()
|
||||||
|
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
peer := PeerConfig{
|
peer := PeerConfig{
|
||||||
@ -18,7 +21,14 @@ func Add(hostname string, owner string, description string) { //, publicKey stri
|
|||||||
PublicKey: publicKey,
|
PublicKey: publicKey,
|
||||||
PresharedKey: presharedKey,
|
PresharedKey: presharedKey,
|
||||||
// TODO Endpoint:
|
// TODO Endpoint:
|
||||||
// TODO pick an available IP AllowedIPs
|
AllowedIPs: []JSONIPNet{
|
||||||
|
JSONIPNet {
|
||||||
|
IPNet: net.IPNet{
|
||||||
|
IP: IP,
|
||||||
|
Mask: conf.Network.IPNet.Mask,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.MustAddPeer(peer)
|
conf.MustAddPeer(peer)
|
||||||
|
Loading…
Reference in New Issue
Block a user