Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DAITA to v2 on Windows #7457

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
27a6cbb
Add Windows support to libwg
dlon Jan 10, 2025
7c59c8c
Pass in interface buffer instead of allocating in libwg
dlon Jan 10, 2025
978d4b7
Build wireguard-go via wireguard-go-rs on Windows
dlon Jan 10, 2025
491fc20
Don't include maybenot_ffi on Windows
dlon Jan 13, 2025
bc888f9
Enable DAITA v2 for Windows via wireguard-go
dlon Jan 10, 2025
8eb47b6
Expose endpoint rebind functions in wireguard-go-rs
dlon Jan 13, 2025
7204d65
Handle network changes for wireguard-go (rebind endpoint socket)
dlon Jan 13, 2025
27a2ab5
Fix socket rebind on default route changes when using multihop
dlon Jan 14, 2025
1fbc794
Update build instructions to accommodate WgGo on Windows
MarkusPettersson98 Jan 14, 2025
8b4b6ad
Remove DAITA feature toggle from `wireguard-go-rs/build.rs`
MarkusPettersson98 Jan 14, 2025
5b69f1b
Fix `wireguard-go-rs` build on non-Windows platforms
MarkusPettersson98 Jan 14, 2025
63a43ff
Search for `lib.exe` in more paths
MarkusPettersson98 Jan 14, 2025
9e224e1
Do not strip prefix manually
dlon Jan 14, 2025
ff487f1
Format code
dlon Jan 14, 2025
ea3348f
Fix maybenot-ffi linkage
dlon Jan 14, 2025
35cc0a0
Don't trigger rerun if build artifacts change for wireguard-go-rs on …
dlon Jan 14, 2025
6ddda6a
Update changelog
MarkusPettersson98 Jan 15, 2025
b9972ed
Remove more use of `#[cfg(daita)]`
MarkusPettersson98 Jan 15, 2025
5cbd662
Compiling `wireguard-go-rs` from unsupported host is a hard error
MarkusPettersson98 Jan 15, 2025
e2d3563
Check out wireguard-go-rs submodule in Windows daemon workflow
dlon Jan 15, 2025
4634668
Fix comments in wireguard-go-rs
dlon Jan 15, 2025
e69d076
Update udeps workflow for libwg
dlon Jan 15, 2025
eec49ca
Compiling `wireguard-go-rs` to unsupported target arch is a hard error
MarkusPettersson98 Jan 15, 2025
b545b6e
Search for `lib.exe` when cross-compiling
MarkusPettersson98 Jan 15, 2025
500dd99
Pack libwg.dll and maybenot.dll for wireguard-go
dlon Jan 15, 2025
85ab43c
Don't pack maybenot_machines on Windows
dlon Jan 15, 2025
fdc6762
Update build instructions for Windows ARM
MarkusPettersson98 Jan 15, 2025
aff1cbe
Add more elaborate error message
MarkusPettersson98 Jan 15, 2025
c96865f
Build `maybenot` with inherited `--profile`
MarkusPettersson98 Jan 15, 2025
270ddf9
Mention zig 0.14 in build instructions
dlon Jan 16, 2025
cffb396
Add WindowsWgGo variant
dlon Jan 16, 2025
55ce109
Fix debug profile selection in wireguard-go-rs
dlon Jan 16, 2025
9380258
Exclude maybenot_ffi from toml file on Android
dlon Jan 16, 2025
f8db4a6
Log DAITA v2 request
dlon Jan 16, 2025
6aed27d
Clean up wireguard-go-rs build script
dlon Jan 16, 2025
93bb410
Explicitly target macos and linux when conditionally compiling
dlon Jan 16, 2025
35eae23
fixup! Add more elaborate error message
dlon Jan 16, 2025
92a04ff
fixup! Clean up wireguard-go-rs build script
dlon Jan 16, 2025
8cb93b5
Install zig in actions workflows
dlon Jan 16, 2025
11eebbc
Update clippy workflow
dlon Jan 16, 2025
d7109fc
Update copyright notices in libwg
dlon Jan 16, 2025
8346735
fixup! Clean up wireguard-go-rs build script
dlon Jan 16, 2025
52bf987
fixup! Clean up wireguard-go-rs build script
dlon Jan 16, 2025
29e70b1
fixup! Add more elaborate error message
dlon Jan 16, 2025
652584a
fixup! Format code
dlon Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ jobs:
sudo apt-get update
sudo apt-get install libdbus-1-dev

