Skip to content

Commit

Permalink
FreeBSD workflow support
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Nov 24, 2024
1 parent fb180c1 commit aab6d91
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: TestFreeBSD

on:
[push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: ["stable"] # ["nightly", "beta", "stable"] #
steps:
- uses: actions/checkout@v4
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
sync: rsync
copyback: false
prepare: |
pkg install -y curl pkgconf glib
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf > install.sh
chmod +x install.sh
./install.sh -y --default-toolchain ${{ matrix.toolchain }}
run: |
. "$HOME/.cargo/env"
set -ex
# Add feature "nightly" if toolchain is nightly
if [ "${{ matrix.toolchain }}" = "nightly" ]; then
ARGS="$ARGS --features nightly"
fi
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} fmt --all -- --check
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} clippy --all-features -- -D warnings
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} build --all-features
16 changes: 8 additions & 8 deletions src/platform/freebsd/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Device {
}
use std::io::ErrorKind::AlreadyExists;
let info = "no avaiable file descriptor";
return Err(Error::Io(std::io::Error::new(AlreadyExists, info).into()));
return Err(Error::Io(std::io::Error::new(AlreadyExists, info)));
};
(tun, device_name)
}
Expand Down Expand Up @@ -173,7 +173,7 @@ impl Device {
let route = Route {
addr,
netmask: mask,
dest: dest,
dest,
};
if let Err(e) = self.set_route(route) {
log::warn!("{e:?}");
Expand Down Expand Up @@ -344,8 +344,8 @@ impl AbstractDevice for Device {

fn set_address(&mut self, value: IpAddr) -> Result<()> {
unsafe {
let mut req = self.request();
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &mut req) {
let req = self.request();
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &req) {
return Err(std::io::Error::from(err).into());
}
let previous = self.route.as_ref().ok_or(Error::InvalidConfig)?;
Expand All @@ -371,8 +371,8 @@ impl AbstractDevice for Device {

fn set_destination(&mut self, value: IpAddr) -> Result<()> {
unsafe {
let mut req = self.request();
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &mut req) {
let req = self.request();
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &req) {
return Err(std::io::Error::from(err).into());
}
let previous = self.route.as_ref().ok_or(Error::InvalidConfig)?;
Expand Down Expand Up @@ -414,8 +414,8 @@ impl AbstractDevice for Device {

fn set_netmask(&mut self, value: IpAddr) -> Result<()> {
unsafe {
let mut req = self.request();
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &mut req) {
let req = self.request();
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &req) {
return Err(std::io::Error::from(err).into());
}
let previous = self.route.as_ref().ok_or(Error::InvalidConfig)?;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/freebsd/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use libc::{c_char, c_int, c_uint, ifreq, sockaddr, IFNAMSIZ};
use nix::{ioctl_readwrite, ioctl_write_ptr};

#[allow(non_camel_case_types)]
#[allow(non_camel_case_types, dead_code)]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ctl_info {
Expand Down

0 comments on commit aab6d91

Please sign in to comment.