allocate IP to peer

This commit is contained in:
Callan Bryant 2020-03-02 19:13:47 +00:00
parent faf0e59887
commit af7484c84b
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA

14
add.go
View File

@ -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)