Skip to content

Commit

Permalink
Return expected version in the RTR server error PDU on mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
partim committed Jan 12, 2024
1 parent 89b700b commit ea535b9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/rtr/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ use super::payload::{Action, PayloadRef, Timing};
use super::state::State;


//============ Constants =====================================================

/// The maximum protocol version we support.
///
/// We support all protcol versions from 0 up to and including this value.
const MAX_VERSION: u8 = 2;

//============ Traits ========================================================

//------------ PayloadSource et al. ------------------------------------------
Expand Down Expand Up @@ -323,7 +330,7 @@ where Sock: AsyncRead + Unpin {
if current != header.version() {
Err(Query::Error(
pdu::Error::new(
header.version(),
current, // respond with the version expected
8,
header,
"version switched during connection"
Expand All @@ -334,10 +341,10 @@ where Sock: AsyncRead + Unpin {
Ok(())
}
}
else if header.version() > 2 {
else if header.version() > MAX_VERSION {
Err(Query::Error(
pdu::Error::new(
header.version(),
MAX_VERSION, // respond with what they should try
4,
header,
"only versions 0 to 2 supported"
Expand Down

0 comments on commit ea535b9

Please sign in to comment.