add complete support for freebsd (#275)

add tun & websocket & wireguard support on freebsd
This commit is contained in:
Sijie.Sun
2024-08-25 00:44:45 +08:00
committed by GitHub
parent 31b26222d3
commit 89b43684d8
8 changed files with 72 additions and 200 deletions
+4 -3
View File
@@ -119,7 +119,7 @@ impl PacketProtocol {
}
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]
fn into_pi_field(self) -> Result<u16, io::Error> {
use nix::libc;
match self {
@@ -338,7 +338,7 @@ impl VirtualNic {
}
}
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos"))]
config.platform_config(|config| {
// disable packet information so we can process the header by ourselves, see tun2 impl for more details
config.packet_information(false);
@@ -513,7 +513,8 @@ impl NicCtx {
nic.link_up().await?;
nic.remove_ip(None).await?;
nic.add_ip(ipv4_addr, 24).await?;
if cfg!(target_os = "macos") {
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
{
nic.add_route(ipv4_addr, 24).await?;
}
Ok(())