summaryrefslogtreecommitdiffhomepage
path: root/wireguard-go-rs/src
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2024-10-09 13:43:50 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2024-11-22 17:42:38 +0100
commit848ddea38dcd93a1cf1575f87f8fada316dff590 (patch)
tree855e9ef69fbd3f1e9e3943cb2c15502190f76cca /wireguard-go-rs/src
parent734abdd7fcafa3d1b4553460de1b2199d4043b51 (diff)
downloadmullvadvpn-848ddea38dcd93a1cf1575f87f8fada316dff590.tar.xz
mullvadvpn-848ddea38dcd93a1cf1575f87f8fada316dff590.zip
Add initial multihop config on Android
- Add some minor wireguard go changes
Diffstat (limited to 'wireguard-go-rs/src')
-rw-r--r--wireguard-go-rs/src/lib.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/wireguard-go-rs/src/lib.rs b/wireguard-go-rs/src/lib.rs
index 2a994a1443..321189ff5c 100644
--- a/wireguard-go-rs/src/lib.rs
+++ b/wireguard-go-rs/src/lib.rs
@@ -112,19 +112,21 @@ impl Tunnel {
/// The `logging_callback` let's you provide a Rust function that receives any logging output
/// from wireguard-go. `logging_context` is a value that will be passed to each invocation of
/// `logging_callback`.
+ #[cfg(target_os = "android")]
pub fn turn_on_multihop(
- #[cfg(not(target_os = "android"))] mtu: isize,
- settings: &CStr,
+ exit_settings: &CStr,
+ entry_settings: &CStr,
+ private_ip: &CStr,
device: Fd,
logging_callback: Option<LoggingCallback>,
logging_context: LoggingContext,
) -> Result<Self, Error> {
// SAFETY: pointer is valid for the the lifetime of this function
let code = unsafe {
- ffi::wgTurnOn(
- #[cfg(not(target_os = "android"))]
- mtu,
- settings.as_ptr(),
+ ffi::wgTurnOnMultihop(
+ exit_settings.as_ptr(),
+ entry_settings.as_ptr(),
+ private_ip.as_ptr(),
device,
logging_callback,
logging_context,
@@ -287,6 +289,22 @@ mod ffi {
logging_context: LoggingContext,
) -> i32;
+ /// Creates a new wireguard tunnel, uses the specific interface name, and file descriptors
+ /// for the tunnel device and logging. For targets other than android, this also takes an
+ /// MTU value.
+ ///
+ /// Positive return values are tunnel handles for this specific wireguard tunnel instance.
+ /// Negative return values signify errors.
+ pub fn wgTurnOnMultihop(
+ exit_settings: *const c_char,
+ entry_settings: *const c_char,
+ private_ip: *const c_char,
+ fd: Fd,
+ logging_callback: Option<LoggingCallback>,
+ logging_context: LoggingContext,
+ ) -> i32;
+
+
/// Pass a handle that was created by wgTurnOn to stop a wireguard tunnel.
///
/// Negative return values signify errors.