Skip to content

Commit

Permalink
Add forced approval of a node if it is registered via CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
hopleus committed Oct 7, 2024
1 parent 2bf5519 commit 3a7d361
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hscontrol/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (h *Headscale) handleAuthKey(
ctx := types.NotifyCtx(context.Background(), "handle-authkey", "na")
h.nodeNotifier.NotifyAll(ctx, types.StateUpdate{Type: types.StatePeerChanged, ChangeNodes: []types.NodeID{node.ID}})
} else {
now := time.Now().UTC()
now := time.Now()
var authorize *time.Time

if pak.Preauthorized {
Expand Down
5 changes: 5 additions & 0 deletions hscontrol/db/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ func (hsdb *HSDatabase) RegisterNodeFromAuthCallback(
node.Expiry = nodeExpiry
}

if registrationMethod == util.RegisterMethodCLI && node.Authorize == nil {
now := time.Now()
node.Authorize = &now
}

node, err := RegisterNode(
tx,
node,
Expand Down

0 comments on commit 3a7d361

Please sign in to comment.