Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: FreeBSD Building #1528

Merged
merged 3 commits into from
May 18, 2024
Merged

Fix: FreeBSD Building #1528

merged 3 commits into from
May 18, 2024

Conversation

splurge103
Copy link
Contributor

This pull request will fix this building errors on FreeBSD 14:

$> cargo build --features local-redir,local-socks4

Compiling shadowsocks-service v1.18.5 (shadowsocks-rust/crates/shadowsocks-service)
error[E0432]: unresolved import `super::pfvar::pfsync_state`
  --> crates/shadowsocks-service/src/local/redir/sys/unix/bsd_pf.rs:22:5
   |
22 |     pfsync_state,
   |     ^^^^^^^^^^^^
   |     |
   |     no `pfsync_state` in `local::redir::sys::unix::pfvar`
   |     help: a similar name exists in the module: `pfioc_state`

error[E0405]: cannot find trait `UdpSocketRedir` in this scope
   --> crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs:147:6
    |
147 | impl UdpSocketRedir for UdpRedirSocket {
    |      ^^^^^^^^^^^^^^
    |
   ::: crates/shadowsocks-service/src/local/redir/redir_ext.rs:49:1
    |
49  | pub trait UdpSocketRedirExt {
    | --------------------------- similarly named trait `UdpSocketRedirExt` defined here
    |
help: a trait with a similar name exists
    |
147 | impl UdpSocketRedirExt for UdpRedirSocket {
    |      ~~~~~~~~~~~~~~~~~
help: consider importing this trait
    |
1   + use crate::local::redir::redir_ext::UdpSocketRedir;
    |

error[E0425]: cannot find value `enable` in this scope
   --> crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs:287:14
    |
287 |             &enable as *const _ as *const _,
    |              ^^^^^^ not found in this scope

error[E0425]: cannot find value `enable` in this scope
   --> crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs:288:31
    |
288 |             mem::size_of_val(&enable) as libc::socklen_t,
    |                               ^^^^^^ not found in this scope

warning: unused import: `async_trait::async_trait`
  --> crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs:10:5
   |
10 | use async_trait::async_trait;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `UdpSocketRedirExt`
  --> crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs:21:38
   |
21 |         redir_ext::{RedirSocketOpts, UdpSocketRedirExt},
   |                                      ^^^^^^^^^^^^^^^^^

error[E0599]: the method `recv_dest_from` exists for struct `UdpRedirSocket`, but its trait bounds were not satisfied
   --> crates/shadowsocks-service/src/local/redir/udprelay/mod.rs:294:45
    |
294 |                 recv_result = self.listener.recv_dest_from(&mut pkt_buf) => {
    |                                             ^^^^^^^^^^^^^^ method cannot be called on `UdpRedirSocket` due to unsatisfied trait bounds
    |
   ::: crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs:30:1
    |
30  | pub struct UdpRedirSocket {
    | ------------------------- method `recv_dest_from` not found for this struct because it doesn't satisfy `_: UdpSocketRedirExt` or `_: UdpSocketRedir`
    |
note: trait bound `redir::udprelay::sys::unix::bsd::UdpRedirSocket: UdpSocketRedir` was not satisfied
   --> crates/shadowsocks-service/src/local/redir/redir_ext.rs:58:42
    |
58  | impl<S> UdpSocketRedirExt for S where S: UdpSocketRedir {}
    |         -----------------     -          ^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
note: the trait `UdpSocketRedir` must be implemented
   --> crates/shadowsocks-service/src/local/redir/redir_ext.rs:35:1
    |
35  | pub trait UdpSocketRedir {
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    = help: items from traits can only be used if the trait is implemented and in scope
note: `UdpSocketRedirExt` defines an item `recv_dest_from`, perhaps you need to implement it
   --> crates/shadowsocks-service/src/local/redir/redir_ext.rs:49:1
    |
49  | pub trait UdpSocketRedirExt {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0405, E0425, E0432, E0599.
For more information about an error, try `rustc --explain E0405`.
warning: `shadowsocks-service` (lib) generated 2 warnings
error: could not compile `shadowsocks-service` (lib) due to 5 previous errors; 2 warnings emitted

@zonyitoo
Copy link
Collaborator

zonyitoo commented May 17, 2024

FreeBSD should have PF, hmm, but pfsync_state has another name in bindgen: pfsync_state_1301. Hmm.... Ugly.

@splurge103
Copy link
Contributor Author

FreeBSD should have PF, hmm, but pfsync_state has another name in bindgen: pfsync_state_1301. Hmm.... Ugly.

In FreeBSD situation:
For TCP in TcpStreamRedirExt code use PF.tcp_natlook
PF.tcp_natlook don't need in pfsync_state_1301, they use only pfioc_natlook
For UDP code in UdpSocketRedir dont use PF.udp_natlook, they use recv_dest_from
Please check my last commit

@zonyitoo
Copy link
Collaborator

zonyitoo commented May 18, 2024

Your commit breaks macOS build.

Please fix it. I'm Ok with the other changes.

@splurge103
Copy link
Contributor Author

Your commit breaks macOS build.

Please fix it. I'm Ok with the other changes.

Already

@zonyitoo zonyitoo merged commit 6d67524 into shadowsocks:master May 18, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants