mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 16:07: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
19
machine.go
19
machine.go
@ -744,24 +744,28 @@ func (h *Headscale) toNode(
|
|||||||
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),
|
User: tailcfg.UserID(machine.UserID),
|
||||||
|
|
||||||
Key: nodeKey,
|
Key: nodeKey,
|
||||||
KeyExpiry: keyExpiry,
|
KeyExpiry: keyExpiry,
|
||||||
|
|
||||||
Machine: machineKey,
|
Machine: machineKey,
|
||||||
DiscoKey: discoKey,
|
DiscoKey: discoKey,
|
||||||
Addresses: addrs,
|
Addresses: addrs,
|
||||||
AllowedIPs: allowedIPs,
|
AllowedIPs: allowedIPs,
|
||||||
PrimaryRoutes: primaryPrefixes,
|
|
||||||
Endpoints: machine.Endpoints,
|
Endpoints: machine.Endpoints,
|
||||||
DERP: derp,
|
DERP: derp,
|
||||||
|
|
||||||
Online: &online,
|
|
||||||
Hostinfo: hostInfo.View(),
|
Hostinfo: hostInfo.View(),
|
||||||
Created: machine.CreatedAt,
|
Created: machine.CreatedAt,
|
||||||
LastSeen: machine.LastSeen,
|
|
||||||
|
|
||||||
|
PrimaryRoutes: primaryPrefixes,
|
||||||
|
|
||||||
|
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