fix(lib): route on the full four-byte message code

Dispatch read one byte of the code, so a code with a non-zero high byte
was handled as its low byte. Message::get_message_code now reads the
whole little-endian uint32 and handlers register by u32. PeerInit and
PierceFirewall, the only frames with a one-byte code, get their own
accessor for the listener's first frame.
This commit is contained in:
Michel de Graaf
2026-09-07 15:03:49 +02:00
parent 40a8eb1dd5
commit f1aa94fecc
40 changed files with 99 additions and 55 deletions
+1 -1
View File
@@ -360,7 +360,7 @@ fn handle_incoming_connection(
// A firewalled peer brokered through the server connects back with a
// PierceFirewall (code 0) instead of a PeerInit (code 1).
if message.get_message_code() == 0 {
if message.get_init_code() == 0 {
handle_pierce_firewall(
message, stream, reader, &context, &peer_ip, peer_port,
);
+1 -1
View File
@@ -191,7 +191,7 @@ fn test_new_from_message2() {
let mut message = Message::new_with_data(data);
message.set_pointer(8);
println!("code: {}", message.get_message_code_u32());
println!("code: {}", message.get_message_code());
let peer = Peer::new_from_message(&mut message).unwrap();