mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 07:57:34 +00:00
Sort tailcfg.Node creation as upstream
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
4183345020
commit
a840a2e6ee
41
machine.go
41
machine.go
@ -743,25 +743,29 @@ func (h *Headscale) toNode(
|
|||||||
StableID: tailcfg.StableNodeID(
|
StableID: tailcfg.StableNodeID(
|
||||||
strconv.FormatUint(machine.ID, Base10),
|
strconv.FormatUint(machine.ID, Base10),
|
||||||
), // in headscale, unlike tailcontrol server, IDs are permanent
|
), // in headscale, unlike tailcontrol server, IDs are permanent
|
||||||
Name: hostname,
|
Name: hostname,
|
||||||
User: tailcfg.UserID(machine.UserID),
|
|
||||||
Key: nodeKey,
|
User: tailcfg.UserID(machine.UserID),
|
||||||
KeyExpiry: keyExpiry,
|
|
||||||
Machine: machineKey,
|
Key: nodeKey,
|
||||||
DiscoKey: discoKey,
|
KeyExpiry: keyExpiry,
|
||||||
Addresses: addrs,
|
|
||||||
AllowedIPs: allowedIPs,
|
Machine: machineKey,
|
||||||
|
DiscoKey: discoKey,
|
||||||
|
Addresses: addrs,
|
||||||
|
AllowedIPs: allowedIPs,
|
||||||
|
Endpoints: machine.Endpoints,
|
||||||
|
DERP: derp,
|
||||||
|
Hostinfo: hostInfo.View(),
|
||||||
|
Created: machine.CreatedAt,
|
||||||
|
|
||||||
PrimaryRoutes: primaryPrefixes,
|
PrimaryRoutes: primaryPrefixes,
|
||||||
Endpoints: machine.Endpoints,
|
|
||||||
DERP: derp,
|
|
||||||
|
|
||||||
Online: &online,
|
|
||||||
Hostinfo: hostInfo.View(),
|
|
||||||
Created: machine.CreatedAt,
|
|
||||||
LastSeen: machine.LastSeen,
|
|
||||||
|
|
||||||
|
LastSeen: machine.LastSeen,
|
||||||
|
Online: &online,
|
||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
MachineAuthorized: !machine.isExpired(),
|
MachineAuthorized: !machine.isExpired(),
|
||||||
|
|
||||||
Capabilities: []string{
|
Capabilities: []string{
|
||||||
tailcfg.CapabilityFileSharing,
|
tailcfg.CapabilityFileSharing,
|
||||||
tailcfg.CapabilityAdmin,
|
tailcfg.CapabilityAdmin,
|
||||||
@ -1112,7 +1116,8 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
|||||||
routes := []Route{}
|
routes := []Route{}
|
||||||
err := h.db.
|
err := h.db.
|
||||||
Preload("Machine").
|
Preload("Machine").
|
||||||
Where("machine_id = ? AND advertised = true AND enabled = false", machine.ID).Find(&routes).Error
|
Where("machine_id = ? AND advertised = true AND enabled = false", machine.ID).
|
||||||
|
Find(&routes).Error
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
log.Error().
|
log.Error().
|
||||||
Caller().
|
Caller().
|
||||||
@ -1126,7 +1131,9 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
|||||||
approvedRoutes := []Route{}
|
approvedRoutes := []Route{}
|
||||||
|
|
||||||
for _, advertisedRoute := range routes {
|
for _, advertisedRoute := range routes {
|
||||||
routeApprovers, err := h.aclPolicy.AutoApprovers.GetRouteApprovers(netip.Prefix(advertisedRoute.Prefix))
|
routeApprovers, err := h.aclPolicy.AutoApprovers.GetRouteApprovers(
|
||||||
|
netip.Prefix(advertisedRoute.Prefix),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).
|
log.Err(err).
|
||||||
Str("advertisedRoute", advertisedRoute.String()).
|
Str("advertisedRoute", advertisedRoute.String()).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user