Added support for DiscoKey

(from https://github.com/awsong/headscale)
This commit is contained in:
Juan Font Alonso 2021-02-21 21:34:28 +01:00
parent acb645aa9d
commit 272eee79fd
2 changed files with 8 additions and 2 deletions

View file

@ -16,6 +16,7 @@ type Machine struct {
ID uint64 `gorm:"primary_key"`
MachineKey string `gorm:"type:varchar(64);unique_index"`
NodeKey string
DiscoKey string
IPAddress string
Registered bool // temp
@ -44,6 +45,10 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
if err != nil {
return nil, err
}
dKey, err := wgcfg.ParseHexKey(m.DiscoKey)
if err != nil {
return nil, err
}
addrs := []netaddr.IPPrefix{}
allowedIPs := []netaddr.IPPrefix{}
@ -81,6 +86,7 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
Key: tailcfg.NodeKey(nKey),
KeyExpiry: *m.Expiry,
Machine: tailcfg.MachineKey(mKey),
DiscoKey: tailcfg.DiscoKey(dKey),
Addresses: addrs,
AllowedIPs: allowedIPs,
Endpoints: endpoints,