diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-17 19:16:14 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-20 12:43:14 +0000 |
| commit | 9c1d25cbcba7310bc2bdb5c527a74ee01c812d42 (patch) | |
| tree | 9748b69eb8737c22a7fa1084dae7f0d12946848e | |
| parent | 82557a833cf451571e1e9e5c63082e3b3db956e6 (diff) | |
| download | mullvadvpn-9c1d25cbcba7310bc2bdb5c527a74ee01c812d42.tar.xz mullvadvpn-9c1d25cbcba7310bc2bdb5c527a74ee01c812d42.zip | |
Implement `Default` for `TunConfig`
| -rw-r--r-- | talpid-core/src/tunnel/tun_provider/android/mod.rs | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/talpid-core/src/tunnel/tun_provider/android/mod.rs b/talpid-core/src/tunnel/tun_provider/android/mod.rs index 2c1c8561c7..3cf6f16cd5 100644 --- a/talpid-core/src/tunnel/tun_provider/android/mod.rs +++ b/talpid-core/src/tunnel/tun_provider/android/mod.rs @@ -66,22 +66,6 @@ pub struct AndroidTunProvider { impl AndroidTunProvider { /// Create a new AndroidTunProvider interfacing with Android's VpnService. pub fn new(context: AndroidContext, allow_lan: bool) -> Self { - // Initial configuration simply intercepts all packets. The only field that matters is - // `routes`, because it determines what must enter the tunnel. All other fields contain - // stub values. - let initial_tun_config = TunConfig { - addresses: vec![IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1))], - dns_servers: Vec::new(), - routes: vec![ - IpNetwork::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0) - .expect("Invalid IP network prefix for IPv4 address"), - IpNetwork::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), 0) - .expect("Invalid IP network prefix for IPv6 address"), - ], - required_routes: vec![], - mtu: 1380, - }; - let env = JnixEnv::from( context .jvm @@ -95,7 +79,7 @@ impl AndroidTunProvider { class: talpid_vpn_service_class, object: context.vpn_service, active_tun: None, - last_tun_config: initial_tun_config, + last_tun_config: TunConfig::default(), allow_lan, } } @@ -297,3 +281,23 @@ impl AsRawFd for VpnServiceTun { self.tunnel } } + +impl Default for TunConfig { + fn default() -> Self { + // Default configuration simply intercepts all packets. The only field that matters is + // `routes`, because it determines what must enter the tunnel. All other fields contain + // stub values. + TunConfig { + addresses: vec![IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1))], + dns_servers: Vec::new(), + routes: vec![ + IpNetwork::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0) + .expect("Invalid IP network prefix for IPv4 address"), + IpNetwork::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), 0) + .expect("Invalid IP network prefix for IPv6 address"), + ], + required_routes: vec![], + mtu: 1380, + } + } +} |
