Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 5 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "defguard_wireguard_rs"
version = "0.7.2"
version = "0.7.3"
edition = "2021"
rust-version = "1.80"
description = "A unified multi-platform high-level API for managing WireGuard interfaces"
Expand All @@ -22,17 +22,9 @@ x25519-dalek = { version = "2.0", features = ["getrandom", "static_secrets"] }
env_logger = "0.11"
serde_test = "1.0"

[target.'cfg(target_os = "freebsd")'.dependencies]
[target.'cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))'.dependencies]
libc = { version = "0.2", default-features = false }
nix = { version = "0.29", features = ["ioctl", "socket"] }

[target.'cfg(target_os = "macos")'.dependencies]
libc = { version = "0.2", default-features = false }
nix = { version = "0.29", features = ["ioctl", "socket"] }

[target.'cfg(target_os = "netbsd")'.dependencies]
libc = { version = "0.2", default-features = false }
nix = { version = "0.29", features = ["ioctl", "socket"] }
nix = { version = "0.30", features = ["ioctl", "socket"] }

[target.'cfg(target_os = "linux")'.dependencies]
netlink-packet-core = "0.7"
Expand All @@ -48,5 +40,7 @@ check_dependencies = []
serde = ["dep:serde"]

[profile.release]
codegen-units = 1
panic = "abort"
lto = "thin"
strip = "symbols"
7 changes: 2 additions & 5 deletions src/bsd/ifconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ type IfName = [u8; IF_NAMESIZE];

fn make_ifr_name(if_name: &str) -> IfName {
let mut ifr_name = [0u8; IF_NAMESIZE];
if_name
.bytes()
.take(IF_NAMESIZE - 1)
.enumerate()
.for_each(|(i, b)| ifr_name[i] = b);
let len = if_name.len().min(IF_NAMESIZE - 1);
ifr_name[..len].copy_from_slice(&if_name.as_bytes()[..len]);
ifr_name
}

Expand Down
8 changes: 4 additions & 4 deletions src/bsd/nvlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{error::Error, ffi::CStr, fmt};
/// `NV_HEADER_SIZE` is for both: `nvlist_header` and `nvpair_header`.
const NV_HEADER_SIZE: usize = 19;
const NV_NAME_MAX: usize = 2048;
const NVLIST_HEADER_MAGIC: u8 = 0x6c; // 'l'
const NVLIST_HEADER_MAGIC: u8 = b'l';
const NVLIST_HEADER_VERSION: u8 = 0;
// Public flags
// Perform case-insensitive lookups of provided names.
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'a> NvList<'a> {
self.items.iter().find(|(n, _)| n == &name).map(|(_, v)| v)
}

/// Get value as `bool`.
// Get value as `bool`.
// pub fn get_bool(&self, name: &str) -> Option<bool> {
// self.get(name).and_then(|value| match value {
// NvValue::Bool(boolean) => Some(*boolean),
Expand All @@ -202,7 +202,7 @@ impl<'a> NvList<'a> {
})
}

/// Get value as `&str`.
// Get value as `&str`.
// pub fn get_string(&self, name: &str) -> Option<&str> {
// self.get(name).and_then(|value| match value {
// NvValue::String(string) => Some(*string),
Expand Down Expand Up @@ -242,7 +242,7 @@ impl<'a> NvList<'a> {
self.items.push((name, NvValue::Number(number)));
}

/// Append `String` value to the list.
// Append `String` value to the list.
// pub fn append_string(&mut self, name: &'a str, string: &'a str) {
// self.items.push((name, NvValue::String(string)));
// }
Expand Down
2 changes: 1 addition & 1 deletion src/bsd/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl<Payload> RtMessage<Payload> {
}

let mut buf = [0u8; 256]; // FIXME: fixed buffer size
let len = read(socket.as_raw_fd(), &mut buf).map_err(IoError::ReadIo)?;
let len = read(socket.as_fd(), &mut buf).map_err(IoError::ReadIo)?;
if len < size_of::<Self>() {
return Err(IoError::Unpack);
}
Expand Down
4 changes: 2 additions & 2 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ impl Host {
break;
}
}
return Err(io::Error::new(io::ErrorKind::Other, "error reading UAPI"));
return Err(io::Error::other("error reading UAPI"));
}
_ => error!("Unknown UAPI keyword {}", keyword),
_ => error!("Unknown UAPI keyword {keyword}"),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ mod wireguard_interface;
extern crate log;

use std::fmt;
#[cfg(not(target_os = "windows"))]
use std::process::Output;

#[cfg(feature = "serde")]
Expand Down
Loading
Loading