Compare commits

..

14 Commits

Author SHA1 Message Date
Alice Bowman
60a411e363 removed m1 cargo test 2024-06-17 15:39:43 +02:00
Alice Bowman
caf8801004 trialing cargo m1 test 2024-06-13 15:42:02 +02:00
Alice Bowman
858c0904ad refactored different cargo os tests into an array 2024-06-13 15:19:20 +02:00
Alice Bowman
e9838722b0 changed qc arm test to mac-14 to avoid bug 2024-06-13 15:12:34 +02:00
Alice Bowman
69043fbae7 added Mac ARM cargo test 2024-06-13 15:01:20 +02:00
Prabhpreet Dua
a70b71d509 Include uncommited changes 2024-06-13 17:35:10 +05:30
Prabhpreet Dua
96bed38ad0 Enable privileged only on linux 2024-06-13 17:34:48 +05:30
Prabhpreet Dua
a75d7a53e0 Add cfg flag to bin .rs files 2024-06-13 17:19:57 +05:30
Prabhpreet Dua
c4314c0eff Limit wireguard broker privledged/socket handler to linux 2024-06-13 17:13:00 +05:30
Alice Bowman
511a59fe1b Alter target OS for mod.rs 2024-06-13 13:18:23 +02:00
Alice Bowman
5e4a7c3b7f netlink.rs and cargo.toml features re: xplatform 2024-06-13 13:07:51 +02:00
Alice Bowman
139e62d1fb fixed indentation 2024-06-13 12:34:06 +02:00
Alice Bowman
c417fafe2a fixed qc-yaml test name 2024-06-13 12:30:56 +02:00
Alice Bowman
8f4141a159 added cargo-test runner for macos 86-64 2024-06-13 12:27:58 +02:00
11 changed files with 86 additions and 106 deletions

View File

@@ -1,33 +0,0 @@
#!/bin/bash
iterations=$1
sleep_time=$2
PWD=$(pwd)
EXEC=$PWD/target/release/rosenpass
LOGS=$PWD/output/logs
mkdir -p output/logs
run_command() {
local file=$1
local log_file="$2"
($EXEC exchange-config $file 2>&1 | sed "s/^/[$2] /" | tee -a $log_file) &
echo $!
}
pids=()
(cd output/dut && run_command "configs/dut-$iterations.toml" "dut.log") & piddut=$!
for (( x=0; x<$iterations; x++ )); do
(cd output/ate && run_command "configs/ate-$x.toml" "ate-$x.log") & pids+=($!)
done
sleep $sleep_time
lsof -i :9999 | awk 'NR!=1 {print $2}' | xargs kill
for (( x=0; x<$iterations; x++ )); do
port=$((x + 50000))
lsof -i :$port | awk 'NR!=1 {print $2}' | xargs kill
done

View File

@@ -110,7 +110,12 @@ jobs:
- run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items
cargo-test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13]
# - ubuntu is x86-64
# - macos-13 is also x86-64 architecture
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3

View File

@@ -1,19 +0,0 @@
name: QC
on:
pull_request:
push:
branches: [main]
permissions:
checks: write
contents: read
jobs:
multi-peer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo build --bin rosenpass --release
- run: python misc/generate_configs.py
- run: chmod +x .ci/run-regression.sh
- run: .ci/run-regression.sh 100 20

2
.gitignore vendored
View File

@@ -20,5 +20,3 @@ _markdown_*
**/result
**/result-*
.direnv
/output

14
Cargo.lock generated
View File

@@ -1066,6 +1066,12 @@ version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.9"
@@ -2325,6 +2331,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "take-until"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4e17d8598067a8c134af59cd33c1c263470e089924a11ab61cf61690919fe3b"
[[package]]
name = "tempfile"
version = "3.10.1"
@@ -2857,8 +2869,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ba4e9811befc20af3b6efb15924a7238ee5e8e8706a196576462a00b9f1af1"
dependencies = [
"derive_builder 0.10.2",
"hex",
"libc",
"neli",
"take-until",
"thiserror",
]

View File

@@ -77,6 +77,6 @@ procspawn = {version = "1.0.0", features= ["test-support"]}
#Broker dependencies (might need cleanup or changes)
wireguard-uapi = "3.0.0"
wireguard-uapi = { version = "3.0.0", features = ["xplatform"] }
command-fds = "0.2.3"
rustix = { version = "0.38.27", features = ["net"] }

View File

@@ -1,14 +1,14 @@
from pathlib import Path
from subprocess import run
import os
config = dict(
peer_counts=[1, 5, 10, 50, 100, 500],
peer_count_max=100,
ate_ip="127.0.0.1",
dut_ip="127.0.0.1",
ate_ip="192.168.2.1",
dut_ip="192.168.2.4",
dut_port=9999,
path_to_rosenpass_bin=os.getcwd() + "/target/release/rosenpass",
path_to_rosenpass_bin="/Users/user/src/rosenppass/rosenpass/target/debug/rosenpass",
)
print(config)

