mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-19 21:39:09 +00:00
Fix routing issues described in #104
This commit is contained in:
parent
2df59ae596
commit
09994d43cc
2 changed files with 3 additions and 35 deletions
|
@ -31,7 +31,7 @@ socks5-impl = { version = "0.5" }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
tokio = { version = "1.36", features = ["full"] }
|
tokio = { version = "1.36", features = ["full"] }
|
||||||
tokio-util = "0.7"
|
tokio-util = "0.7"
|
||||||
tproxy-config = { version = ">=3.0.2", features = ["log"] }
|
tproxy-config = { version = "4.0", features = ["log"] }
|
||||||
trust-dns-proto = "0.23"
|
trust-dns-proto = "0.23"
|
||||||
tun2 = { version = "1.2", features = ["async"] }
|
tun2 = { version = "1.2", features = ["async"] }
|
||||||
udp-stream = { version = "0.0", default-features = false }
|
udp-stream = { version = "0.0", default-features = false }
|
||||||
|
|
|
@ -108,7 +108,8 @@ pub async fn desktop_run_async(args: Args, shutdown_token: tokio_util::sync::Can
|
||||||
let mut tproxy_args = TproxyArgs::new()
|
let mut tproxy_args = TproxyArgs::new()
|
||||||
.tun_dns(args.dns_addr)
|
.tun_dns(args.dns_addr)
|
||||||
.proxy_addr(args.proxy.addr)
|
.proxy_addr(args.proxy.addr)
|
||||||
.bypass_ips(&bypass_ips);
|
.bypass_ips(&bypass_ips)
|
||||||
|
.ipv6_default_route(args.ipv6_enabled);
|
||||||
|
|
||||||
#[allow(unused_mut, unused_assignments, unused_variables)]
|
#[allow(unused_mut, unused_assignments, unused_variables)]
|
||||||
let mut setup = true;
|
let mut setup = true;
|
||||||
|
@ -135,39 +136,6 @@ pub async fn desktop_run_async(args: Args, shutdown_token: tokio_util::sync::Can
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let run_ip_util = |args: String| {
|
|
||||||
tokio::process::Command::new("ip")
|
|
||||||
.args(args.split(' '))
|
|
||||||
.stdout(std::process::Stdio::null())
|
|
||||||
.stderr(std::process::Stdio::null())
|
|
||||||
.spawn()
|
|
||||||
.ok();
|
|
||||||
};
|
|
||||||
|
|
||||||
if setup && !args.ipv6_enabled {
|
|
||||||
// Remove ipv6 connectivity if not explicitly required
|
|
||||||
// TODO: remove this when upstream will get updated
|
|
||||||
run_ip_util(format!("-6 route delete ::/1 dev {}", tproxy_args.tun_name));
|
|
||||||
run_ip_util(format!("-6 route delete 80::/1 dev {}", tproxy_args.tun_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
if setup && args.unshare {
|
|
||||||
// New namespace doesn't have any other routing device by default
|
|
||||||
// So our `tun` device should act as such to make space for other proxies.
|
|
||||||
run_ip_util(format!("route delete 0.0.0.0/1 dev {}", tproxy_args.tun_name));
|
|
||||||
run_ip_util(format!("route delete 128.0.0.0/1 dev {}", tproxy_args.tun_name));
|
|
||||||
|
|
||||||
run_ip_util(format!("route add 0.0.0.0/0 dev {}", tproxy_args.tun_name));
|
|
||||||
|
|
||||||
if args.ipv6_enabled {
|
|
||||||
run_ip_util(format!("-6 route delete ::/1 dev {}", tproxy_args.tun_name));
|
|
||||||
run_ip_util(format!("-6 route delete 80::/1 dev {}", tproxy_args.tun_name));
|
|
||||||
|
|
||||||
run_ip_util(format!("-6 route add ::/0 dev {}", tproxy_args.tun_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut admin_command_args = args.admin_command.iter();
|
let mut admin_command_args = args.admin_command.iter();
|
||||||
if let Some(command) = admin_command_args.next() {
|
if let Some(command) = admin_command_args.next() {
|
||||||
let child = tokio::process::Command::new(command)
|
let child = tokio::process::Command::new(command)
|
||||||
|
|
Loading…
Add table
Reference in a new issue