Skip to content

Commit e72c64d

Browse files
sanityclaude
andauthored
Release v0.1.8 (#1650)
Co-authored-by: Claude <[email protected]>
1 parent 17b7d6b commit e72c64d

File tree

21 files changed

+561
-24
lines changed

21 files changed

+561
-24
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
aider_stdlib_map.md
22

3+
# Local tools and notes
4+
.local-tools/
5+
6+
# Release artifacts (downloaded binaries)
7+
release-artifacts/
8+
39
### Rust ###
410
# Generated by Cargo
511
# will have compiled files and executables

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/freenet-ping/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[gateways]]
2+
public_key = "/home/ian/code/freenet/freenet-core/main/apps/freenet-ping/test-prod-logs/data/secrets/public.vega.gw.pem"
3+
4+
[gateways.address]
5+
hostname = "vega.locut.us:31337"
6+
7+
[[gateways]]
8+
public_key = "/home/ian/code/freenet/freenet-core/main/apps/freenet-ping/test-prod-logs/data/secrets/public.ziggy.gw.pem"
9+
10+
[gateways.address]
11+
hostname = "technic.locut.us:31337"
46.8 KB
Binary file not shown.

apps/freenet-ping/test-prod-logs/data/_EVENT_LOG_LOCAL

Whitespace-only changes.
Binary file not shown.

apps/freenet-ping/test-prod-logs/data/contracts/KEY_DATA.tmp

Whitespace-only changes.
1.52 MB
Binary file not shown.

apps/freenet-ping/test-prod-logs/data/delegates/KEY_DATA

Whitespace-only changes.

apps/freenet-ping/test-prod-logs/data/delegates/KEY_DATA.tmp

Whitespace-only changes.

apps/freenet-ping/test-prod-logs/data/secrets/KEY_DATA

Whitespace-only changes.

apps/freenet-ping/test-prod-logs/data/secrets/KEY_DATA.tmp

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA3ZECtEbAcxfvnpweDHiV
3+
OtHvHtyYE5omuNWn3AHyNHPyFMRWd/LAF4l7Q0WunjL4uAXUws1U2OBroW+Rw91C
4+
753kUtecaCelU2f4dLOfz7hIcbFL+A9w4Qzwc3bLUqTKmfASmqVX9qXP1SE4ZAKQ
5+
VxgS/9dVNBEo6wvLkrCNvq2LVQvWslEJb+0QKKbUPrFmYVnweiNGCmP6dqL37u5d
6+
C1jsuE72TaJ7FSj+hWFja3gl6o+Wz/Bw+9qbByUOchD7LtQ//9zl4Xb9lHjyUJ4V
7+
+Tmhg2EiKy3EFEUWILB391cLR3YSzS6B4kw/PptZ/L/TSWUsZH33QiGnAw56jNBW
8+
cFw3TIlQu3PvZWcttyD2dDO6tqZDusI2YHh8hyAb9Z5N8px1jlfHPpK6qHEqhB9N
9+
XjrkD2lTuRbB55UurZ5L2ajvysIjqOOtYDPcLRZHk8YjvxrYmMIk17GKE/6YI01h
10+
+QcqcYxcBCBv0ME9WL3ohKvWTziHVNfrcWYebISHhpc4F/CHbaj2O4bs4I9a9aXV
11+
INlmFHVprCl7UYI7lb4BHWu0tYxsy3oZeLG7ARWffRsz3L2aRHbtqgthSu6X7yYL
12+
YB/qWjUmIE0cAszAULCjbynplZNtwJT324+77DPD85+N9nTrS+Po8T2xJ8pCweu+
13+
5LUJQ0Jh+QPJeIQ2TzA7RSUCAwEAAQ==
14+
-----END PUBLIC KEY-----
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArpQ/xgxqczEpsNaKtBdh
3+
MmhiocOjfNimI6rD5cTYfMAsahKS0ElY6leXzNBgsZYLGxYPKqkrODPxpttejD9v
4+
fdcOaN1QNW+Rl85BSf5DlBxeBdC2NTMeadC207RZOdD12pdEdIz1W1nS/PGlDqRq
5+
Kh2LPSmuT9Kqxzk1PMO7HuIgMvQVpLBJiFnQMWJ4+meHINtI8vOkbYjLqoE2yrSK
6+
GSapQ/zptsjzzB4Jd0Rm/OV5qT7SF14yhv+XVhPy2gw/lJmhcIDw2rCEBe7hPbDX
7+
E+p9jCgGMi0HWN8QeSDTapY9hlFy4dzXW5xK0ySrGUAp1kcPDdwqA2npa3oJlVDZ
8+
TstAMDt3RhdfrrwfmdQefvygBUIAlAk69y1FvNGEOO9TcikQjDaJdfQSP9V0qTEV
9+
BsKNpkX7VHgG1i8Cc6c7JlDyeHSB+3TXSfO9esYcAFxjwx1SbyInHBMpYG/iYoX+
10+
jGqQLJVMV6EasQ5xgryW2jTD4pBjkcrlgz0KKUlCg0cMTafaOpTrnaTHjmWYIP2c
11+
KKxVR2Iu+cPdNPvFeywr2mF2Bz7I4cRxJOVhwupDH7XaWf8gfMMvIlsr2f2ChQzc
12+
gRCVduKEeMp1bcuKisSbJnFIluVOgJ3MZJi7RS+0W31dkePWtJYP0eXgdlHtDVV6
13+
scCTSgvaL0QFtu7+5ds0qqkCAwEAAQ==
14+
-----END PUBLIC KEY-----

