From 54353aec133ebec95ee94f0e8a9087a55b57ce25 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Mon, 19 Feb 2024 09:42:12 +0800 Subject: [PATCH] feat: set default route for tun device - ref #1432 - Linux platform will add default route when tun device was created by default - This commit will add default route on macOS by default --- crates/shadowsocks-service/src/local/tun/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/shadowsocks-service/src/local/tun/mod.rs b/crates/shadowsocks-service/src/local/tun/mod.rs index 8f7cb6ed669f..d0edd95adf5a 100644 --- a/crates/shadowsocks-service/src/local/tun/mod.rs +++ b/crates/shadowsocks-service/src/local/tun/mod.rs @@ -182,6 +182,11 @@ impl Tun { netmask ); + // Set default route + if let Err(err) = sys::set_route_configuration(&self.device.get_ref()).await { + warn!("[TUN] tun device set route failed, error: {}", err); + } + let address_broadcast = address_net.broadcast(); let mut packet_buffer = vec![0u8; 65536 + IFF_PI_PREFIX_LEN].into_boxed_slice();