feat: add public I2P network mode to router daemon
- Add `--public`, `--hops`, `--hosts`, and `--debug` router flags; `--public` auto-reseeds from the live network and keeps a status loop running. - Route NetDB lookups through tunnels with Noise_N garlic wrapping, fan out to two floodfills, and fetch unknown RouterInfos in the background. - Back off failed NTCP2 peers and fall back to IPv6 addresses when no IPv4 NTCP2 address is available. - Size session LeaseSet2 expiry from lease end dates and use the destination's X25519 key when present. - Add canonical Ed25519 Destination KeyCertificate constructors with round-trip tests. - Fix DatabaseStore gzip handling to honor the length prefix, and send `Wget/1.11.4` as the reseed User-Agent.
This commit is contained in:
1 parent
ae72b00323
commit
54cfb2faa9
25 files changed
+2033
-191
No files matched your search
@@ -86,8 +86,14 @@ test "Streaming full SYN -> SYN-ACK -> Data with drop/NACK/retransmit -> CLOSE"
|
||||
from_port=1111U,
|
||||
to_port=80U,
|
||||
)
|
||||
// Deliver SYN to Bob
|
||||
for msg in a_stream.drain_outbound() {
|
||||
// Deliver SYN to Bob and verify canonical I2P wire polarity & 8-NACK target hash
|
||||
let syn_pkts = a_stream.drain_outbound()
|
||||
assert_eq(syn_pkts.length(), 1)
|
||||
let (_syn_hdr, syn_dec) = @streaming.decode_i2cp_streaming(syn_pkts[0])
|
||||
assert_eq(syn_dec.send_stream_id, 0U)
|
||||
assert_eq(syn_dec.recv_stream_id, 100U)
|
||||
assert_eq(syn_dec.nacks.length(), 8)
|
||||
for msg in syn_pkts {
|
||||
let _ = bob_mgr.handle_incoming_i2cp(msg, 1010UL)
|
||||
}
|
||||
let b_stream = match bob_mgr.accept_next() {
|
||||
@@ -161,3 +167,162 @@ test "RepliableDatagram (Ed25519 raw payload) and RawDatagram I2CP round-trip" {
|
||||
assert_eq(rh.protocol, b'\x12')
|
||||
assert_eq(rbody, b"unauth-raw")
|
||||
}
|
||||
|
||||
///|
|
||||
test "Streaming accepts unsigned ECIES SYN-ACK / CLOSE and honors DELAY_REQUESTED=0" {
|
||||
let (alice_dest, alice_seed) = make_test_identity(b'\x41')
|
||||
let (bob_dest, _bob_seed) = make_test_identity(b'\x42')
|
||||
let alice_mgr = @streaming.StreamManager::new(
|
||||
alice_dest,
|
||||
alice_seed,
|
||||
initial_stream_id=300U,
|
||||
)
|
||||
let a_stream = alice_mgr.connect(bob_dest.hash(), 2000UL)
|
||||
let _ = a_stream.drain_outbound()
|
||||
|
||||
// Simulated ECIES peer sends unsigned SYN-ACK (m_DontSign)
|
||||
let unsigned_syn_ack : @streaming.StreamingPacket = {
|
||||
send_stream_id: 300U,
|
||||
recv_stream_id: 900U,
|
||||
sequence_num: 0U,
|
||||
ack_through: 0U,
|
||||
nacks: [],
|
||||
resend_delay: b'\x00',
|
||||
flags: @streaming.flag_synchronize |
|
||||
@streaming.flag_from_included |
|
||||
@streaming.flag_max_packet_size_included,
|
||||
delay_requested: None,
|
||||
from_dest: Some(bob_dest),
|
||||
max_packet_size: Some(1730U),
|
||||
offline_sig: None,
|
||||
signature: None,
|
||||
payload: b"",
|
||||
}
|
||||
let _ = alice_mgr.handle_incoming_i2cp(
|
||||
@streaming.encode_i2cp_streaming(unsigned_syn_ack),
|
||||
2010UL,
|
||||
)
|
||||
assert_eq(a_stream.state, Established)
|
||||
let _ = a_stream.drain_outbound()
|
||||
|
||||
// Peer sends empty ACK packet with DELAY_REQUESTED=0 -> must queue immediate ACK
|
||||
let probe_pkt : @streaming.StreamingPacket = {
|
||||
send_stream_id: 300U,
|
||||
recv_stream_id: 900U,
|
||||
sequence_num: 0U,
|
||||
ack_through: 0U,
|
||||
nacks: [],
|
||||
resend_delay: b'\x00',
|
||||
flags: @streaming.flag_delay_requested,
|
||||
delay_requested: Some(0U),
|
||||
from_dest: None,
|
||||
max_packet_size: None,
|
||||
offline_sig: None,
|
||||
signature: None,
|
||||
payload: b"",
|
||||
}
|
||||
let _ = alice_mgr.handle_incoming_i2cp(
|
||||
@streaming.encode_i2cp_streaming(probe_pkt),
|
||||
2020UL,
|
||||
)
|
||||
assert_eq(a_stream.drain_outbound().length(), 1)
|
||||
|
||||
// Peer sends unsigned CLOSE with data at seq 1
|
||||
let unsigned_close : @streaming.StreamingPacket = {
|
||||
send_stream_id: 300U,
|
||||
recv_stream_id: 900U,
|
||||
sequence_num: 1U,
|
||||
ack_through: 0U,
|
||||
nacks: [],
|
||||
resend_delay: b'\x00',
|
||||
flags: @streaming.flag_close,
|
||||
delay_requested: None,
|
||||
from_dest: None,
|
||||
max_packet_size: None,
|
||||
offline_sig: None,
|
||||
signature: None,
|
||||
payload: b"bye",
|
||||
}
|
||||
let _ = alice_mgr.handle_incoming_i2cp(
|
||||
@streaming.encode_i2cp_streaming(unsigned_close),
|
||||
2030UL,
|
||||
)
|
||||
assert_eq(a_stream.read_available(), b"bye")
|
||||
assert_eq(a_stream.is_eof(), true)
|
||||
}
|
||||
|
||||
///|
|
||||
test "Streaming caches offline transient key from SYN-ACK to verify CLOSE without OFFLINE_SIGNATURE" {
|
||||
let (alice_dest, alice_seed) = make_test_identity(b'\x51')
|
||||
let master_seed = Bytes::make(32, b'\x52')
|
||||
let master_pub = @crypto.ed25519_public_key(master_seed)
|
||||
let transient_seed = Bytes::make(32, b'\x53')
|
||||
let transient_pub = @crypto.ed25519_public_key(transient_seed)
|
||||
let bob_dest = try! @common.Destination::new_ed25519(master_pub)
|
||||
|
||||
let off_sig : @common.OfflineSignature = {
|
||||
expires_sec: 1900000000U,
|
||||
transient_sig_type: EdDsaSha512Ed25519,
|
||||
transient_pub_key: transient_pub,
|
||||
signature: b"",
|
||||
}
|
||||
let signed_off = off_sig.sign_ed25519(master_seed)
|
||||
|
||||
let alice_mgr = @streaming.StreamManager::new(
|
||||
alice_dest,
|
||||
alice_seed,
|
||||
initial_stream_id=400U,
|
||||
)
|
||||
let a_stream = alice_mgr.connect(bob_dest.hash(), 3000UL)
|
||||
let _ = a_stream.drain_outbound()
|
||||
|
||||
let syn_ack_raw : @streaming.StreamingPacket = {
|
||||
send_stream_id: 400U,
|
||||
recv_stream_id: 800U,
|
||||
sequence_num: 0U,
|
||||
ack_through: 0U,
|
||||
nacks: [],
|
||||
resend_delay: b'\x00',
|
||||
flags: @streaming.flag_synchronize |
|
||||
@streaming.flag_from_included |
|
||||
@streaming.flag_max_packet_size_included |
|
||||
@streaming.flag_offline_signature,
|
||||
delay_requested: None,
|
||||
from_dest: Some(bob_dest),
|
||||
max_packet_size: Some(1730U),
|
||||
offline_sig: Some(signed_off),
|
||||
signature: None,
|
||||
payload: b"",
|
||||
}
|
||||
let syn_ack = syn_ack_raw.sign_ed25519(transient_seed)
|
||||
let _ = alice_mgr.handle_incoming_i2cp(
|
||||
@streaming.encode_i2cp_streaming(syn_ack),
|
||||
3010UL,
|
||||
)
|
||||
assert_eq(a_stream.state, Established)
|
||||
let _ = a_stream.drain_outbound()
|
||||
|
||||
// Follow-on CLOSE signed with cached transient key without repeating OFFLINE_SIGNATURE
|
||||
let close_raw : @streaming.StreamingPacket = {
|
||||
send_stream_id: 400U,
|
||||
recv_stream_id: 800U,
|
||||
sequence_num: 1U,
|
||||
ack_through: 0U,
|
||||
nacks: [],
|
||||
resend_delay: b'\x00',
|
||||
flags: @streaming.flag_close,
|
||||
delay_requested: None,
|
||||
from_dest: None,
|
||||
max_packet_size: None,
|
||||
offline_sig: None,
|
||||
signature: None,
|
||||
payload: b"HTTP/1.0 200 OK\r\n\r\nhi",
|
||||
}
|
||||
let close_pkt = close_raw.sign_ed25519(transient_seed)
|
||||
let _ = alice_mgr.handle_incoming_i2cp(
|
||||
@streaming.encode_i2cp_streaming(close_pkt),
|
||||
3020UL,
|
||||
)
|
||||
assert_eq(a_stream.read_available(), b"HTTP/1.0 200 OK\r\n\r\nhi")
|
||||
assert_eq(a_stream.is_eof(), true)
|
||||
}
|
||||
Reference in new issue
Block a user