View File

@@ -44,6 +44,7 @@ path = "src/bin/priviledged.rs"
test = false
doc = false
required-features=["enable_broker_api"]
cfg = { target_os = "linux" }
[[bin]]
name = "rosenpass-wireguard-broker-socket-handler"
@@ -51,3 +52,4 @@ test = false
path = "src/bin/socket_handler.rs"
doc = false
required-features=["enable_broker_api"]
cfg = { target_os = "linux" }

View File

@@ -1,56 +1,67 @@
use std::io::{stdin, stdout, Read, Write};
use std::result::Result;
fn main() {
#[cfg(target_os = "linux")]
linux::main().unwrap();
use rosenpass_wireguard_broker::api::msgs;
use rosenpass_wireguard_broker::api::server::BrokerServer;
use rosenpass_wireguard_broker::brokers::netlink as wg;
#[derive(thiserror::Error, Debug)]
pub enum BrokerAppError {
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
WgConnectError(#[from] wg::ConnectError),
#[error(transparent)]
WgSetPskError(#[from] wg::SetPskError),
#[error("Oversized message {}; something about the request is fatally wrong", .0)]
OversizedMessage(u64),
#[cfg(not(target_os = "linux"))]
panic!("This binary is only supported on Linux");
}
fn main() -> Result<(), BrokerAppError> {
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
#[cfg(target_os = "linux")]
pub mod linux {
use std::io::{stdin, stdout, Read, Write};
use std::result::Result;
let mut stdin = stdin().lock();
let mut stdout = stdout().lock();
loop {
// Read the message length
let mut len = [0u8; 8];
stdin.read_exact(&mut len)?;
use rosenpass_wireguard_broker::api::msgs;
use rosenpass_wireguard_broker::api::server::BrokerServer;
use rosenpass_wireguard_broker::brokers::netlink as wg;
// Parse the message length
let len = u64::from_le_bytes(len);
if (len as usize) > msgs::REQUEST_MSG_BUFFER_SIZE {
return Err(BrokerAppError::OversizedMessage(len));
}
#[derive(thiserror::Error, Debug)]
pub enum BrokerAppError {
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
WgConnectError(#[from] wg::ConnectError),
#[error(transparent)]
WgSetPskError(#[from] wg::SetPskError),
#[error("Oversized message {}; something about the request is fatally wrong", .0)]
OversizedMessage(u64),
}
// Read the message itself
let mut req_buf = [0u8; msgs::REQUEST_MSG_BUFFER_SIZE];
let req_buf = &mut req_buf[..(len as usize)];
stdin.read_exact(req_buf)?;
pub fn main() -> Result<(), BrokerAppError> {
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
// Process the message
let mut res_buf = [0u8; msgs::RESPONSE_MSG_BUFFER_SIZE];
let res = match broker.handle_message(req_buf, &mut res_buf) {
Ok(len) => &res_buf[..len],
Err(e) => {
eprintln!("Error processing message for wireguard PSK broker: {e:?}");
continue;
let mut stdin = stdin().lock();
let mut stdout = stdout().lock();
loop {
// Read the message length
let mut len = [0u8; 8];
stdin.read_exact(&mut len)?;
// Parse the message length
let len = u64::from_le_bytes(len);
if (len as usize) > msgs::REQUEST_MSG_BUFFER_SIZE {
return Err(BrokerAppError::OversizedMessage(len));
}
};
// Write the response
stdout.write_all(&(res.len() as u64).to_le_bytes())?;
stdout.write_all(&res)?;
stdout.flush()?;
// Read the message itself
let mut req_buf = [0u8; msgs::REQUEST_MSG_BUFFER_SIZE];
let req_buf = &mut req_buf[..(len as usize)];
stdin.read_exact(req_buf)?;
// Process the message
let mut res_buf = [0u8; msgs::RESPONSE_MSG_BUFFER_SIZE];
let res = match broker.handle_message(req_buf, &mut res_buf) {
Ok(len) => &res_buf[..len],
Err(e) => {
eprintln!("Error processing message for wireguard PSK broker: {e:?}");
continue;
}
};
// Write the response
stdout.write_all(&(res.len() as u64).to_le_bytes())?;
stdout.write_all(&res)?;
stdout.flush()?;
}
}
}

View File

@@ -1,6 +1,6 @@
#[cfg(feature = "enable_broker_api")]
pub mod mio_client;
#[cfg(feature = "enable_broker_api")]
#[cfg(all(feature = "enable_broker_api", target_os = "linux"))]
pub mod netlink;
pub mod native_unix;

View File

@@ -1,3 +1,5 @@
#![cfg(target_os = "linux")]
use std::fmt::Debug;
use wireguard_uapi::linux as wg;