Skip to content

Commit aa19a28

Browse files
Add daita as a Cargo cfg variable (#6231)
* Gate DAITA compilation on `"cargo::rustc-cfg=daita"` emitted in build files per platform, instead of compilation features * Add `wireguard-go` fork as a submodule, which in turn has `maybenot` as a submodule * Use newly upstreamed `maybenot-ffi` * Fetch submodules in github actions * Update `build-wireguard-go.sh` --------- Co-authored-by: Markus Pettersson <markus.pettersson@mullvad.net>
1 parent 04ba931 commit aa19a28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+309
-902
lines changed

.github/workflows/android-app.yml

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ jobs:
118118
- name: Checkout repository
119119
if: steps.cache-relay-list.outputs.cache-hit != 'true'
120120
uses: actions/checkout@v4
121+
with:
122+
submodules: true
121123

122124
- name: Generate
123125
if: steps.cache-relay-list.outputs.cache-hit != 'true'
@@ -164,6 +166,8 @@ jobs:
164166

165167
- name: Checkout repository
166168
uses: actions/checkout@v4
169+
with:
170+
submodules: true
167171

168172
- name: Calculate native lib cache hash
169173
id: native-lib-cache-hash
@@ -232,6 +236,8 @@ jobs:
232236

233237
- name: Checkout repository
234238
uses: actions/checkout@v4
239+
with:
240+
submodules: true
235241

236242
- name: Run gradle task
237243
uses: burrunan/gradle-cache-action@v1
@@ -259,6 +265,8 @@ jobs:
259265

260266
- name: Checkout repository
261267
uses: actions/checkout@v4
268+
with:
269+
submodules: true
262270

263271
- uses: actions/download-artifact@v4
264272
with:
@@ -363,6 +371,8 @@ jobs:
363371

364372
- name: Checkout repository
365373
uses: actions/checkout@v4
374+
with:
375+
submodules: true
366376

367377
- uses: actions/download-artifact@v4
368378
with:

.github/workflows/cargo-vendor.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: true
2022

2123
- name: Install Rust
2224
uses: actions-rs/toolchain@v1.0.6

.github/workflows/clippy.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ jobs:
4343
with:
4444
repo-token: ${{ secrets.GITHUB_TOKEN }}
4545

46-
- name: Checkout binaries submodule
47-
run: git submodule update --init --depth=1 dist-assets/binaries
46+
- name: Checkout submodules
47+
run: |
48+
git submodule update --init --depth=1 dist-assets/binaries
49+
git submodule update --init --recursive --depth=1 wireguard-go-rs/libwg/wireguard-go
4850
4951
- uses: actions-rs/toolchain@v1.0.6
5052
with:
@@ -58,6 +60,12 @@ jobs:
5860
sudo apt-get update
5961
sudo apt-get install libdbus-1-dev
6062
63+
- name: Install Go
64+
if: matrix.os == 'linux-latest' || matrix.os == 'macos-latest'
65+
uses: actions/setup-go@v5
66+
with:
67+
go-version: 1.21.3
68+
6169
- name: Clippy check
6270
shell: bash
6371
env:
@@ -83,6 +91,11 @@ jobs:
8391
- name: Checkout repository
8492
uses: actions/checkout@v3
8593

94+
- name: Checkout wireguard-go submodule
95+
run: |
96+
git config --global --add safe.directory '*'
97+
git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
98+
8699
- name: Clippy check
87100
env:
88101
RUSTFLAGS: --deny warnings

.github/workflows/daemon.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ jobs:
6868
- name: Checkout repository
6969
uses: actions/checkout@v3
7070

71-
- name: Checkout binaries submodule
71+
- name: Checkout submodules
7272
run: |
7373
git config --global --add safe.directory '*'
74-
git submodule update --init --depth=1 dist-assets/binaries
74+
git submodule update --init --depth=1 dist-assets/binaries wireguard-go-rs/libwg/wireguard-go
7575
7676
# The container image already has rustup and Rust, but only the stable toolchain
7777
- name: Install Rust toolchain
@@ -86,6 +86,11 @@ jobs:
8686
- name: Checkout repository
8787
uses: actions/checkout@v2
8888

89+
- name: Checkout wireguard-go submodule
90+
run: |
91+
git config --global --add safe.directory '*'
92+
git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
93+
8994
- name: Install Protoc
9095
uses: arduino/setup-protoc@v3
9196
with:

.github/workflows/desktop-e2e.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ jobs:
103103
run: echo "HOME=/root" >> $GITHUB_ENV
104104
- name: Checkout repository
105105
uses: actions/checkout@v3
106-
- name: Checkout binaries submodule
106+
- name: Checkout submodules
107107
run: |
108108
git config --global --add safe.directory '*'
109-
git submodule update --init --depth=1 dist-assets/binaries
109+
git submodule update --init --depth=1 dist-assets/binaries wireguard-go-rs/libwg/wireguard-go
110110
- name: Build app
111111
env:
112112
USE_MOLD: false
@@ -159,9 +159,9 @@ jobs:
159159
runs-on: windows-latest
160160
steps:
161161
- name: Checkout repository
162-
uses: actions/checkout@v2
163-
- name: Checkout submodules
164-
run: git submodule update --init --depth=1
162+
uses: actions/checkout@v4
163+
with:
164+
submodules: true
165165
- name: Install Protoc
166166
uses: arduino/setup-protoc@v3
167167
with:
@@ -231,9 +231,9 @@ jobs:
231231
runs-on: [self-hosted, desktop-test, macOS] # app-test-macos-arm
232232
steps:
233233
- name: Checkout repository
234-
uses: actions/checkout@v2
235-
- name: Checkout submodules
236-
run: git submodule update --init --depth=1
234+
uses: actions/checkout@v4
235+
with:
236+
submodules: true
237237
- name: Install Go
238238
uses: actions/setup-go@v3
239239
with:

.github/workflows/frontend.yml

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- name: Checkout repository
2020
uses: actions/checkout@v3
2121

22+
- name: Checkout wireguard-go submodule
23+
run: git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
24+
2225
- name: Install Rust
2326
uses: actions-rs/toolchain@v1.0.6
2427
with:

.github/workflows/rust-supply-chain.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v3
1818

19+
- name: Checkout wireguard-go submodule
20+
run: git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
21+
1922
- name: Run cargo deny
2023
uses: EmbarkStudios/cargo-deny-action@v1
2124
with:

.github/workflows/rust-unused-dependencies.yml

+24-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
workflow_dispatch:
1111
env:
1212
# Pinning nightly just to avoid random breakage. It's fine to bump this at any time
13-
RUST_NIGHTLY_TOOLCHAIN: nightly-2024-02-06
13+
RUST_NIGHTLY_TOOLCHAIN: nightly-2024-05-07
1414
jobs:
1515
prepare-containers:
1616
runs-on: ubuntu-latest
@@ -41,17 +41,17 @@ jobs:
4141
- name: Checkout repository
4242
uses: actions/checkout@v3
4343

44-
- name: Checkout binaries submodule
44+
- name: Checkout submodules
4545
run: |
4646
git config --global --add safe.directory '*'
47-
git submodule update --init --depth=1 dist-assets/binaries
47+
git submodule update --init --depth=1 dist-assets/binaries wireguard-go-rs/libwg/wireguard-go
4848
4949
- name: Install nightly Rust toolchain
5050
run: rustup default $RUST_NIGHTLY_TOOLCHAIN
5151

5252
- uses: taiki-e/install-action@v2
5353
with:
54-
tool: cargo-udeps
54+
tool: cargo-udeps@0.1.48
5555

5656
- name: Check for unused dependencies
5757
shell: bash
@@ -72,27 +72,36 @@ jobs:
7272
- name: Checkout repository
7373
uses: actions/checkout@v3
7474

75+
- name: Checkout wireguard-go submodule
76+
run: |
77+
git config --global --add safe.directory '*'
78+
git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
79+
7580
- name: Install nightly Rust toolchain
7681
run: |
7782
rustup default $RUST_NIGHTLY_TOOLCHAIN
7883
rustup target add aarch64-linux-android
7984
8085
- uses: taiki-e/install-action@v2
8186
with:
82-
tool: cargo-udeps
87+
tool: cargo-udeps@0.1.48
8388

8489
- name: Check for unused dependencies
8590
run: cargo udeps --target aarch64-linux-android --package mullvad-jni
8691

92+
cargo-udeps-windows:
93+
runs-on: windows-latest
94+
8795
cargo-udeps:
8896
strategy:
8997
matrix:
90-
os: [macos-latest, windows-latest]
98+
os: [windows-latest, macos-latest]
9199
runs-on: ${{ matrix.os }}
92-
93100
steps:
94101
- name: Checkout repository
95-
uses: actions/checkout@v3
102+
uses: actions/checkout@v4
103+
with:
104+
submodules: true
96105

97106
- name: Install Protoc
98107
uses: arduino/setup-protoc@v3
@@ -108,7 +117,13 @@ jobs:
108117

109118
- uses: taiki-e/install-action@v2
110119
with:
111-
tool: cargo-udeps
120+
tool: cargo-udeps@0.1.48
121+
122+
- name: Install Go
123+
if: matrix.os == 'macos-latest'
124+
uses: actions/setup-go@v3
125+
with:
126+
go-version: 1.21.3
112127

113128
- name: Check for unused dependencies
114129
shell: bash

.github/workflows/rustfmt.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
- name: Checkout repository
1515
uses: actions/checkout@v3
1616

17+
- name: Checkout wireguard-go submodule
18+
run: git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
19+
1720
- name: Install nightly Rust
1821
uses: actions-rs/toolchain@v1.0.6
1922
with:

.github/workflows/translations.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v2
1818

19+
- name: Checkout wireguard-go submodule
20+
run: git submodule update --init --depth=1 wireguard-go-rs/libwg/wireguard-go
21+
1922
- name: Read volta info
2023
id: volta
2124
uses: zoexx/github-action-json-file-properties@1.0.6

.github/workflows/unicode-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
uses: actions/checkout@v3
1010

1111
- name: Checkout submodules
12-
run: git submodule update --init
12+
run: git submodule update --init --depth=1 dist-assets/binaries wireguard-go-rs/libwg/wireguard-go
1313

1414
- name: Scan for code points
1515
run: ./ci/check-trojan-source.sh .

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
/android/play-api-key.json
3838
/wireguard/libwg/libwg.exp
3939
/wireguard/libwg/exports.def
40+
/wireguard-go-rs/libwg/libwg.a
4041
**/.vs/
4142
*.bak
4243
android/.idea

Cargo.lock

+1-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.sh

-5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ else
162162
CARGO_ARGS+=(--features api-override)
163163
fi
164164

165-
# Enable DAITA on supported platforms
166-
if [[ "$(uname -s)" == "MINGW"* || "$(uname -s)" == "Linux" ]]; then
167-
CARGO_ARGS+=(--features daita)
168-
fi
169-
170165
# Make Windows builds include a manifest in the daemon binary declaring it must
171166
# be run as admin.
172167
if [[ "$(uname -s)" == "MINGW"* ]]; then

mullvad-cli/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ rust-version.workspace = true
1010
[lints]
1111
workspace = true
1212

13-
[features]
14-
daita = ["mullvad-management-interface/daita", "mullvad-types/daita", "talpid-types/daita"]
15-
1613
[[bin]]
1714
name = "mullvad"
1815
path = "src/main.rs"

mullvad-cli/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ fn main() {
1515
));
1616
res.compile().expect("Unable to generate windows resources");
1717
}
18+
let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");
19+
20+
// Enable Daita by default on Linux and Windows.
21+
println!("cargo::rustc-check-cfg=cfg(daita)");
22+
if let "linux" | "windows" = target_os.as_str() {
23+
println!(r#"cargo::rustc-cfg=daita"#);
24+
}
1825
}

mullvad-cli/src/cmds/relay.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl Relay {
542542
allowed_ips: all_of_the_internet(),
543543
endpoint: SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port),
544544
psk: None,
545-
#[cfg(feature = "daita")]
545+
#[cfg(daita)]
546546
constant_packet_size: false,
547547
},
548548
exit_peer: None,

0 commit comments

Comments
 (0)