From 592a0d60c654e1e24d5a42f0578ca31ada002cab Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 18 Jan 2026 14:49:42 -0800 Subject: [PATCH] Reorder websocket disconnect message --- olm/olm.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/olm/olm.go b/olm/olm.go index 7476561..12f804a 100644 --- a/olm/olm.go +++ b/olm/olm.go @@ -480,7 +480,12 @@ func (o *Olm) StartTunnel(config TunnelConfig) { func (o *Olm) Close() { // send a disconnect message to the cloud to show disconnected - o.websocket.SendMessage("olm/disconnecting", map[string]any{}) + if o.websocket != nil { + o.websocket.SendMessage("olm/disconnecting", map[string]any{}) + // Close the websocket connection after sending disconnect + _ = o.websocket.Close() + o.websocket = nil + } // Restore original DNS configuration // we do this first to avoid any DNS issues if something else gets stuck @@ -567,12 +572,7 @@ func (o *Olm) StopTunnel() error { time.Sleep(200 * time.Millisecond) } - // Close the websocket connection - if o.websocket != nil { - _ = o.websocket.Close() - o.websocket = nil - } - + // Close() will handle sending disconnect message and closing websocket o.Close() // Reset the connected state