mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Only pass the context in pollmap, no req needed
This commit is contained in:
parent
52073ce7c9
commit
204dedaa49
3 changed files with 6 additions and 6 deletions
|
@ -22,7 +22,7 @@ const machineNameContextKey = contextKey("machineName")
|
||||||
// managed the poll loop.
|
// managed the poll loop.
|
||||||
func (h *Headscale) handlePollCommon(
|
func (h *Headscale) handlePollCommon(
|
||||||
writer http.ResponseWriter,
|
writer http.ResponseWriter,
|
||||||
req *http.Request,
|
ctx context.Context,
|
||||||
machine *Machine,
|
machine *Machine,
|
||||||
mapRequest tailcfg.MapRequest,
|
mapRequest tailcfg.MapRequest,
|
||||||
isNoise bool,
|
isNoise bool,
|
||||||
|
@ -201,7 +201,7 @@ func (h *Headscale) handlePollCommon(
|
||||||
|
|
||||||
h.pollNetMapStream(
|
h.pollNetMapStream(
|
||||||
writer,
|
writer,
|
||||||
req,
|
ctx,
|
||||||
machine,
|
machine,
|
||||||
mapRequest,
|
mapRequest,
|
||||||
pollDataChan,
|
pollDataChan,
|
||||||
|
@ -221,7 +221,7 @@ func (h *Headscale) handlePollCommon(
|
||||||
// ensuring we communicate updates and data to the connected clients.
|
// ensuring we communicate updates and data to the connected clients.
|
||||||
func (h *Headscale) pollNetMapStream(
|
func (h *Headscale) pollNetMapStream(
|
||||||
writer http.ResponseWriter,
|
writer http.ResponseWriter,
|
||||||
req *http.Request,
|
ctxReq context.Context,
|
||||||
machine *Machine,
|
machine *Machine,
|
||||||
mapRequest tailcfg.MapRequest,
|
mapRequest tailcfg.MapRequest,
|
||||||
pollDataChan chan []byte,
|
pollDataChan chan []byte,
|
||||||
|
@ -232,7 +232,7 @@ func (h *Headscale) pollNetMapStream(
|
||||||
h.pollNetMapStreamWG.Add(1)
|
h.pollNetMapStreamWG.Add(1)
|
||||||
defer h.pollNetMapStreamWG.Done()
|
defer h.pollNetMapStreamWG.Done()
|
||||||
|
|
||||||
ctx := context.WithValue(req.Context(), machineNameContextKey, machine.Hostname)
|
ctx := context.WithValue(ctxReq, machineNameContextKey, machine.Hostname)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
@ -90,5 +90,5 @@ func (h *Headscale) PollNetMapHandler(
|
||||||
Str("machine", machine.Hostname).
|
Str("machine", machine.Hostname).
|
||||||
Msg("A machine is entering polling via the legacy protocol")
|
Msg("A machine is entering polling via the legacy protocol")
|
||||||
|
|
||||||
h.handlePollCommon(writer, req, machine, mapRequest, false)
|
h.handlePollCommon(writer, req.Context(), machine, mapRequest, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,5 +63,5 @@ func (h *Headscale) NoisePollNetMapHandler(
|
||||||
Str("machine", machine.Hostname).
|
Str("machine", machine.Hostname).
|
||||||
Msg("A machine is entering polling via the Noise protocol")
|
Msg("A machine is entering polling via the Noise protocol")
|
||||||
|
|
||||||
h.handlePollCommon(writer, req, machine, mapRequest, true)
|
h.handlePollCommon(writer, req.Context(), machine, mapRequest, true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue