aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw/commands.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-05-02 18:45:50 -0400
committerJesse Luehrs <doy@tozt.net>2020-05-02 18:59:11 -0400
commitf035ac5470c7fbcf791e361cb2d611de7edafb0f (patch)
tree8d75832af542bb27ca32163fbadc67758dde50cb /src/bin/rbw/commands.rs
parentbcf1df8dd65fb24c767ca91159fc5639dbd5375f (diff)
downloadrbw-f035ac5470c7fbcf791e361cb2d611de7edafb0f.tar.gz
rbw-f035ac5470c7fbcf791e361cb2d611de7edafb0f.zip
check protocol version before agent communication
Diffstat (limited to 'src/bin/rbw/commands.rs')
-rw-r--r--src/bin/rbw/commands.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 6c9d18c..b29987d 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -493,6 +493,30 @@ pub fn stop_agent() -> anyhow::Result<()> {
}
fn ensure_agent() -> anyhow::Result<()> {
+ ensure_agent_once()?;
+ let version = crate::actions::version()?;
+ if version != rbw::protocol::VERSION {
+ log::debug!(
+ "client protocol version is {} but agent protocol version is {}",
+ rbw::protocol::VERSION,
+ version
+ );
+ crate::actions::quit()?;
+ ensure_agent_once()?;
+ let version = crate::actions::version()?;
+ if version != rbw::protocol::VERSION {
+ crate::actions::quit()?;
+ return Err(anyhow::anyhow!(
+ "incompatible protocol versions: client ({}), agent ({})",
+ rbw::protocol::VERSION,
+ version
+ ));
+ }
+ }
+ Ok(())
+}
+
+fn ensure_agent_once() -> anyhow::Result<()> {
let agent_path = std::env::var("RBW_AGENT");
let agent_path = agent_path
.as_ref()