Add a version check to the pull protocol
This commit is contained in:
parent
375d68eb0e
commit
14be0ef0a3
|
@ -137,6 +137,19 @@ pub fn offering_side<R: Read, W: Write>(
|
||||||
writer: &mut W,
|
writer: &mut W,
|
||||||
mut progress: Box<dyn ProgressTracker>,
|
mut progress: Box<dyn ProgressTracker>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
|
let expecting = format!("Datman Pull Accepter {}", version);
|
||||||
|
write_message(writer, &format!("Datman Pull Offerer {}", version))?;
|
||||||
|
writer.flush()?;
|
||||||
|
|
||||||
|
let found: String = read_message(reader)?;
|
||||||
|
ensure!(
|
||||||
|
found == expecting,
|
||||||
|
"Version mismatch. Expecting {:?} got {:?}",
|
||||||
|
expecting,
|
||||||
|
found
|
||||||
|
);
|
||||||
|
|
||||||
// First 'negotiate' (for now: assert) a pile bypass.
|
// First 'negotiate' (for now: assert) a pile bypass.
|
||||||
// This lets us avoid decompressing things before recompressing them at the other end,
|
// This lets us avoid decompressing things before recompressing them at the other end,
|
||||||
// assuming both ends use the same dictionary.
|
// assuming both ends use the same dictionary.
|
||||||
|
@ -195,6 +208,19 @@ pub fn accepting_side<R: Read, W: Write>(
|
||||||
writer: &mut W,
|
writer: &mut W,
|
||||||
mut progress: Box<dyn ProgressTracker>,
|
mut progress: Box<dyn ProgressTracker>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
|
let expecting = format!("Datman Pull Offerer {}", version);
|
||||||
|
write_message(writer, &format!("Datman Pull Accepter {}", version))?;
|
||||||
|
writer.flush()?;
|
||||||
|
|
||||||
|
let found: String = read_message(reader)?;
|
||||||
|
ensure!(
|
||||||
|
found == expecting,
|
||||||
|
"Version mismatch. Expecting {:?} got {:?}",
|
||||||
|
expecting,
|
||||||
|
found
|
||||||
|
);
|
||||||
|
|
||||||
// First 'negotiate' (for now: assert) a pile bypass.
|
// First 'negotiate' (for now: assert) a pile bypass.
|
||||||
// This lets us avoid decompressing things before recompressing them at the other end,
|
// This lets us avoid decompressing things before recompressing them at the other end,
|
||||||
// assuming both ends use the same dictionary.
|
// assuming both ends use the same dictionary.
|
||||||
|
|
Loading…
Reference in New Issue