Skip to content

Commit

Permalink
Add ipv6 on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
pronebird committed Oct 29, 2024
1 parent 3370350 commit 6aaad97
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only

#[cfg(any(
target_os = "linux",
target_os = "macos",
target_os = "ios",
target_os = "android"
))]
use std::net::Ipv6Addr;
#[cfg(any(target_os = "linux", target_os = "macos"))]
use std::net::{Ipv4Addr, Ipv6Addr};
#[cfg(any(target_os = "android", target_os = "ios"))]
Expand Down Expand Up @@ -52,7 +59,12 @@ const WG_ENTRY_IPV6_ADDR: Ipv6Addr = Ipv6Addr::new(
0xfdcc, 0x9fc0, 0xe75a, 0x53c3, 0xfa25, 0x241f, 0x21c0, 0x70d0,
);

#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(
target_os = "linux",
target_os = "macos",
target_os = "android",
target_os = "ios"
))]
/// Exit IPv6 address (ULA) used by WireGuard, currently not routable.
const WG_EXIT_IPV6_ADDR: Ipv6Addr = Ipv6Addr::new(
0xfdcc, 0x9fc0, 0xe75a, 0x53c3, 0x72a5, 0xf352, 0x5475, 0x4160,
Expand Down Expand Up @@ -381,9 +393,15 @@ impl ConnectingState {

let packet_tunnel_settings = tunnel_provider::tunnel_settings::TunnelSettings {
dns_servers: shared_state.tunnel_settings.dns.ip_addresses().to_vec(),
interface_addresses: vec![IpNetwork::V4(
Ipv4Network::new(conn_data.entry.private_ipv4, 32).expect("ipv4 to ipnetwork/32"),
)],
interface_addresses: vec![
IpNetwork::V4(
Ipv4Network::new(conn_data.entry.private_ipv4, 32)
.expect("ipv4 to ipnetwork/32"),
),
IpNetwork::V6(
Ipv6Network::new(WG_EXIT_IPV6_ADDR, 128).expect("ipv6 to ipnetwork/128"),
),
],
remote_addresses: vec![conn_data.entry.endpoint.ip()],
mtu: connected_tunnel.exit_mtu(),
};
Expand Down

0 comments on commit 6aaad97

Please sign in to comment.