Skip to content

Commit

Permalink
fix: freebsd doesnt allow setting IPv4 options on IPv6 sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Jun 18, 2024
1 parent a27410c commit 80103b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/shadowsocks-service/src/local/redir/sys/unix/bsd_pf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use nix::ioctl_readwrite;
use once_cell::sync::Lazy;
use socket2::{Protocol, SockAddr};

use super::pfvar::{in6_addr, in_addr, pfioc_natlook, pfioc_states, sockaddr_in, sockaddr_in6, PF_OUT};
use super::pfvar::{in6_addr, in_addr, pfioc_natlook, sockaddr_in, sockaddr_in6, PF_OUT};
#[cfg(any(target_os = "macos", target_os = "ios"))]
use super::pfvar::{pf_addr, pfsync_state};
use super::pfvar::{pf_addr, pfioc_states, pfsync_state};

ioctl_readwrite!(ioc_natlook, 'D', 23, pfioc_natlook);
#[cfg(any(target_os = "macos", target_os = "ios"))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ impl UdpRedirSocket {
if is_dual_stack_addr(&addr) {
// set IP_ORIGDSTADDR before bind()

set_ip_origdstaddr(libc::IPPROTO_IP, &socket)?;
set_disable_ip_fragmentation(libc::IPPROTO_IP, &socket)?;
// NOTE: FreeBSD doesn't allow setting IPPROTO_IP level on an IPv6 socket
//
// set_ip_origdstaddr(libc::IPPROTO_IP, &socket)?;
// set_disable_ip_fragmentation(libc::IPPROTO_IP, &socket)?;

match set_ipv6_only(&socket, false) {
Ok(..) => {
Expand Down

0 comments on commit 80103b7

Please sign in to comment.