aboutsummaryrefslogtreecommitdiff
path: root/src/client.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-02-21 16:43:17 +0100
committerAlex Auvolat <alex@adnab.me>2022-02-21 16:43:17 +0100
commit8858c9428936534ef2b62d73283cd800f4b838d6 (patch)
treee3569aaabad79f14093b1e140c88770676840dea /src/client.rs
parent96a3cc1e1f5c0c4e73ad1036a7e0add19d9a197e (diff)
downloadnetapp-8858c9428936534ef2b62d73283cd800f4b838d6.tar.gz
netapp-8858c9428936534ef2b62d73283cd800f4b838d6.zip
Implement version tag for application as well
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/client.rs b/src/client.rs
index e84c85e..27cd1b8 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -52,6 +52,7 @@ impl ClientConn {
let remote_addr = socket.peer_addr()?;
let mut socket = socket.compat();
+ // Do handshake to authenticate and prove our identity to server
let handshake = handshake_client(
&mut socket,
netapp.netid.clone(),
@@ -67,11 +68,25 @@ impl ClientConn {
remote_addr
);
+ // Create BoxStream layer that encodes content
let (read, write) = socket.split();
-
- let (read, write) =
+ let (mut read, write) =
BoxStream::from_handshake(read, write, handshake, 0x8000).split_read_write();
+ // Before doing anything, receive version tag and
+ // check they are running the same version as us
+ let mut their_version_tag = VersionTag::default();
+ read.read_exact(&mut their_version_tag[..]).await?;
+ if their_version_tag != netapp.version_tag {
+ let msg = format!(
+ "Different netapp versions: {:?} (theirs) vs. {:?} (ours)",
+ their_version_tag, netapp.version_tag
+ );
+ error!("{}", msg);
+ return Err(Error::VersionMismatch(msg));
+ }
+
+ // Build and launch stuff that manages sending requests client-side
let (query_send, query_recv) = mpsc::unbounded_channel();
let (stop_recv_loop, stop_recv_loop_recv) = watch::channel(false);