impl Version { /// The first SCONE packet version. pubconst SCONE1: u32 = 0x6f7d_c0fd; /// The second SCONE packet version. pubconst SCONE2: u32 = 0xef7d_c0fd;
#[derive(Debug, Clone)] pubstruct Config { /// The version that a client uses to establish a connection. /// /// For a client, this is the version that is sent out in an Initial packet. /// A client that resumes will set this to the version from the original /// connection. /// A client that handles a Version Negotiation packet will be initialized with /// a version chosen from the packet, but it will then have this value overridden /// to match the original configuration so that the version negotiation can be /// authenticated. /// /// For a server `Connection`, this is the only type of Initial packet that /// can be accepted; the correct value is set by `Server`, see below. /// /// For a `Server`, this value is not used; if an Initial packet is received /// in a supported version (as listed in `versions`), new instances of /// `Connection` will be created with this value set to match what was received. /// /// An invariant here is that this version is always listed in `all`.
initial: Version, /// The set of versions that are enabled, in preference order. For a server, /// only the relative order of compatible versions matters.
all: Vec<Version>,
}
impl Config { /// # Panics /// When `all` does not include `initial`. #[must_use] pubfn new(initial: Version, all: Vec<Version>) -> Self {
assert!(all.contains(&initial)); Self { initial, all }
}
#[must_use] pubconstfn initial(&self) -> Version { self.initial
}
/// Overwrite the initial value; used by the `Server` when handling new connections /// and by the client on resumption. pub(crate) fn set_initial(&mutself, initial: Version) {
qdebug!( "Overwrite initial version {:?} ==> {initial:?}", self.initial
);
assert!(self.all.contains(&initial)); self.initial = initial;
}
fn find_preferred<'a>(
preferences: impl IntoIterator<Item = &'a Version>,
vn: &[Wire],
) -> Option<Version> { for v in preferences { if vn.contains(&v.wire_version()) { return Some(*v);
}
}
None
}
/// Determine the preferred version based on a version negotiation packet. pub(crate) fn preferred(&self, vn: &[Wire]) -> Option<Version> { Self::find_preferred(&self.all, vn)
}
/// Determine the preferred version based on a set of compatible versions. pub(crate) fn preferred_compatible(&self, vn: &[Wire]) -> Option<Version> { Self::find_preferred(self.compatible(), vn)
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.