diff --git a/Cargo.lock b/Cargo.lock index 7bb2fc7..e3f1581 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -996,7 +996,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "playit-agent-core" -version = "0.17.1" +version = "0.17.2" dependencies = [ "byteorder", "chrono", @@ -1030,7 +1030,7 @@ dependencies = [ [[package]] name = "playit-cli" -version = "0.15.18" +version = "0.15.19" dependencies = [ "clap", "crossterm", diff --git a/Cargo.toml b/Cargo.toml index 5de667a..dd9afb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] [workspace.package] -version = "0.15.18" +version = "0.15.19" [workspace.dependencies] tokio = { version = "1.39", features = ["full"] } diff --git a/packages/agent_cli/src/match_ip.rs b/packages/agent_cli/src/match_ip.rs index f3ca9f9..122cc51 100644 --- a/packages/agent_cli/src/match_ip.rs +++ b/packages/agent_cli/src/match_ip.rs @@ -51,6 +51,10 @@ impl MatchIp { else if octs[0] == 23 && octs[1] == 133 && octs[2] == 216 { 6u16 } + /* 198.22.204.0/24 (6) */ + else if octs[0] == 198 && octs[1] == 22 && octs[2] == 204 { + 6u16 + } /* global IP */ else { 0 diff --git a/packages/agent_core/Cargo.toml b/packages/agent_core/Cargo.toml index 410f777..f1b8a15 100644 --- a/packages/agent_core/Cargo.toml +++ b/packages/agent_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playit-agent-core" -version = "0.17.1" +version = "0.17.2" edition = "2021" description = "Contains the logic to create a playit.gg agent" license = "BSD-2-Clause" diff --git a/packages/agent_core/src/agent_control/maintained_control.rs b/packages/agent_core/src/agent_control/maintained_control.rs index bd99d67..e3ebd9c 100644 --- a/packages/agent_core/src/agent_control/maintained_control.rs +++ b/packages/agent_core/src/agent_control/maintained_control.rs @@ -105,7 +105,7 @@ impl MaintainedControl { if let Some(udp) = &self.udp { if udp.requires_auth() { - if 5_000 < now - self.last_udp_auth { + if 13_000 < now - self.last_udp_auth { self.last_udp_auth = now; if let Err(error) = self.control.send_setup_udp_channel(9000).await { diff --git a/packages/agent_core/src/agent_control/udp_channel.rs b/packages/agent_core/src/agent_control/udp_channel.rs index 7fdacbe..dfdca46 100644 --- a/packages/agent_core/src/agent_control/udp_channel.rs +++ b/packages/agent_core/src/agent_control/udp_channel.rs @@ -3,6 +3,7 @@ use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use std::sync::Arc; use std::sync::atomic::{AtomicU32, Ordering}; +use byteorder::{BigEndian, ByteOrder}; use tokio::net::UdpSocket; use tokio::sync::RwLock; @@ -75,6 +76,7 @@ impl UdpChannel { return false; } + /* send within the last 5 seconds */ let now = now_sec(); 5 < now - last_send } @@ -151,8 +153,8 @@ impl UdpChannel { } pub async fn receive_from(&self, buffer: &mut [u8]) -> std::io::Result { - let details = self.get_details().await?; let (bytes, remote) = self.inner.packet_io.recv_from(buffer).await?; + let details = self.get_details().await?; if details.tunnel_addr != remote { let lock = self.inner.details.read().await; @@ -185,10 +187,8 @@ impl UdpChannel { let actual = hex::encode(&buffer[..bytes]); let expected = hex::encode(&details.token[..]); - return Err(std::io::Error::new( - std::io::ErrorKind::InvalidData, - format!("unexpected UDP establish packet, actual: {}, expected: {}", actual, expected) - )); + tracing::error!(%actual, %expected, "unexpected UDP establish packet"); + return Ok(UdpTunnelRx::InvalidEstablishToken); }, _ => return Err(std::io::Error::new( std::io::ErrorKind::InvalidData, @@ -206,4 +206,5 @@ impl UdpChannel { pub enum UdpTunnelRx { ReceivedPacket { bytes: usize, flow: UdpFlow }, ConfirmedConnection, + InvalidEstablishToken, } diff --git a/packages/agent_core/src/playit_agent.rs b/packages/agent_core/src/playit_agent.rs index 302e493..96d409b 100644 --- a/packages/agent_core/src/playit_agent.rs +++ b/packages/agent_core/src/playit_agent.rs @@ -136,6 +136,8 @@ impl PlayitAgent where L::Value: Into v, @@ -157,7 +159,18 @@ impl PlayitAgent where L::Value: Into {} + UdpTunnelRx::InvalidEstablishToken => { + invalid_count += 1; + + if 5 <= invalid_count && invalid_count < 10 { + tracing::error!("have repeat invalid UDP establish tokens"); + tokio::time::sleep(Duration::from_millis(100)).await; + } + continue; + } } + + invalid_count = 0; } });