Skip to content

Commit

Permalink
fix panic if derp update is 0 (#2368)
Browse files Browse the repository at this point in the history
* fix panic if derp update is 0

Fixes #2362

Signed-off-by: Kristoffer Dalby <[email protected]>

* update changelog

Signed-off-by: Kristoffer Dalby <[email protected]>

---------

Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby authored Jan 23, 2025
1 parent 9e3f945 commit d1dbe4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
[#2364](https://github.com/juanfont/headscale/pull/2364)
- Remove invalid routes and add stronger constraints for routes to avoid API panic
[#2371](https://github.com/juanfont/headscale/pull/2371)
- Fix panic when `derp.update_frequency` is 0
[#2368](https://github.com/juanfont/headscale/pull/2368)

## 0.24.0 (2025-01-17)

Expand Down
12 changes: 6 additions & 6 deletions hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ func (h *Headscale) scheduledTasks(ctx context.Context) {

lastExpiryCheck := time.Unix(0, 0)

derpTicker := time.NewTicker(h.cfg.DERP.UpdateFrequency)
defer derpTicker.Stop()
// If we dont want auto update, just stop the ticker
if !h.cfg.DERP.AutoUpdate {
derpTicker.Stop()
derpTickerChan := make(<-chan time.Time)
if h.cfg.DERP.AutoUpdate && h.cfg.DERP.UpdateFrequency != 0 {
derpTicker := time.NewTicker(h.cfg.DERP.UpdateFrequency)
defer derpTicker.Stop()
derpTickerChan = derpTicker.C
}

var extraRecordsUpdate <-chan []tailcfg.DNSRecord
Expand Down Expand Up @@ -285,7 +285,7 @@ func (h *Headscale) scheduledTasks(ctx context.Context) {
h.nodeNotifier.NotifyAll(ctx, update)
}

case <-derpTicker.C:
case <-derpTickerChan:
log.Info().Msg("Fetching DERPMap updates")
h.DERPMap = derp.GetDERPMap(h.cfg.DERP)
if h.cfg.DERP.ServerEnabled && h.cfg.DERP.AutomaticallyAddEmbeddedDerpRegion {
Expand Down

0 comments on commit d1dbe4e

Please sign in to comment.