- name: Install msbuild
if: matrix.os == 'windows-latest'
uses: microsoft/[email protected]
with:
vs-version: 16

- name: Install latest zig
if: matrix.os == 'windows-latest'
uses: mlugg/setup-zig@v1

- name: Install Go
if: matrix.os == 'linux-latest' || matrix.os == 'macos-latest'
uses: actions/setup-go@v5
with:
go-version: 1.21.3
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/daemon.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Daemon+CLI - Build and test
on:

Check warning on line 3 in .github/workflows/daemon.yml

View workflow job for this annotation

GitHub Actions / check-formatting

3:1 [truthy] truthy value should be one of [false, true]
pull_request:
paths:
- '**'
Expand Down Expand Up @@ -130,7 +130,9 @@
uses: actions/checkout@v4

- name: Checkout submodules
run: git submodule update --init --depth=1
run: |
git submodule update --init --depth=1
git submodule update --init --recursive --depth=1 wireguard-go-rs

- name: Install Protoc
# NOTE: ARM runner already has protoc
Expand Down Expand Up @@ -183,6 +185,9 @@
with:
vs-version: 16

- name: Install latest zig
uses: mlugg/setup-zig@v1

- name: Build Windows modules
if: steps.cache-windows-modules.outputs.cache-hit != 'true'
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/desktop-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# * compiling the output from the different runners and executed platforms.
---
name: Desktop - End-to-end tests
on:

Check warning on line 10 in .github/workflows/desktop-e2e.yml

View workflow job for this annotation

GitHub Actions / check-formatting

10:1 [truthy] truthy value should be one of [false, true]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
Expand Down Expand Up @@ -147,7 +147,7 @@
!cancelled() &&
needs.prepare-matrices.outputs.linux_matrix != '[]' &&
needs.prepare-matrices.outputs.linux_matrix != ''
runs-on: [self-hosted, desktop-test, Linux] # app-test-linux

Check warning on line 150 in .github/workflows/desktop-e2e.yml

View workflow job for this annotation

GitHub Actions / check-formatting

150:49 [comments] too few spaces before comment
timeout-minutes: 240
strategy:
fail-fast: false
Expand Down Expand Up @@ -200,6 +200,8 @@
toolchain: stable
target: i686-pc-windows-msvc
default: true
- name: Install latest zig
uses: mlugg/setup-zig@v1
- name: Install msbuild
uses: microsoft/[email protected]
with:
Expand Down Expand Up @@ -232,7 +234,7 @@
needs.prepare-matrices.outputs.windows_matrix != '[]' &&
needs.prepare-matrices.outputs.windows_matrix != ''
name: Windows end-to-end tests
runs-on: [self-hosted, desktop-test, Linux] # app-test-linux

Check warning on line 237 in .github/workflows/desktop-e2e.yml

View workflow job for this annotation

GitHub Actions / check-formatting

237:49 [comments] too few spaces before comment
timeout-minutes: 240
strategy:
fail-fast: false
Expand Down Expand Up @@ -264,7 +266,7 @@
if: |
needs.prepare-matrices.outputs.macos_matrix != '[]' &&
!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'
runs-on: [self-hosted, desktop-test, macOS] # app-test-macos-arm

Check warning on line 269 in .github/workflows/desktop-e2e.yml

View workflow job for this annotation

GitHub Actions / check-formatting

269:49 [comments] too few spaces before comment
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/rust-unused-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,21 @@ jobs:
uses: actions/checkout@v4

- name: Checkout wireguard-go submodule
if: matrix.os == 'macos-latest'
run: |
git config --global --add safe.directory '*'
git submodule update --init --depth=1
git submodule update --init --recursive --depth=1 wireguard-go-rs

- name: Install msbuild
if: matrix.os == 'windows-latest'
uses: microsoft/[email protected]
with:
vs-version: 16

- name: Install latest zig
if: matrix.os == 'windows-latest'
uses: mlugg/setup-zig@v1

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
Expand Down
9 changes: 5 additions & 4 deletions BuildInstructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ on your platform please submit an issue or a pull request.

Install the `msi` hosted here: https://github.com/volta-cli/volta

