Skip to content

Commit

Permalink
upgrade to rstun 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Sep 28, 2024
1 parent 8339a1c commit a6da33b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
35 changes: 33 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lazy_static = "1.4"
async-trait = "0.1"
byte-pool = { git = "https://github.com/neevek/byte-pool" }
# rstun = { path = "../rstun" }
rstun = { git = "https://github.com/neevek/rstun" }
rstun = { git = "https://github.com/neevek/rstun", branch = "dev" }
hyper = { version = "0.14", features = ["full"]}
http = "0.2"
http-body = "0.4"
Expand Down
6 changes: 4 additions & 2 deletions src/quic/quic_client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use rstun::Upstream;
use std::{net::SocketAddr, sync::Arc};
use tokio::task::JoinHandle;

Expand All @@ -23,7 +24,7 @@ impl QuicClient {
}

pub async fn start_tcp_server(&mut self) -> Result<()> {
self.tcp_server_addr = Some(self.client.start_tcp_server().await?);
self.tcp_server_addr = self.client.start_tcp_server().await?;
Ok(())
}

Expand Down Expand Up @@ -67,7 +68,8 @@ impl QuicClient {
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(),
tcp_server_addr: None,
tcp_upstream: Upstream::PeerDefault,
udp_upstream: Upstream::NotSpecified,
}))
}
}
23 changes: 14 additions & 9 deletions src/quic/quic_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ pub struct QuicServer {

impl QuicServer {
pub fn new(quic_server_config: QuicServerConfig) -> Self {
let mut config = rstun::ServerConfig::default();
config.addr = quic_server_config.server_addr.to_string();
config.password = quic_server_config.common_cfg.password.to_string();
config.cert_path = quic_server_config.common_cfg.cert.to_string();
config.key_path = quic_server_config.common_cfg.key.to_string();
config.max_idle_timeout_ms = quic_server_config.common_cfg.max_idle_timeout_ms;
config.upstreams = vec![quic_server_config.upstream_addr];
let server = rstun::Server::new(config);
QuicServer { server }
let config = rstun::ServerConfig {
addr: quic_server_config.server_addr.to_string(),
password: quic_server_config.common_cfg.password.to_string(),
cert_path: quic_server_config.common_cfg.cert.to_string(),
key_path: quic_server_config.common_cfg.key.to_string(),
max_idle_timeout_ms: quic_server_config.common_cfg.max_idle_timeout_ms,
tcp_upstreams: vec![quic_server_config.upstream_addr],
udp_upstreams: vec![],
dashboard_server: "".to_string(),
dashboard_server_credential: "".to_string(),
};
QuicServer {
server: rstun::Server::new(config),
}
}

pub fn bind(&mut self) -> Result<SocketAddr> {
Expand Down

0 comments on commit a6da33b

Please sign in to comment.