mirror of
https://github.com/fosrl/newt.git
synced 2026-02-28 15:56:40 +00:00
Change terminate to reconnect
This commit is contained in:
13
main.go
13
main.go
@@ -387,8 +387,8 @@ persistent_keepalive_interval=5`, fixKey(privateKey.String()), fixKey(wgData.Pub
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
client.RegisterHandler("newt/wg/terminate", func(msg websocket.WSMessage) {
|
client.RegisterHandler("newt/wg/reconnect", func(msg websocket.WSMessage) {
|
||||||
logger.Info("Received disconnect message")
|
logger.Info("Received reconnect message")
|
||||||
|
|
||||||
if pingStopChan != nil {
|
if pingStopChan != nil {
|
||||||
// Stop the ping check
|
// Stop the ping check
|
||||||
@@ -419,6 +419,15 @@ persistent_keepalive_interval=5`, fixKey(privateKey.String()), fixKey(wgData.Pub
|
|||||||
// Mark as disconnected
|
// Mark as disconnected
|
||||||
connected = false
|
connected = false
|
||||||
|
|
||||||
|
// start asking for the exit nodes again
|
||||||
|
if stopFunc != nil {
|
||||||
|
stopFunc() // stop the ws from sending more requests
|
||||||
|
stopFunc = nil // reset stopFunc to nil to avoid double stopping
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request exit nodes from the server
|
||||||
|
stopFunc = client.SendMessageInterval("newt/ping/request", map[string]interface{}{}, 3*time.Second)
|
||||||
|
|
||||||
logger.Info("Tunnel destroyed, ready for reconnection")
|
logger.Info("Tunnel destroyed, ready for reconnection")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user