Fixed panic when sending keep alives to a disconnected node

This commit is contained in:
Juan Font Alonso 2021-05-15 18:12:22 +02:00
parent 93a9284d84
commit 374a6eef7e

2
api.go
View file

@ -279,12 +279,14 @@ func (h *Headscale) keepAlive(cancel chan []byte, pollData chan []byte, mKey wgc
return return
default: default:
h.pollMu.Lock()
data, err := h.getMapKeepAliveResponse(mKey, req, m) data, err := h.getMapKeepAliveResponse(mKey, req, m)
if err != nil { if err != nil {
log.Printf("Error generating the keep alive msg: %s", err) log.Printf("Error generating the keep alive msg: %s", err)
return return
} }
pollData <- *data pollData <- *data
h.pollMu.Unlock()
time.Sleep(60 * time.Second) time.Sleep(60 * time.Second)
} }
} }