mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-11 18:54:25 +00:00
Fixed crash when NetInfo is nil
This commit is contained in:
parent
d0e54bd59e
commit
562e996996
@ -95,6 +95,13 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var derp string
|
||||||
|
if hostinfo.NetInfo != nil {
|
||||||
|
derp = fmt.Sprintf("127.3.3.40:%d", hostinfo.NetInfo.PreferredDERP)
|
||||||
|
} else {
|
||||||
|
derp = "127.3.3.40:0" // Zero means disconnected or unknown.
|
||||||
|
}
|
||||||
|
|
||||||
n := tailcfg.Node{
|
n := tailcfg.Node{
|
||||||
ID: tailcfg.NodeID(m.ID), // this is the actual ID
|
ID: tailcfg.NodeID(m.ID), // this is the actual ID
|
||||||
StableID: tailcfg.StableNodeID(strconv.FormatUint(m.ID, 10)), // in headscale, unlike tailcontrol server, IDs are permantent
|
StableID: tailcfg.StableNodeID(strconv.FormatUint(m.ID, 10)), // in headscale, unlike tailcontrol server, IDs are permantent
|
||||||
@ -107,7 +114,7 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
|
|||||||
Addresses: addrs,
|
Addresses: addrs,
|
||||||
AllowedIPs: allowedIPs,
|
AllowedIPs: allowedIPs,
|
||||||
Endpoints: endpoints,
|
Endpoints: endpoints,
|
||||||
DERP: fmt.Sprintf("127.3.3.40:%d", hostinfo.NetInfo.PreferredDERP),
|
DERP: derp,
|
||||||
|
|
||||||
Hostinfo: hostinfo,
|
Hostinfo: hostinfo,
|
||||||
Created: m.CreatedAt,
|
Created: m.CreatedAt,
|
||||||
|
Loading…
Reference in New Issue
Block a user