mirror of
https://github.com/fosrl/olm.git
synced 2026-02-24 13:56:44 +00:00
Add ping for connectivity monitoring
This commit is contained in:
9
main.go
9
main.go
@@ -135,6 +135,7 @@ func main() {
|
||||
|
||||
stopHolepunch = make(chan struct{})
|
||||
stopRegister = make(chan struct{})
|
||||
stopPing = make(chan struct{})
|
||||
|
||||
// if PANGOLIN_ENDPOINT, OLM_ID, and OLM_SECRET are set as environment variables, they will be used as default values
|
||||
endpoint = os.Getenv("PANGOLIN_ENDPOINT")
|
||||
@@ -473,6 +474,7 @@ func main() {
|
||||
logger.Debug("Public key: %s", publicKey)
|
||||
|
||||
go keepSendingRegistration(olm, publicKey.String())
|
||||
go keepSendingPing(olm)
|
||||
|
||||
logger.Info("Sent registration message")
|
||||
return nil
|
||||
@@ -509,6 +511,13 @@ func main() {
|
||||
close(stopRegister)
|
||||
}
|
||||
|
||||
select {
|
||||
case <-stopPing:
|
||||
// Channel already closed
|
||||
default:
|
||||
close(stopPing)
|
||||
}
|
||||
|
||||
uapi.Close()
|
||||
dev.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user