From 000f9e515dead4b3ed00bf961611ef34025f53c9 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 28 Dec 2023 01:05:15 +0100 Subject: [PATCH] Fix idle websocket connection on logout --- agent/bitwarden/websocket.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agent/bitwarden/websocket.go b/agent/bitwarden/websocket.go index 118fbad..9b1db9f 100644 --- a/agent/bitwarden/websocket.go +++ b/agent/bitwarden/websocket.go @@ -94,6 +94,16 @@ func connectToWebsocket(ctx context.Context, vault *vault.Vault, cfg *config.Con //handshake required for official bitwarden implementation c.WriteMessage(1, []byte(`{"protocol":"messagepack","version":1}`)) + go func() { + for { + time.Sleep(5 * time.Second) + if vault.Keyring.IsLocked() || cfg.IsLocked() || !cfg.IsLoggedIn() { + c.Close() + return + } + } + }() + go func() { defer close(done) for {