From 7bbe153b8ff0fbe1eb003e0816e43e9f6fbb9645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Fri, 3 May 2024 09:53:53 +0200 Subject: [PATCH] Add AuthenticationFailureWithPreexistingSharedKey and a few log statements (#4568) --- common/client-libs/gateway-client/src/client.rs | 7 +++++-- common/client-libs/gateway-client/src/error.rs | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/client-libs/gateway-client/src/client.rs b/common/client-libs/gateway-client/src/client.rs index 633832889e..39172158c0 100644 --- a/common/client-libs/gateway-client/src/client.rs +++ b/common/client-libs/gateway-client/src/client.rs @@ -442,7 +442,7 @@ impl GatewayClient { } debug_assert!(self.connection.is_available()); - log::trace!("Registering gateway"); + log::debug!("Registering gateway"); // it's fine to instantiate it here as it's only used once (during authentication or registration) // and putting it into the GatewayClient struct would be a hassle @@ -494,6 +494,7 @@ impl GatewayClient { if !self.connection.is_established() { return Err(GatewayClientError::ConnectionNotEstablished); } + log::debug!("Authenticating with gateway"); // it's fine to instantiate it here as it's only used once (during authentication or registration) // and putting it into the GatewayClient struct would be a hassle @@ -529,6 +530,7 @@ impl GatewayClient { self.authenticated = status; self.bandwidth_remaining = bandwidth_remaining; self.negotiated_protocol = protocol_version; + log::debug!("authenticated: {status}, bandwidth remaining: {bandwidth_remaining}"); Ok(()) } ServerResponse::Error { message } => Err(GatewayClientError::GatewayError(message)), @@ -541,10 +543,11 @@ impl GatewayClient { &mut self, ) -> Result, GatewayClientError> { if self.authenticated { + debug!("Already authenticated"); return if let Some(shared_key) = &self.shared_key { Ok(Arc::clone(shared_key)) } else { - Err(GatewayClientError::AuthenticationFailure) + Err(GatewayClientError::AuthenticationFailureWithPreexistingSharedKey) }; } diff --git a/common/client-libs/gateway-client/src/error.rs b/common/client-libs/gateway-client/src/error.rs index 4bcaf4cfd1..f9bad9ff12 100644 --- a/common/client-libs/gateway-client/src/error.rs +++ b/common/client-libs/gateway-client/src/error.rs @@ -71,6 +71,9 @@ pub enum GatewayClientError { #[error("Authentication failure")] AuthenticationFailure, + #[error("Authentication failure with preexisting shared key")] + AuthenticationFailureWithPreexistingSharedKey, + #[error("Timed out")] Timeout,