aboutsummaryrefslogtreecommitdiff
path: root/src/client.rs
diff options
context:
space:
mode:
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);