From 331ff1e13ced7ea1a469f59ee7fcc9ab00a0e609 Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Wed, 10 Jan 2024 11:10:48 +0800 Subject: [PATCH] add more cfg for BSD os --- doc/transparent_proxy.md | 17 +++++++++ g3keymess/src/opts.rs | 3 +- g3proxy/src/config/server/mod.rs | 35 ++++++++++++++++--- .../escape/direct_fixed/udp_connect/recv.rs | 6 ++-- .../escape/direct_fixed/udp_connect/send.rs | 6 ++-- .../src/escape/direct_fixed/udp_relay/recv.rs | 9 +++-- .../src/escape/direct_fixed/udp_relay/send.rs | 9 +++-- .../escape/proxy_socks5/udp_connect/recv.rs | 6 ++-- .../escape/proxy_socks5/udp_connect/send.rs | 6 ++-- .../src/escape/proxy_socks5/udp_relay/recv.rs | 6 ++-- .../src/escape/proxy_socks5/udp_relay/send.rs | 6 ++-- g3proxy/src/serve/mod.rs | 7 +++- g3proxy/src/serve/ops.rs | 14 ++++++-- .../socks_proxy/task/udp_associate/recv.rs | 6 ++-- .../socks_proxy/task/udp_associate/send.rs | 6 ++-- .../socks_proxy/task/udp_connect/recv.rs | 6 ++-- .../socks_proxy/task/udp_connect/send.rs | 6 ++-- lib/g3-io-ext/src/udp/copy/client.rs | 9 +++-- lib/g3-io-ext/src/udp/copy/mod.rs | 12 ++++--- lib/g3-io-ext/src/udp/copy/remote.rs | 9 +++-- lib/g3-io-ext/src/udp/ext.rs | 19 ++++++---- lib/g3-io-ext/src/udp/recv.rs | 9 +++-- lib/g3-io-ext/src/udp/relay/client.rs | 9 +++-- lib/g3-io-ext/src/udp/relay/mod.rs | 12 ++++--- lib/g3-io-ext/src/udp/relay/remote.rs | 9 +++-- lib/g3-io-ext/src/udp/send.rs | 9 +++-- lib/g3-io-ext/src/udp/split.rs | 12 ++++--- lib/g3-runtime/src/unaided.rs | 3 +- lib/g3-socket/src/tcp.rs | 4 ++- lib/g3-socket/src/udp.rs | 4 ++- lib/g3-socks/src/v5/quic.rs | 6 ++-- lib/g3-yaml/src/value/runtime.rs | 3 +- lib/g3-yaml/src/value/sched.rs | 3 +- 33 files changed, 208 insertions(+), 78 deletions(-) create mode 100644 doc/transparent_proxy.md diff --git a/doc/transparent_proxy.md b/doc/transparent_proxy.md new file mode 100644 index 00000000..595df624 --- /dev/null +++ b/doc/transparent_proxy.md @@ -0,0 +1,17 @@ +Transparent Proxy +===== + +Linux +--- + +[netfilter TPROXY](https://docs.kernel.org/networking/tproxy.html) + +FreeBSD +--- + +[ipfw forward](https://man.freebsd.org/cgi/man.cgi?query=ipfw) + +OpenBSD +--- + +[pf divert-to](https://man.openbsd.org/pf.conf.5#divert-to) diff --git a/g3keymess/src/opts.rs b/g3keymess/src/opts.rs index 56cb81f9..6b95283f 100644 --- a/g3keymess/src/opts.rs +++ b/g3keymess/src/opts.rs @@ -137,7 +137,8 @@ pub fn parse_clap() -> anyhow::Result> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "dragonfly", + target_os = "netbsd", ))] if let Some(s) = group_name.strip_prefix("core") { let mut cpu = CpuAffinity::default(); diff --git a/g3proxy/src/config/server/mod.rs b/g3proxy/src/config/server/mod.rs index 3d2429c4..657878fb 100644 --- a/g3proxy/src/config/server/mod.rs +++ b/g3proxy/src/config/server/mod.rs @@ -45,7 +45,12 @@ pub(crate) mod http_rproxy; pub(crate) mod sni_proxy; pub(crate) mod socks_proxy; pub(crate) mod tcp_stream; -#[cfg(any(target_os = "linux", target_os = "freebsd"))] +#[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd", +))] pub(crate) mod tcp_tproxy; pub(crate) mod tls_stream; @@ -133,7 +138,12 @@ pub(crate) enum AnyServerConfig { PlainQuicPort(plain_quic_port::PlainQuicPortConfig), IntelliProxy(intelli_proxy::IntelliProxyConfig), TcpStream(Box), - #[cfg(any(target_os = "linux", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" + ))] TcpTProxy(tcp_tproxy::TcpTProxyServerConfig), TlsStream(Box), SniProxy(Box), @@ -154,7 +164,12 @@ macro_rules! impl_transparent0 { AnyServerConfig::PlainQuicPort(s) => s.$f(), AnyServerConfig::IntelliProxy(s) => s.$f(), AnyServerConfig::TcpStream(s) => s.$f(), - #[cfg(any(target_os = "linux", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" + ))] AnyServerConfig::TcpTProxy(s) => s.$f(), AnyServerConfig::TlsStream(s) => s.$f(), AnyServerConfig::SniProxy(s) => s.$f(), @@ -178,7 +193,12 @@ macro_rules! impl_transparent1 { AnyServerConfig::PlainQuicPort(s) => s.$f(p), AnyServerConfig::IntelliProxy(s) => s.$f(p), AnyServerConfig::TcpStream(s) => s.$f(p), - #[cfg(any(target_os = "linux", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" + ))] AnyServerConfig::TcpTProxy(s) => s.$f(p), AnyServerConfig::TlsStream(s) => s.$f(p), AnyServerConfig::SniProxy(s) => s.$f(p), @@ -267,7 +287,12 @@ fn load_server( .context("failed to load this TcpStream server")?; Ok(AnyServerConfig::TcpStream(Box::new(server))) } - #[cfg(any(target_os = "linux", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" + ))] "tcp_tproxy" | "tcptproxy" => { let server = tcp_tproxy::TcpTProxyServerConfig::parse(map, position) .context("failed to load this TcpTProxy server")?; diff --git a/g3proxy/src/escape/direct_fixed/udp_connect/recv.rs b/g3proxy/src/escape/direct_fixed/udp_connect/recv.rs index 84305e30..b2a7fcdf 100644 --- a/g3proxy/src/escape/direct_fixed/udp_connect/recv.rs +++ b/g3proxy/src/escape/direct_fixed/udp_connect/recv.rs @@ -21,7 +21,8 @@ use g3_io_ext::{AsyncUdpRecv, UdpCopyRemoteError, UdpCopyRemoteRecv}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{RecvMsgBuf, RecvMsgHdr, UdpCopyPacket}; @@ -59,7 +60,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, diff --git a/g3proxy/src/escape/direct_fixed/udp_connect/send.rs b/g3proxy/src/escape/direct_fixed/udp_connect/send.rs index b1900795..8bb40cbb 100644 --- a/g3proxy/src/escape/direct_fixed/udp_connect/send.rs +++ b/g3proxy/src/escape/direct_fixed/udp_connect/send.rs @@ -22,7 +22,8 @@ use g3_io_ext::{AsyncUdpSend, UdpCopyRemoteError, UdpCopyRemoteSend}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{SendMsgHdr, UdpCopyPacket}; @@ -63,7 +64,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/g3proxy/src/escape/direct_fixed/udp_relay/recv.rs b/g3proxy/src/escape/direct_fixed/udp_relay/recv.rs index d9df5c52..af9c7158 100644 --- a/g3proxy/src/escape/direct_fixed/udp_relay/recv.rs +++ b/g3proxy/src/escape/direct_fixed/udp_relay/recv.rs @@ -22,7 +22,8 @@ use g3_io_ext::{AsyncUdpRecv, UdpRelayRemoteError, UdpRelayRemoteRecv}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{RecvMsgBuf, RecvMsgHdr, UdpRelayPacket}; use g3_types::net::UpstreamAddr; @@ -98,7 +99,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( inner: &mut T, @@ -150,7 +152,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, diff --git a/g3proxy/src/escape/direct_fixed/udp_relay/send.rs b/g3proxy/src/escape/direct_fixed/udp_relay/send.rs index d473e369..7df6ac19 100644 --- a/g3proxy/src/escape/direct_fixed/udp_relay/send.rs +++ b/g3proxy/src/escape/direct_fixed/udp_relay/send.rs @@ -24,7 +24,8 @@ use g3_io_ext::{AsyncUdpSend, UdpRelayRemoteError, UdpRelayRemoteSend}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{SendMsgHdr, UdpRelayPacket}; use g3_resolver::{ResolveError, ResolveLocalError}; @@ -269,7 +270,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( inner: &mut T, @@ -319,7 +321,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/g3proxy/src/escape/proxy_socks5/udp_connect/recv.rs b/g3proxy/src/escape/proxy_socks5/udp_connect/recv.rs index 85afbb18..efcff39a 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_connect/recv.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_connect/recv.rs @@ -25,7 +25,8 @@ use g3_io_ext::{AsyncUdpRecv, UdpCopyRemoteError, UdpCopyRemoteRecv}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{RecvMsgBuf, RecvMsgHdr, UdpCopyPacket}; use g3_socks::v5::UdpInput; @@ -84,7 +85,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, diff --git a/g3proxy/src/escape/proxy_socks5/udp_connect/send.rs b/g3proxy/src/escape/proxy_socks5/udp_connect/send.rs index 50cec2ee..8e07fce5 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_connect/send.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_connect/send.rs @@ -22,7 +22,8 @@ use g3_io_ext::{AsyncUdpSend, UdpCopyRemoteError, UdpCopyRemoteSend}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{SendMsgHdr, UdpCopyPacket}; use g3_socks::v5::UdpOutput; @@ -77,7 +78,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/g3proxy/src/escape/proxy_socks5/udp_relay/recv.rs b/g3proxy/src/escape/proxy_socks5/udp_relay/recv.rs index 9ed90817..9131acc3 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_relay/recv.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_relay/recv.rs @@ -26,7 +26,8 @@ use g3_io_ext::{AsyncUdpRecv, UdpRelayRemoteError, UdpRelayRemoteRecv}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{RecvMsgBuf, RecvMsgHdr, UdpRelayPacket}; use g3_socks::v5::UdpInput; @@ -103,7 +104,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, diff --git a/g3proxy/src/escape/proxy_socks5/udp_relay/send.rs b/g3proxy/src/escape/proxy_socks5/udp_relay/send.rs index 11deee3e..29eee8ef 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_relay/send.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_relay/send.rs @@ -23,7 +23,8 @@ use g3_io_ext::{AsyncUdpSend, UdpRelayRemoteError, UdpRelayRemoteSend}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{SendMsgHdr, UdpRelayPacket}; use g3_socks::v5::SocksUdpHeader; @@ -82,7 +83,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/g3proxy/src/serve/mod.rs b/g3proxy/src/serve/mod.rs index dc7e85ed..49e93821 100644 --- a/g3proxy/src/serve/mod.rs +++ b/g3proxy/src/serve/mod.rs @@ -54,7 +54,12 @@ mod http_rproxy; mod sni_proxy; mod socks_proxy; mod tcp_stream; -#[cfg(any(target_os = "linux", target_os = "freebsd"))] +#[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" +))] mod tcp_tproxy; mod tls_stream; diff --git a/g3proxy/src/serve/ops.rs b/g3proxy/src/serve/ops.rs index 71e0a001..09e85684 100644 --- a/g3proxy/src/serve/ops.rs +++ b/g3proxy/src/serve/ops.rs @@ -42,7 +42,12 @@ use super::http_rproxy::HttpRProxyServer; use super::sni_proxy::SniProxyServer; use super::socks_proxy::SocksProxyServer; use super::tcp_stream::TcpStreamServer; -#[cfg(any(target_os = "linux", target_os = "freebsd"))] +#[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" +))] use super::tcp_tproxy::TcpTProxyServer; use super::tls_stream::TlsStreamServer; @@ -296,7 +301,12 @@ fn spawn_new_unlocked(config: AnyServerConfig) -> anyhow::Result<()> { AnyServerConfig::PlainQuicPort(c) => PlainQuicPort::prepare_initial(c)?, AnyServerConfig::IntelliProxy(c) => IntelliProxy::prepare_initial(c)?, AnyServerConfig::TcpStream(c) => TcpStreamServer::prepare_initial(*c)?, - #[cfg(any(target_os = "linux", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd" + ))] AnyServerConfig::TcpTProxy(c) => TcpTProxyServer::prepare_initial(c)?, AnyServerConfig::TlsStream(c) => TlsStreamServer::prepare_initial(*c)?, AnyServerConfig::SniProxy(c) => SniProxyServer::prepare_initial(*c)?, diff --git a/g3proxy/src/serve/socks_proxy/task/udp_associate/recv.rs b/g3proxy/src/serve/socks_proxy/task/udp_associate/recv.rs index 4283b9f1..3ca7acc1 100644 --- a/g3proxy/src/serve/socks_proxy/task/udp_associate/recv.rs +++ b/g3proxy/src/serve/socks_proxy/task/udp_associate/recv.rs @@ -24,7 +24,8 @@ use g3_io_ext::{AsyncUdpRecv, UdpRelayClientError, UdpRelayClientRecv}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{RecvMsgBuf, RecvMsgHdr, UdpRelayPacket}; use g3_socks::v5::UdpInput; @@ -237,7 +238,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, diff --git a/g3proxy/src/serve/socks_proxy/task/udp_associate/send.rs b/g3proxy/src/serve/socks_proxy/task/udp_associate/send.rs index 3a586d4d..ef260c65 100644 --- a/g3proxy/src/serve/socks_proxy/task/udp_associate/send.rs +++ b/g3proxy/src/serve/socks_proxy/task/udp_associate/send.rs @@ -23,7 +23,8 @@ use g3_io_ext::{AsyncUdpSend, UdpRelayClientError, UdpRelayClientSend}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{SendMsgHdr, UdpRelayPacket}; use g3_socks::v5::SocksUdpHeader; @@ -79,7 +80,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/g3proxy/src/serve/socks_proxy/task/udp_connect/recv.rs b/g3proxy/src/serve/socks_proxy/task/udp_connect/recv.rs index 37160287..402322f1 100644 --- a/g3proxy/src/serve/socks_proxy/task/udp_connect/recv.rs +++ b/g3proxy/src/serve/socks_proxy/task/udp_connect/recv.rs @@ -24,7 +24,8 @@ use g3_io_ext::{AsyncUdpRecv, UdpCopyClientError, UdpCopyClientRecv}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{RecvMsgBuf, RecvMsgHdr, UdpCopyPacket}; use g3_socks::v5::UdpInput; @@ -163,7 +164,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, diff --git a/g3proxy/src/serve/socks_proxy/task/udp_connect/send.rs b/g3proxy/src/serve/socks_proxy/task/udp_connect/send.rs index f0605117..153d96f3 100644 --- a/g3proxy/src/serve/socks_proxy/task/udp_connect/send.rs +++ b/g3proxy/src/serve/socks_proxy/task/udp_connect/send.rs @@ -22,7 +22,8 @@ use g3_io_ext::{AsyncUdpSend, UdpCopyClientError, UdpCopyClientSend}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use g3_io_ext::{SendMsgHdr, UdpCopyPacket}; use g3_socks::v5::UdpOutput; @@ -77,7 +78,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/copy/client.rs b/lib/g3-io-ext/src/udp/copy/client.rs index 5b383929..9f44ae67 100644 --- a/lib/g3-io-ext/src/udp/copy/client.rs +++ b/lib/g3-io-ext/src/udp/copy/client.rs @@ -23,7 +23,8 @@ use thiserror::Error; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::UdpCopyPacket; @@ -58,7 +59,8 @@ pub trait UdpCopyClientRecv { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -79,7 +81,8 @@ pub trait UdpCopyClientSend { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/copy/mod.rs b/lib/g3-io-ext/src/udp/copy/mod.rs index 7df3ac7a..6c428cfe 100644 --- a/lib/g3-io-ext/src/udp/copy/mod.rs +++ b/lib/g3-io-ext/src/udp/copy/mod.rs @@ -130,7 +130,8 @@ impl<'a, T: UdpCopyClientRecv + ?Sized> UdpCopyRecv for ClientRecv<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -164,7 +165,8 @@ impl<'a, T: UdpCopyRemoteRecv + ?Sized> UdpCopyRecv for RemoteRecv<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -224,7 +226,8 @@ impl<'a, T: UdpCopyClientSend + ?Sized> UdpCopySend for ClientSend<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, @@ -254,7 +257,8 @@ impl<'a, T: UdpCopyRemoteSend + ?Sized> UdpCopySend for RemoteSend<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/copy/remote.rs b/lib/g3-io-ext/src/udp/copy/remote.rs index ab10e01e..3c80fb51 100644 --- a/lib/g3-io-ext/src/udp/copy/remote.rs +++ b/lib/g3-io-ext/src/udp/copy/remote.rs @@ -23,7 +23,8 @@ use thiserror::Error; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::UdpCopyPacket; @@ -58,7 +59,8 @@ pub trait UdpCopyRemoteRecv { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -79,7 +81,8 @@ pub trait UdpCopyRemoteSend { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/ext.rs b/lib/g3-io-ext/src/udp/ext.rs index 7116baf7..acb2995b 100644 --- a/lib/g3-io-ext/src/udp/ext.rs +++ b/lib/g3-io-ext/src/udp/ext.rs @@ -23,7 +23,8 @@ use std::task::{ready, Context, Poll}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use nix::sys::socket::{recvmmsg, sendmmsg, MultiHeaders}; use nix::sys::socket::{recvmsg, sendmsg, MsgFlags, SockaddrStorage}; @@ -97,7 +98,8 @@ pub trait UdpSocketExt { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_sendmsg( &self, @@ -109,7 +111,8 @@ pub trait UdpSocketExt { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_recvmsg( &self, @@ -130,7 +133,9 @@ impl UdpSocketExt for UdpSocket { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd", ))] let flags: MsgFlags = MsgFlags::MSG_DONTWAIT | MsgFlags::MSG_NOSIGNAL; #[cfg(target_os = "macos")] @@ -194,7 +199,8 @@ impl UdpSocketExt for UdpSocket { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_sendmsg( &self, @@ -230,7 +236,8 @@ impl UdpSocketExt for UdpSocket { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_recvmsg( &self, diff --git a/lib/g3-io-ext/src/udp/recv.rs b/lib/g3-io-ext/src/udp/recv.rs index a9a9fc20..bd883258 100644 --- a/lib/g3-io-ext/src/udp/recv.rs +++ b/lib/g3-io-ext/src/udp/recv.rs @@ -27,7 +27,8 @@ use tokio::time::{Instant, Sleep}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::{RecvMsgBuf, RecvMsgHdr}; use crate::limit::{DatagramLimitInfo, DatagramLimitResult}; @@ -46,7 +47,8 @@ pub trait AsyncUdpRecv { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_recvmsg( &mut self, @@ -156,7 +158,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_recvmsg( &mut self, diff --git a/lib/g3-io-ext/src/udp/relay/client.rs b/lib/g3-io-ext/src/udp/relay/client.rs index 70c61161..c348fad0 100644 --- a/lib/g3-io-ext/src/udp/relay/client.rs +++ b/lib/g3-io-ext/src/udp/relay/client.rs @@ -25,7 +25,8 @@ use g3_types::net::UpstreamAddr; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::UdpRelayPacket; @@ -62,7 +63,8 @@ pub trait UdpRelayClientRecv { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -84,7 +86,8 @@ pub trait UdpRelayClientSend { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/relay/mod.rs b/lib/g3-io-ext/src/udp/relay/mod.rs index 88e4d054..167709a0 100644 --- a/lib/g3-io-ext/src/udp/relay/mod.rs +++ b/lib/g3-io-ext/src/udp/relay/mod.rs @@ -145,7 +145,8 @@ impl<'a, T: UdpRelayClientRecv + ?Sized> UdpRelayRecv for ClientRecv<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -180,7 +181,8 @@ impl<'a, T: UdpRelayRemoteRecv + ?Sized> UdpRelayRecv for RemoteRecv<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -240,7 +242,8 @@ impl<'a, T: UdpRelayClientSend + ?Sized> UdpRelaySend for ClientSend<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, @@ -270,7 +273,8 @@ impl<'a, T: UdpRelayRemoteSend + ?Sized> UdpRelaySend for RemoteSend<'a, T> { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/relay/remote.rs b/lib/g3-io-ext/src/udp/relay/remote.rs index bb945fd3..900726ee 100644 --- a/lib/g3-io-ext/src/udp/relay/remote.rs +++ b/lib/g3-io-ext/src/udp/relay/remote.rs @@ -27,7 +27,8 @@ use g3_types::net::UpstreamAddr; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::UdpRelayPacket; @@ -72,7 +73,8 @@ pub trait UdpRelayRemoteRecv { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv_packets( &mut self, @@ -94,7 +96,8 @@ pub trait UdpRelayRemoteSend { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send_packets( &mut self, diff --git a/lib/g3-io-ext/src/udp/send.rs b/lib/g3-io-ext/src/udp/send.rs index 338ad151..4891e7dd 100644 --- a/lib/g3-io-ext/src/udp/send.rs +++ b/lib/g3-io-ext/src/udp/send.rs @@ -27,7 +27,8 @@ use tokio::time::{Instant, Sleep}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::SendMsgHdr; use crate::limit::{DatagramLimitInfo, DatagramLimitResult}; @@ -54,7 +55,8 @@ pub trait AsyncUdpSend { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_sendmsg( &mut self, @@ -190,7 +192,8 @@ where target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_sendmsg( &mut self, diff --git a/lib/g3-io-ext/src/udp/split.rs b/lib/g3-io-ext/src/udp/split.rs index 2da7cf7d..1319a33c 100644 --- a/lib/g3-io-ext/src/udp/split.rs +++ b/lib/g3-io-ext/src/udp/split.rs @@ -20,7 +20,8 @@ use std::fmt; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use std::io::IoSliceMut; use std::io::{self, IoSlice}; @@ -36,7 +37,8 @@ use super::{AsyncUdpRecv, AsyncUdpSend, UdpSocketExt}; target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] use super::{RecvMsgBuf, RecvMsgHdr, SendMsgHdr}; @@ -113,7 +115,8 @@ impl AsyncUdpSend for SendHalf { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_sendmsg( &mut self, @@ -155,7 +158,8 @@ impl AsyncUdpRecv for RecvHalf { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_batch_recvmsg( &mut self, diff --git a/lib/g3-runtime/src/unaided.rs b/lib/g3-runtime/src/unaided.rs index 8e5df6ef..dda21033 100644 --- a/lib/g3-runtime/src/unaided.rs +++ b/lib/g3-runtime/src/unaided.rs @@ -73,7 +73,8 @@ impl UnaidedRuntimeConfig { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "dragonfly", + target_os = "netbsd", ))] pub fn set_mapped_sched_affinity(&mut self) -> anyhow::Result<()> { let n = self.num_threads(); diff --git a/lib/g3-socket/src/tcp.rs b/lib/g3-socket/src/tcp.rs index dd45b952..a64a09b3 100644 --- a/lib/g3-socket/src/tcp.rs +++ b/lib/g3-socket/src/tcp.rs @@ -128,7 +128,9 @@ fn new_tcp_socket(family: AddressFamily) -> io::Result { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd", ))] fn new_tcp_socket(family: AddressFamily) -> io::Result { Socket::new(Domain::from(family), Type::STREAM.nonblocking(), None) diff --git a/lib/g3-socket/src/udp.rs b/lib/g3-socket/src/udp.rs index c82d8427..6e672b1f 100644 --- a/lib/g3-socket/src/udp.rs +++ b/lib/g3-socket/src/udp.rs @@ -212,7 +212,9 @@ fn new_nonblocking_udp_socket(family: AddressFamily) -> io::Result { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd", ))] fn new_nonblocking_udp_socket(family: AddressFamily) -> io::Result { Socket::new(Domain::from(family), Type::DGRAM.nonblocking(), None) diff --git a/lib/g3-socks/src/v5/quic.rs b/lib/g3-socks/src/v5/quic.rs index 6f9fa5c3..ea5cb62e 100644 --- a/lib/g3-socks/src/v5/quic.rs +++ b/lib/g3-socks/src/v5/quic.rs @@ -180,7 +180,8 @@ impl AsyncUdpSocket for Socks5UdpSocket { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_send( &self, @@ -266,7 +267,8 @@ impl AsyncUdpSocket for Socks5UdpSocket { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "netbsd" + target_os = "netbsd", + target_os = "openbsd", ))] fn poll_recv( &self, diff --git a/lib/g3-yaml/src/value/runtime.rs b/lib/g3-yaml/src/value/runtime.rs index 7a32f1e5..e6d1cca7 100644 --- a/lib/g3-yaml/src/value/runtime.rs +++ b/lib/g3-yaml/src/value/runtime.rs @@ -45,7 +45,8 @@ pub fn as_unaided_runtime_config(v: &Yaml) -> anyhow::Result anyhow::Result { use anyhow::{anyhow, Context};