From 8263094c03a42cb7e28a59d4615fa14757959cb0 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 28 Dec 2023 11:45:36 +0100 Subject: [PATCH] Reconnect websocket on unlock --- agent/unixsocketagent.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/agent/unixsocketagent.go b/agent/unixsocketagent.go index 37561e7..a5a34fc 100644 --- a/agent/unixsocketagent.go +++ b/agent/unixsocketagent.go @@ -182,9 +182,17 @@ func StartUnixAgent(path string, runtimeConfig config.RuntimeConfig) error { } }() - if !runtimeConfig.WebsocketDisabled { - go bitwarden.RunWebsocketDaemon(ctx, vault, &cfg) - } + go func() { + if !runtimeConfig.WebsocketDisabled { + for { + // polling, switch this to signal based later + if !cfg.IsLocked() && cfg.IsLoggedIn() { + bitwarden.RunWebsocketDaemon(ctx, vault, &cfg) + } + time.Sleep(60 * time.Second) + } + } + }() if !runtimeConfig.DisableSSHAgent { vaultAgent := ssh.NewVaultAgent(vault, &cfg)