crates/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "freenet"
3-
version = "0.1.7"
3+
version = "0.1.8"
44
edition = "2021"
55
rust-version = "1.80"
66
publish = true

crates/core/src/node/network_bridge/handshake.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ mod tests {
14671467

14681468
let gw_inbound = async {
14691469
let event =
1470-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
1470+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
14711471
match event {
14721472
Event::InboundConnection { conn, .. } => {
14731473
assert_eq!(conn.remote_addr(), remote_addr);
@@ -1522,7 +1522,7 @@ mod tests {
15221522

15231523
let gw_inbound = async {
15241524
let event =
1525-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
1525+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
15261526
match event {
15271527
Event::InboundConnectionRejected { peer_id } => {
15281528
assert_eq!(peer_id.addr, remote_addr);
@@ -1589,7 +1589,7 @@ mod tests {
15891589

15901590
let peer_inbound = async {
15911591
let event =
1592-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
1592+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
15931593
match event {
15941594
Event::OutboundGatewayConnectionSuccessful { peer_id, .. } => {
15951595
assert_eq!(peer_id.addr, remote_addr);
@@ -1624,7 +1624,7 @@ mod tests {
16241624

16251625
let peer_inbound = async {
16261626
let event =
1627-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
1627+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
16281628
match event {
16291629
Event::OutboundConnectionFailed { peer_id, error } => {
16301630
let addr: SocketAddr = ([127, 0, 0, 1], 10000).into();
@@ -1647,7 +1647,7 @@ mod tests {
16471647

16481648
#[tokio::test]
16491649
async fn test_gw_to_peer_outbound_conn_forwarded() -> anyhow::Result<()> {
1650-
// crate::config::set_logger(Some(tracing::level_filters::LevelFilter::DEBUG));
1650+
// crate::config::set_logger(Some(tracing::level_filters::LevelFilter::DEBUG), None);
16511651
let gw_addr: SocketAddr = ([127, 0, 0, 1], 10000).into();
16521652
let peer_addr: SocketAddr = ([127, 0, 0, 1], 10001).into();
16531653
let joiner_addr: SocketAddr = ([127, 0, 0, 1], 10002).into();
@@ -1682,6 +1682,9 @@ mod tests {
16821682
.establish_inbound_conn(joiner_addr, joiner_pub_key, None)
16831683
.await;
16841684

1685+
// Give some time for the events to be processed
1686+
tokio::time::sleep(Duration::from_millis(100)).await;
1687+
16851688
// TODO: maybe simulate forwarding back all expected responses
16861689

16871690
Ok::<_, anyhow::Error>(())
@@ -1691,7 +1694,7 @@ mod tests {
16911694
let mut third_party = None;
16921695
loop {
16931696
let event =
1694-
tokio::time::timeout(Duration::from_secs(1), gw_handler.wait_for_events())
1697+
tokio::time::timeout(Duration::from_secs(15), gw_handler.wait_for_events())
16951698
.await??;
16961699
match event {
16971700
Event::InboundConnection {
@@ -1978,7 +1981,7 @@ mod tests {
19781981

19791982
let peer_inbound = async {
19801983
let event =
1981-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
1984+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
19821985
let _conn = match event {
19831986
Event::OutboundGatewayConnectionSuccessful {
19841987
peer_id,
@@ -2022,7 +2025,7 @@ mod tests {
20222025

20232026
let peer_inbound = async {
20242027
let event =
2025-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
2028+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
20262029
match event {
20272030
Event::OutboundConnectionFailed { peer_id, error } => {
20282031
assert_eq!(peer_id.addr, peer_addr);
@@ -2066,7 +2069,7 @@ mod tests {
20662069

20672070
let peer_inbound = async {
20682071
let event =
2069-
tokio::time::timeout(Duration::from_secs(1), handler.wait_for_events()).await??;
2072+
tokio::time::timeout(Duration::from_secs(15), handler.wait_for_events()).await??;
20702073
match event {
20712074
Event::OutboundConnectionSuccessful {
20722075
peer_id,

crates/core/src/transport/connection_handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ impl<S: Socket> UdpPacketsListener<S> {
646646
inbound_symmetric_key: inbound_key,
647647
inbound_symmetric_key_bytes: inbound_key_bytes,
648648
my_address: None,
649+
transport_secret_key: secret,
649650
};
650651

651652
let inbound_conn = InboundRemoteConnection {
@@ -842,6 +843,8 @@ impl<S: Socket> UdpPacketsListener<S> {
842843
inbound_symmetric_key_bytes:
843844
inbound_sym_key_bytes,
844845
my_address: Some(my_address),
846+
transport_secret_key: transport_secret_key
847+
.clone(),
845848
},
846849
InboundRemoteConnection {
847850
inbound_packet_sender: inbound_sender,
@@ -907,6 +910,7 @@ impl<S: Socket> UdpPacketsListener<S> {
907910
inbound_symmetric_key: inbound_sym_key,
908911
inbound_symmetric_key_bytes: inbound_sym_key_bytes,
909912
my_address: None,
913+
transport_secret_key: transport_secret_key.clone(),
910914
},
911915
InboundRemoteConnection {
912916
inbound_packet_sender: inbound_sender,

crates/core/src/transport/peer_connection.rs

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::time::Duration;
55
use std::{collections::HashMap, time::Instant};
66

77
use crate::transport::connection_handler::NAT_TRAVERSAL_MAX_ATTEMPTS;
8+
use crate::transport::crypto::TransportSecretKey;
89
use crate::transport::packet_data::UnknownEncryption;
910
use crate::transport::sent_packet_tracker::MESSAGE_CONFIRMATION_TIMEOUT;
1011
use aes_gcm::Aes128Gcm;
@@ -47,6 +48,7 @@ pub(crate) struct RemoteConnection {
4748
pub(super) inbound_symmetric_key: Aes128Gcm,
4849
pub(super) inbound_symmetric_key_bytes: [u8; 16],
4950
pub(super) my_address: Option<SocketAddr>,
51+
pub(super) transport_secret_key: TransportSecretKey,
5052
}
5153

5254
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
@@ -157,6 +159,7 @@ impl PeerConnection {
157159
inbound_symmetric_key,
158160
inbound_symmetric_key_bytes: [1; 16],
159161
my_address: Some(my_address),
162+
transport_secret_key: super::crypto::TransportKeypair::new().secret,
160163
};
161164
(
162165
Self::new(remote),
@@ -186,6 +189,7 @@ impl PeerConnection {
186189
inbound_symmetric_key,
187190
inbound_symmetric_key_bytes: [1; 16],
188191
my_address: Some(my_address),
192+
transport_secret_key: super::crypto::TransportKeypair::new().secret,
189193
},
190194
inbound_packet_sender,
191195
outbound_packets_recv,
@@ -215,14 +219,8 @@ impl PeerConnection {
215219
// listen for incoming messages or receipts or wait until is time to do anything else again
216220
let mut resend_check = Some(tokio::time::sleep(tokio::time::Duration::from_millis(10)));
217221

218-
#[cfg(debug_assertions)]
219-
const KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(2);
220-
#[cfg(not(debug_assertions))]
221-
const KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(20);
222-
#[cfg(debug_assertions)]
223-
const KILL_CONNECTION_AFTER: Duration = Duration::from_secs(6);
224-
#[cfg(not(debug_assertions))]
225-
const KILL_CONNECTION_AFTER: Duration = Duration::from_secs(60);
222+
const KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(10);
223+
const KILL_CONNECTION_AFTER: Duration = Duration::from_secs(30);
226224

227225
let mut keep_alive = tokio::time::interval(KEEP_ALIVE_INTERVAL);
228226
keep_alive.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
@@ -236,14 +234,85 @@ impl PeerConnection {
236234
inbound = self.remote_conn.inbound_packet_recv.recv() => {
237235
let packet_data = inbound.ok_or(TransportError::ConnectionClosed(self.remote_addr()))?;
238236
last_received = std::time::Instant::now();
237+
238+
// Debug logging for 256-byte packets
239+
if packet_data.data().len() == 256 {
240+
tracing::warn!(
241+
remote = ?self.remote_conn.remote_addr,
242+
packet_bytes = ?&packet_data.data()[..32], // First 32 bytes
243+
packet_len = packet_data.data().len(),
244+
"Received 256-byte packet"
245+
);
246+
}
247+
239248
let Ok(decrypted) = packet_data.try_decrypt_sym(&self.remote_conn.inbound_symmetric_key).inspect_err(|error| {
240249
tracing::warn!(
241250
%error,
242251
remote = ?self.remote_conn.remote_addr,
243252
inbound_key = ?self.remote_conn.inbound_symmetric_key_bytes,
253+
packet_len = packet_data.data().len(),
254+
packet_first_bytes = ?&packet_data.data()[..std::cmp::min(32, packet_data.data().len())],
244255
"Failed to decrypt packet, might be an intro packet or a partial packet"
245256
);
246257
}) else {
258+
// Check if this is a 256-byte RSA intro packet
259+
if packet_data.data().len() == 256 {
260+
tracing::info!(
261+
remote = ?self.remote_conn.remote_addr,
262+
"Attempting to decrypt potential RSA intro packet"
263+
);
264+
265+
// Try to decrypt as RSA intro packet
266+
match self.remote_conn.transport_secret_key.decrypt(packet_data.data()) {
267+
Ok(_decrypted_intro) => {
268+
tracing::info!(
269+
remote = ?self.remote_conn.remote_addr,
270+
"Successfully decrypted RSA intro packet, sending ACK"
271+
);
272+
273+
// Send ACK response for intro packet
274+
let ack_packet = SymmetricMessage::ack_ok(
275+
&self.remote_conn.outbound_symmetric_key,
276+
self.remote_conn.inbound_symmetric_key_bytes,
277+
self.remote_conn.remote_addr,
278+
);
279+
280+
if let Ok(ack) = ack_packet {
281+
if let Err(send_err) = self.remote_conn
282+
.outbound_packets
283+
.send((self.remote_conn.remote_addr, ack.data().into()))
284+
.await
285+
{
286+
tracing::warn!(
287+
remote = ?self.remote_conn.remote_addr,
288+
error = ?send_err,
289+
"Failed to send ACK for intro packet"
290+
);
291+
} else {
292+
tracing::info!(
293+
remote = ?self.remote_conn.remote_addr,
294+
"Successfully sent ACK for intro packet"
295+
);
296+
}
297+
} else {
298+
tracing::warn!(
299+
remote = ?self.remote_conn.remote_addr,
300+
"Failed to create ACK packet for intro"
301+
);
302+
}
303+
304+
// Continue to next packet
305+
continue;
306+
}
307+
Err(rsa_err) => {
308+
tracing::debug!(
309+
remote = ?self.remote_conn.remote_addr,
310+
error = ?rsa_err,
311+
"256-byte packet is not a valid RSA intro packet"
312+
);
313+
}
314+
}
315+
}
247316
let now = Instant::now();
248317
if let Some(first_failure_time) = self.first_failure_time {
249318
if now.duration_since(first_failure_time) <= FAILURE_TIME_WINDOW {

0 commit comments

Comments
 (0)