Skip to content

Commit

Permalink
make sure endpoint is sent out
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Sep 10, 2023
1 parent 61116ad commit 2ae36a2
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,27 @@ func (h *Headscale) handlePoll(
// In this case, the server can omit the entire response; the client
// only checks the HTTP response status code.
if mapRequest.OmitPeers && !mapRequest.Stream && !mapRequest.ReadOnly {
logInfo("Received endpoint update")
log.Info().
Caller().
Bool("noise", isNoise).
Bool("readOnly", mapRequest.ReadOnly).
Bool("omitPeers", mapRequest.OmitPeers).
Bool("stream", mapRequest.Stream).
Str("node_key", machine.NodeKey).
Str("machine", machine.Hostname).
Strs("endpoints", machine.Endpoints).
Msg("Received endpoint update")

now := time.Now().UTC()
machine.Endpoints = mapRequest.Endpoints
machine.LastSeen = &now

// if err := h.db.MachineSave(machine); err != nil {
// logErr(err, "Failed to persist/update machine in the database")
// http.Error(writer, "", http.StatusInternalServerError)
//
// return
// }
if err := h.db.MachineSave(machine); err != nil {
logErr(err, "Failed to persist/update machine in the database")
http.Error(writer, "", http.StatusInternalServerError)

return
}

h.nodeNotifier.NotifyWithIgnore(
types.StateUpdate{
Expand Down Expand Up @@ -128,6 +137,7 @@ func (h *Headscale) handlePoll(
machine.Hostname = mapRequest.Hostinfo.Hostname
machine.HostInfo = types.HostInfo(*mapRequest.Hostinfo)
machine.DiscoKey = util.DiscoPublicKeyStripPrefix(mapRequest.DiscoKey)
machine.Endpoints = mapRequest.Endpoints

// When a node connects to control, list the peers it has at
// that given point, further updates are kept in memory in
Expand Down

0 comments on commit 2ae36a2

Please sign in to comment.