Skip to content

Commit

Permalink
Merge branch 'win-daita-v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Jan 24, 2025
2 parents ff88a77 + 0d5ba1a commit 654de1c
Show file tree
Hide file tree
Showing 29 changed files with 817 additions and 206 deletions.
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
Expand Up @@ -130,7 +130,9 @@ jobs:
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 @@ jobs:
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 @@ -200,6 +200,8 @@ jobs:
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
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
/dist-assets/mullvad-setup.exe
/dist-assets/mullvad-problem-report
/dist-assets/mullvad-problem-report.exe
/dist-assets/libwg.dll
/dist-assets/maybenot_ffi.dll
/dist-assets/libtalpid_openvpn_plugin.dylib
/dist-assets/libtalpid_openvpn_plugin.so
/dist-assets/talpid_openvpn_plugin.dll
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
50 changes: 18 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,22 @@ 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
// FIXME: wggo
DaitaPlatform::LinuxWgGo
} 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 @@ -30,8 +30,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 @@ -121,7 +121,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

0 comments on commit 654de1c

Please sign in to comment.