From 72b66fdea382a7b8deff4222d7d3467e5dedffb2 Mon Sep 17 00:00:00 2001 From: Neelay Date: Sun, 3 Nov 2024 16:57:59 -0800 Subject: [PATCH] fix local ip v4 vs v6 issues and fix arbitrary ipv6 port --- Cargo.lock | 4 ++-- insanity-native-tui-app/src/connection_manager.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d82e6bc..03f58f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -450,7 +450,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "baybridge" version = "0.1.0" -source = "git+https://github.com/nicolaschan/baybridge.git#2daedf1840777b3dd95950ec186e408fda96da25" +source = "git+https://github.com/nicolaschan/baybridge.git#b9abf87256f93bc412a4f0abc24377576552fff9" dependencies = [ "anyhow", "axum", @@ -4087,7 +4087,7 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "veq" version = "0.1.0" -source = "git+https://github.com/nicolaschan/udpp.git#16ced1b4a5a7d1e0ae0f2d694e727674db04e40d" +source = "git+https://github.com/nicolaschan/udpp.git#569535bbfefe20a803157bff8b5fcebe2b064c21" dependencies = [ "anyhow", "async-std", diff --git a/insanity-native-tui-app/src/connection_manager.rs b/insanity-native-tui-app/src/connection_manager.rs index 0074189..b350219 100644 --- a/insanity-native-tui-app/src/connection_manager.rs +++ b/insanity-native-tui-app/src/connection_manager.rs @@ -213,12 +213,14 @@ impl ConnectionManagerBuilder { VeqSocket::bind_with_keypair(&v4_addr.to_string(), keypair).await? } IpVersion::Ipv6 => { - let v6_addr = SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, self.listen_port + 1, 0, 0); + let v6_addr = SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, self.listen_port, 0, 0); VeqSocket::bind_with_keypair(&v6_addr.to_string(), keypair).await? } IpVersion::Dualstack => { let v4_addr = SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, self.listen_port); - let v6_addr = SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, self.listen_port + 1, 0, 0); + // TODO: maybe have a better way for specifying both ipv4 and ipv6 listen ports simultaneously. + let ipv6_listen_port = if self.listen_port == 0 { 0 } else { self.listen_port + 1 }; + let v6_addr = SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, ipv6_listen_port, 0, 0); VeqSocket::dualstack_with_keypair(v4_addr, v6_addr, keypair).await? } };