- (Not Windows) Install Go (ideally version `1.21`) by following the [official
instructions](https://golang.org/doc/install). Newer versions may work
too.
- Install Go (ideally version `1.21`) by following the [official instructions](https://golang.org/doc/install).
Newer versions may work too.

- Install a protobuf compiler (version 3.15 and up), it can be installed on most major Linux distros
via the package name `protobuf-compiler`, `protobuf` on macOS via Homebrew, and on Windows
Expand Down Expand Up @@ -96,6 +95,8 @@ The host has to have the following installed:
- `bash` installed as well as a few base unix utilities, including `sed` and `tail`.
You are recommended to use [Git for Windows].

- `zig` installed and available in `%PATH%`. 0.14 or later is recommended: https://ziglang.org/download/.

- `msbuild.exe` available in `%PATH%`. If you installed Visual Studio Community edition, the
binary can be found under:

Expand Down Expand Up @@ -153,7 +154,7 @@ In addition to the above requirements:
the Electron app:

```
pushd gui
pushd desktop/packages/mullvad-vpn
npm install --target_arch=x64 grpc-tools
popd
```
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Line wrap the file at 100 chars. Th
### Added
#### Windows
- Add support for Windows ARM64.
- Add support for DAITA V2.
- Add back wireguard-go (userspace WireGuard) support.

### Changed
- (Linux and macOS only) Update to DAITA v2. The main difference is that many different machines are
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ function build {
mullvad-problem-report.exe
talpid_openvpn_plugin.dll
mullvad-setup.exe
libwg.dll
maybenot_ffi.dll
)
fi

Expand Down
3 changes: 2 additions & 1 deletion desktop/packages/mullvad-vpn/tasks/distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ function newConfig() {
),
to: '.',
},
{ from: distAssets('maybenot_machines'), to: '.' },
{ from: distAssets(path.join('${env.DIST_SUBDIR}', 'libwg.dll')), to: '.' },
{ from: distAssets(path.join('${env.DIST_SUBDIR}', 'maybenot_ffi.dll')), to: '.' },
],
},

Expand Down
1 change: 1 addition & 0 deletions talpid-tunnel-config-client/proto/ephemeralpeer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum DaitaPlatform {
macos_wg_go = 3;
ios_wg_go = 4;
android_wg_go = 5;
windows_wg_go = 6;
}

