diff --git a/main.go b/main.go index 5816129..380efef 100644 --- a/main.go +++ b/main.go @@ -1199,6 +1199,10 @@ persistent_keepalive_interval=5`, fixKey(privateKey.String()), fixKey(wgData.Pub logger.Info("Websocket connected") if !connected { + // make sure the stop function is called + if stopFunc != nil { + stopFunc() + } // request from the server the list of nodes to ping at newt/ping/request stopFunc = client.SendMessageInterval("newt/ping/request", map[string]interface{}{}, 3*time.Second) logger.Info("Requesting exit nodes from server") diff --git a/wgnetstack/wgnetstack.go b/wgnetstack/wgnetstack.go index 7823781..6684c40 100644 --- a/wgnetstack/wgnetstack.go +++ b/wgnetstack/wgnetstack.go @@ -399,6 +399,10 @@ func (s *WireGuardService) SetOnNetstackClose(callback func()) { } func (s *WireGuardService) LoadRemoteConfig() error { + if s.stopGetConfig != nil { + s.stopGetConfig() + s.stopGetConfig = nil + } s.stopGetConfig = s.client.SendMessageInterval("newt/wg/get-config", map[string]interface{}{ "publicKey": s.key.PublicKey().String(), "port": s.Port,