diff --git a/Cargo.lock b/Cargo.lock index 9b1272c..a44980d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1136,7 +1136,7 @@ dependencies = [ [[package]] name = "omnip" -version = "0.5.0" +version = "0.5.1" dependencies = [ "android_logger", "anyhow", @@ -1455,8 +1455,8 @@ dependencies = [ [[package]] name = "rstun" -version = "0.5.0" -source = "git+https://github.com/neevek/rstun#ed4e99e965c3661c6400f4b0655195dabf04cf88" +version = "0.5.1" +source = "git+https://github.com/neevek/rstun#6d2057ebdf929de6d58a4dfb1603e2e18c7ea3e0" dependencies = [ "android_logger", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index f89aeca..eeeb48f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "omnip" -version = "0.5.0" +version = "0.5.1" edition = "2021" [lib] diff --git a/src/lib.rs b/src/lib.rs index fd83164..3062601 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -289,7 +289,7 @@ pub struct QuicServerConfig { #[derive(Debug, Clone)] pub struct QuicClientConfig { pub server_addr: NetAddr, - pub local_access_server_addr: SocketAddr, + pub local_tcp_server_addr: SocketAddr, pub common_cfg: CommonQuicConfig, } diff --git a/src/quic/quic_client.rs b/src/quic/quic_client.rs index 349eeaa..e342004 100644 --- a/src/quic/quic_client.rs +++ b/src/quic/quic_client.rs @@ -7,7 +7,7 @@ use crate::QuicClientConfig; pub struct QuicClient { client: Arc, server_addr: String, - access_server_addr: Option, + tcp_server_addr: Option, } impl QuicClient { @@ -18,12 +18,12 @@ impl QuicClient { QuicClient { client: rstun::Client::new(config.clone()), server_addr, - access_server_addr: None, + tcp_server_addr: None, } } - pub async fn start_access_server(&mut self) -> Result<()> { - self.access_server_addr = Some(self.client.start_access_server().await?); + pub async fn start_tcp_server(&mut self) -> Result<()> { + self.tcp_server_addr = Some(self.client.start_tcp_server().await?); Ok(()) } @@ -47,8 +47,8 @@ impl QuicClient { self.server_addr.clone() } - pub fn access_server_addr(&self) -> Option { - self.access_server_addr + pub fn tcp_server_addr(&self) -> Option { + self.tcp_server_addr } pub fn get_state(&self) -> rstun::ClientState { @@ -60,15 +60,14 @@ impl QuicClient { config.cert_path = quic_client_config.common_cfg.cert.clone(); config.cipher = quic_client_config.common_cfg.cipher.clone(); config.max_idle_timeout_ms = quic_client_config.common_cfg.max_idle_timeout_ms; - config.keep_alive_interval_ms = quic_client_config.common_cfg.max_idle_timeout_ms / 2; config.threads = quic_client_config.common_cfg.threads; config.wait_before_retry_ms = quic_client_config.common_cfg.retry_interval_ms; config.connect_max_retry = 0; config.mode = rstun::TUNNEL_MODE_OUT; - config.local_access_server_addr = Some(quic_client_config.local_access_server_addr); + config.local_tcp_server_addr = Some(quic_client_config.local_tcp_server_addr); config.login_msg = Some(rstun::TunnelMessage::ReqOutLogin(rstun::LoginInfo { password: quic_client_config.common_cfg.password.clone(), - access_server_addr: None, + tcp_server_addr: None, })) } } diff --git a/src/server.rs b/src/server.rs index 9cc4a1c..c3469af 100644 --- a/src/server.rs +++ b/src/server.rs @@ -253,7 +253,7 @@ impl Server { // with +quic protocols, quic_client will be used to connect to the upstream let quic_client_config = QuicClientConfig { server_addr: quic_server_addr, - local_access_server_addr: local_socket_addr_with_unspecified_port( + local_tcp_server_addr: local_socket_addr_with_unspecified_port( self.config.addr.is_ipv6(), ), common_cfg: common_quic_config, @@ -267,18 +267,15 @@ impl Server { info_bridge.post_server_log(data); }); } - client.start_access_server().await?; + client.start_tcp_server().await?; - let access_server_addr = client.access_server_addr(); - info!( - "QUIC tunnel access server address: {:?}", - access_server_addr - ); + let tcp_server_addr = client.tcp_server_addr(); + info!("QUIC tunnel access server address: {:?}", tcp_server_addr); // will handover the handle to the caller, so we don't block here let join_handle = client.connect_and_serve_async(); - inner_state!(self, upstream) = access_server_addr; + inner_state!(self, upstream) = tcp_server_addr; inner_state!(self, quic_client) = Some(Arc::new(client)); Ok(join_handle)