mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-19 21:39:09 +00:00
Bump version 0.6.3
This commit is contained in:
parent
e8143a691b
commit
21355e37da
4 changed files with 23 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tun2proxy"
|
name = "tun2proxy"
|
||||||
version = "0.6.2"
|
version = "0.6.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/tun2proxy/tun2proxy"
|
repository = "https://github.com/tun2proxy/tun2proxy"
|
||||||
|
|
|
@ -160,8 +160,9 @@ Options:
|
||||||
--daemonize Daemonize for unix family or run as Windows service
|
--daemonize Daemonize for unix family or run as Windows service
|
||||||
--exit-on-fatal-error Exit immediately when fatal error occurs, useful for running as a service
|
--exit-on-fatal-error Exit immediately when fatal error occurs, useful for running as a service
|
||||||
--max-sessions <number> Maximum number of sessions to be handled concurrently [default: 200]
|
--max-sessions <number> Maximum number of sessions to be handled concurrently [default: 200]
|
||||||
--udpgw-server <IP:PORT> UDP gateway server address, similar to badvpn-udpgw
|
--udpgw-server <IP:PORT> UDP gateway server address, forwards UDP packets via specified TCP server
|
||||||
--udpgw-max-connections <number> Max udpgw connections, default value is 5
|
--udpgw-connections <number> Max connections for the UDP gateway, default value is 5
|
||||||
|
--udpgw-keepalive <seconds> Keepalive interval in seconds for the UDP gateway, default value is 30
|
||||||
-h, --help Print help
|
-h, --help Print help
|
||||||
-V, --version Print version
|
-V, --version Print version
|
||||||
```
|
```
|
||||||
|
|
19
src/args.rs
19
src/args.rs
|
@ -111,15 +111,20 @@ pub struct Args {
|
||||||
#[arg(long, value_name = "number", default_value = "200")]
|
#[arg(long, value_name = "number", default_value = "200")]
|
||||||
pub max_sessions: usize,
|
pub max_sessions: usize,
|
||||||
|
|
||||||
/// UDP gateway server address, similar to badvpn-udpgw
|
/// UDP gateway server address, forwards UDP packets via specified TCP server
|
||||||
#[cfg(feature = "udpgw")]
|
#[cfg(feature = "udpgw")]
|
||||||
#[arg(long, value_name = "IP:PORT")]
|
#[arg(long, value_name = "IP:PORT")]
|
||||||
pub udpgw_server: Option<SocketAddr>,
|
pub udpgw_server: Option<SocketAddr>,
|
||||||
|
|
||||||
/// Max udpgw connections, default value is 5
|
/// Max connections for the UDP gateway, default value is 5
|
||||||
#[cfg(feature = "udpgw")]
|
#[cfg(feature = "udpgw")]
|
||||||
#[arg(long, value_name = "number", requires = "udpgw_server")]
|
#[arg(long, value_name = "number", requires = "udpgw_server")]
|
||||||
pub udpgw_max_connections: Option<usize>,
|
pub udpgw_connections: Option<usize>,
|
||||||
|
|
||||||
|
/// Keepalive interval in seconds for the UDP gateway, default value is 30
|
||||||
|
#[cfg(feature = "udpgw")]
|
||||||
|
#[arg(long, value_name = "seconds", requires = "udpgw_server")]
|
||||||
|
pub udpgw_keepalive: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_tun(p: &str) -> Result<String> {
|
fn validate_tun(p: &str) -> Result<String> {
|
||||||
|
@ -166,7 +171,9 @@ impl Default for Args {
|
||||||
#[cfg(feature = "udpgw")]
|
#[cfg(feature = "udpgw")]
|
||||||
udpgw_server: None,
|
udpgw_server: None,
|
||||||
#[cfg(feature = "udpgw")]
|
#[cfg(feature = "udpgw")]
|
||||||
udpgw_max_connections: None,
|
udpgw_connections: None,
|
||||||
|
#[cfg(feature = "udpgw")]
|
||||||
|
udpgw_keepalive: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +208,8 @@ impl Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "udpgw")]
|
#[cfg(feature = "udpgw")]
|
||||||
pub fn udpgw_max_connections(&mut self, udpgw_max_connections: usize) -> &mut Self {
|
pub fn udpgw_connections(&mut self, udpgw_connections: usize) -> &mut Self {
|
||||||
self.udpgw_max_connections = Some(udpgw_max_connections);
|
self.udpgw_connections = Some(udpgw_connections);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -240,14 +240,15 @@ where
|
||||||
let mut ip_stack = ipstack::IpStack::new(ipstack_config, device);
|
let mut ip_stack = ipstack::IpStack::new(ipstack_config, device);
|
||||||
|
|
||||||
#[cfg(feature = "udpgw")]
|
#[cfg(feature = "udpgw")]
|
||||||
let udpgw_client = args.udpgw_server.as_ref().map(|addr| {
|
let udpgw_client = args.udpgw_server.map(|addr| {
|
||||||
log::info!("UDPGW enabled");
|
log::info!("UDP Gateway enabled, server: {}", addr);
|
||||||
|
use std::time::Duration;
|
||||||
let client = Arc::new(UdpGwClient::new(
|
let client = Arc::new(UdpGwClient::new(
|
||||||
mtu,
|
mtu,
|
||||||
args.udpgw_max_connections.unwrap_or(UDPGW_MAX_CONNECTIONS),
|
args.udpgw_connections.unwrap_or(UDPGW_MAX_CONNECTIONS),
|
||||||
UDPGW_KEEPALIVE_TIME,
|
args.udpgw_keepalive.map(Duration::from_secs).unwrap_or(UDPGW_KEEPALIVE_TIME),
|
||||||
args.udp_timeout,
|
args.udp_timeout,
|
||||||
*addr,
|
addr,
|
||||||
));
|
));
|
||||||
let client_keepalive = client.clone();
|
let client_keepalive = client.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
|
Loading…
Add table
Reference in a new issue