Merge master

This commit is contained in:
Kristoffer Dalby 2022-05-16 21:41:46 +02:00
commit e631c6f7e0
44 changed files with 2714 additions and 842 deletions

10
poll.go
View file

@ -20,6 +20,10 @@ const (
updateCheckInterval = 10 * time.Second
)
type contextKey string
const machineNameContextKey = contextKey("machineName")
// PollNetMapHandler takes care of /machine/:id/map
//
// This is the busiest endpoint, as it keeps the HTTP long poll that updates
@ -261,7 +265,7 @@ func (h *Headscale) PollNetMapStream(
return
}
ctx := context.WithValue(ctx.Request.Context(), "machineName", machine.Hostname)
ctx := context.WithValue(ctx.Request.Context(), machineNameContextKey, machine.Hostname)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@ -565,12 +569,12 @@ func (h *Headscale) scheduledPollWorker(
defer closeChanWithLog(
updateChan,
fmt.Sprint(ctx.Value("machineName")),
fmt.Sprint(ctx.Value(machineNameContextKey)),
"updateChan",
)
defer closeChanWithLog(
keepAliveChan,
fmt.Sprint(ctx.Value("machineName")),
fmt.Sprint(ctx.Value(machineNameContextKey)),
"updateChan",
)