enum DaitaLevel {
Expand Down
49 changes: 17 additions & 32 deletions talpid-tunnel-config-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ mod proto {
tonic::include_proto!("ephemeralpeer");
}

#[cfg(unix)]
const DAITA_VERSION: u32 = 2;

#[derive(Debug)]
Expand Down Expand Up @@ -88,7 +87,6 @@ pub const CONFIG_SERVICE_PORT: u16 = 1337;

pub struct EphemeralPeer {
pub psk: Option<PresharedKey>,
#[cfg(unix)]
pub daita: Option<DaitaSettings>,
}

Expand Down Expand Up @@ -141,19 +139,15 @@ pub async fn request_ephemeral_peer_with(
wg_parent_pubkey: parent_pubkey.as_bytes().to_vec(),
wg_ephemeral_peer_pubkey: ephemeral_pubkey.as_bytes().to_vec(),
post_quantum: pq_request,
#[cfg(windows)]
daita: Some(proto::DaitaRequestV1 {
activate_daita: enable_daita,
}),
#[cfg(windows)]
daita_v2: None,
#[cfg(unix)]
daita: None,
#[cfg(unix)]
daita_v2: enable_daita.then(|| proto::DaitaRequestV2 {
level: i32::from(proto::DaitaLevel::LevelDefault),
platform: i32::from(get_platform()),
version: DAITA_VERSION,
daita_v2: enable_daita.then(|| {
let platform = get_platform();
log::trace!("DAITA v2 platform: {platform:?}");
proto::DaitaRequestV2 {
level: i32::from(proto::DaitaLevel::LevelDefault),
platform: i32::from(platform),
version: DAITA_VERSION,
}
}),
})
.await
Expand Down Expand Up @@ -204,30 +198,21 @@ pub async fn request_ephemeral_peer_with(
None
};

#[cfg(unix)]
{
let daita = response.daita.map(|daita| DaitaSettings {
client_machines: daita.client_machines,
max_padding_frac: daita.max_padding_frac,
max_blocking_frac: daita.max_blocking_frac,
});
if daita.is_none() && enable_daita {
return Err(Error::MissingDaitaResponse);
}
Ok(EphemeralPeer { psk, daita })
}

#[cfg(windows)]
{
Ok(EphemeralPeer { psk })
let daita = response.daita.map(|daita| DaitaSettings {
client_machines: daita.client_machines,
max_padding_frac: daita.max_padding_frac,
max_blocking_frac: daita.max_blocking_frac,
});
if daita.is_none() && enable_daita {
return Err(Error::MissingDaitaResponse);
}
Ok(EphemeralPeer { psk, daita })
}

#[cfg(unix)]
const fn get_platform() -> proto::DaitaPlatform {
use proto::DaitaPlatform;
const PLATFORM: DaitaPlatform = if cfg!(target_os = "windows") {
DaitaPlatform::WindowsNative
DaitaPlatform::WindowsWgGo
} else if cfg!(target_os = "linux") {
DaitaPlatform::LinuxWgGo
} else if cfg!(target_os = "macos") {
Expand Down
2 changes: 0 additions & 2 deletions talpid-wireguard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ tunnel-obfuscation = { path = "../tunnel-obfuscation" }
rand = "0.8.5"
surge-ping = "0.8.0"
rand_chacha = "0.3.1"

[target.'cfg(not(windows))'.dependencies]
wireguard-go-rs = { path = "../wireguard-go-rs"}

[target.'cfg(target_os="android")'.dependencies]
Expand Down
7 changes: 3 additions & 4 deletions talpid-wireguard/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ fn main() {
if target_os == "windows" {
declare_libs_dir("../dist-assets/binaries");
}
// Wireguard-Go can be used on all platforms except Windows
// Wireguard-Go can be used on all platforms
println!("cargo::rustc-check-cfg=cfg(wireguard_go)");
if matches!(target_os.as_str(), "linux" | "macos" | "android") {
println!("cargo::rustc-cfg=wireguard_go");
}
println!("cargo::rustc-cfg=wireguard_go");

// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
println!("cargo::rustc-cfg=daita");
Expand Down
2 changes: 1 addition & 1 deletion talpid-wireguard/src/connectivity/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Tunnel for MockTunnel {
#[cfg(daita)]
fn start_daita(
&mut self,
#[cfg(not(target_os = "windows"))] _: talpid_tunnel_config_client::DaitaSettings,
_: talpid_tunnel_config_client::DaitaSettings,
) -> std::result::Result<(), TunnelError> {
Ok(())
}
Expand Down
19 changes: 2 additions & 17 deletions talpid-wireguard/src/ephemeral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async fn config_ephemeral_peers_inner(
)
.await?;

#[cfg(not(target_os = "windows"))]
let mut daita = exit_ephemeral_peer.daita;

log::debug!("Retrieved ephemeral peer");
Expand Down Expand Up @@ -145,14 +144,10 @@ async fn config_ephemeral_peers_inner(
log::debug!("Successfully exchanged PSK with entry peer");

config.entry_peer.psk = entry_ephemeral_peer.psk;
#[cfg(not(target_os = "windows"))]
{
daita = entry_ephemeral_peer.daita;
}
daita = entry_ephemeral_peer.daita;
}

config.exit_peer_mut().psk = exit_ephemeral_peer.psk;
#[cfg(daita)]
if config.daita {
log::trace!("Enabling constant packet size for entry peer");
config.entry_peer.constant_packet_size = true;
Expand All @@ -170,28 +165,18 @@ async fn config_ephemeral_peers_inner(
)
.await?;

#[cfg(daita)]
if config.daita {
#[cfg(not(target_os = "windows"))]
let Some(daita) = daita
else {
let Some(daita) = daita else {
unreachable!("missing DAITA settings");
};

// Start local DAITA machines
let mut tunnel = tunnel.lock().await;
if let Some(tunnel) = tunnel.as_mut() {
#[cfg(not(target_os = "windows"))]
tunnel
.start_daita(daita)
.map_err(Error::TunnelError)
.map_err(CloseMsg::SetupError)?;

#[cfg(target_os = "windows")]
tunnel
.start_daita()
.map_err(Error::TunnelError)
.map_err(CloseMsg::SetupError)?;
}
}

Expand Down
Loading
Loading