dsnet/add.go
2020-03-02 03:08:28 +00:00

23 lines
495 B
Go

package dsnet
func Add(hostname string, owner string, description string) {//, publicKey string) {
conf := MustLoadDsnetConfig()
privateKey := GenerateJSONPrivateKey()
presharedKey := GenerateJSONKey()
publicKey := privateKey.PublicKey()
peer := PeerConfig{
Owner: owner,
Hostname: hostname,
Description: description,
PublicKey: publicKey,
PresharedKey: presharedKey,
// TODO Endpoint:
// TODO pick an available IP AllowedIPs
}
conf.MustAddPeer(peer)
conf.MustSave()
}