Skip to content

Commit

Permalink
Merge pull request #3961 from nymtech/jon/wireguard-platform-specific
Browse files Browse the repository at this point in the history
Compartmentalize the platform specific modules in the wg crate
  • Loading branch information
octol committed Oct 5, 2023
2 parents f244cff + 750a594 commit d57a4bc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ on:

jobs:
build:
runs-on: [ self-hosted, custom-linux ]
strategy:
fail-fast: false
matrix:
os: [custom-linux, custom-runner-mac-m1]
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
# Enable sccache via environment variable
Expand All @@ -50,6 +54,7 @@ jobs:
- name: Install Dependencies (Linux)
run: sudo apt-get update && sudo apt-get -y install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools protobuf-compiler
continue-on-error: true
if: matrix.os == 'custom-linux'

- name: Check out repository code
uses: actions/checkout@v2
Expand All @@ -76,6 +81,7 @@ jobs:
args: --workspace --features wireguard

- name: Build all examples
if: matrix.os == 'custom-linux'
uses: actions-rs/cargo@v1
with:
command: build
Expand All @@ -88,13 +94,14 @@ jobs:
args: --workspace --features wireguard

- name: Run expensive tests
if: github.ref == 'refs/heads/develop' || github.event.pull_request.base.ref == 'develop' || github.event.pull_request.base.ref == 'master'
if: (github.ref == 'refs/heads/develop' || github.event.pull_request.base.ref == 'develop' || github.event.pull_request.base.ref == 'master') && matrix.os == 'custom-linux'
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --features wireguard -- --ignored

- name: Annotate with clippy checks
if: matrix.os == 'custom-linux'
uses: actions-rs/clippy-check@v1
continue-on-error: true
with:
Expand Down
14 changes: 6 additions & 8 deletions common/wireguard/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use nym_task::TaskClient;
#![cfg_attr(not(target_os = "linux"), allow(dead_code))]

pub use error::WgError;
use nym_task::TaskClient;

mod error;
#[cfg(target_os = "linux")]
mod event;
#[cfg(target_os = "linux")]
mod platform;
mod setup;
#[cfg(target_os = "linux")]
mod tun;
#[cfg(target_os = "linux")]
mod tun_device;
#[cfg(target_os = "linux")]
mod udp_listener;

// Currently the module related to setting up the virtual network device is platform specific.
#[cfg(target_os = "linux")]
use platform::linux::tun_device;

type ActivePeers =
dashmap::DashMap<std::net::SocketAddr, tokio::sync::mpsc::UnboundedSender<crate::event::Event>>;

Expand Down
1 change: 1 addition & 0 deletions common/wireguard/src/platform/linux/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub(crate) mod tun_device;
File renamed without changes.
2 changes: 2 additions & 0 deletions common/wireguard/src/platform/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[cfg(target_os = "linux")]
pub(crate) mod linux;
2 changes: 1 addition & 1 deletion common/wireguard/src/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tokio::{
time::timeout,
};

use crate::{event::Event, WgError};
use crate::{error::WgError, event::Event};

const MAX_PACKET: usize = 65535;

Expand Down
2 changes: 0 additions & 2 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ nym-statistics-common = { path = "../common/statistics" }
nym-task = { path = "../common/task" }
nym-types = { path = "../common/types" }
nym-validator-client = { path = "../common/client-libs/validator-client" }

[target.'cfg(target_os = "linux")'.dependencies]
nym-wireguard = { path = "../common/wireguard", optional = true }

[build-dependencies]
Expand Down

0 comments on commit d57a4bc

Please sign in to comment.