multi-hop s2s: forward svs*/metadata/sasl to the target's server, route/flood encap by mask (Message::to_wire)

This commit is contained in:
Jean Chevronnet 2026-08-08 20:09:15 +00:00
parent b92101616b
commit d9433eb692
No known key found for this signature in database
GPG key ID: 439666D63A9477E4
2 changed files with 146 additions and 56 deletions

View file

@ -17,6 +17,29 @@ pub struct Message {
pub label: Option<String>,
}
impl Message {
/// Re-serialise to a wire line, for forwarding across links. The last param is
/// emitted as a trailing `:param` when it's empty, has a space, or starts `:`.
pub fn to_wire(&self) -> String {
let mut out = String::new();
if let Some(src) = &self.source {
out.push(':');
out.push_str(src);
out.push(' ');
}
out.push_str(&self.command);
let n = self.params.len();
for (i, p) in self.params.iter().enumerate() {
out.push(' ');
if i + 1 == n && (p.is_empty() || p.contains(' ') || p.starts_with(':')) {
out.push(':');
}
out.push_str(p);
}
out
}
}
/// Parse one wire line. Returns `None` for an empty/garbage line.
pub fn parse(line: &str) -> Option<Message> {
let mut rest = line.trim_start();