Skip to content

Commit

Permalink
Merge #835
Browse files Browse the repository at this point in the history
835: Add socket options for IP_TRANSPARENT / BIND_ANY r=asomers a=justinlatimer

Add socket options for implementing a transparent proxy.
Sources:
[Linux](https://www.kernel.org/doc/Documentation/networking/tproxy.txt)
[OpenBSD](https://man.openbsd.org/setsockopt.2#SO_BINDANY)
[FreeBSD](https://www.freebsd.org/cgi/man.cgi?query=ip&manpath=FreeBSD+11.1-RELEASE)

Thanks!
  • Loading branch information
bors[bot] committed Jan 11, 2018
2 parents 2478f0f + 37dea7b commit 1b1e427
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#826](https://github.com/nix-rust/nix/pull/826))
- Added `nix::sys::socket::LinkAddr` on Linux and all bsdlike system.
([#813](https://github.com/nix-rust/nix/pull/813))
- Add socket options for `IP_TRANSPARENT` / `BIND_ANY`.
([#835](https://github.com/nix-rust/nix/pull/835))

### Changed
- Exposed the `mqueue` module for all supported operating systems.
Expand Down
6 changes: 6 additions & 0 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ sockopt_impl!(GetOnly, AcceptConn, libc::SOL_SOCKET, libc::SO_ACCEPTCONN, bool);
#[cfg(any(target_os = "linux", target_os = "android"))]
sockopt_impl!(GetOnly, OriginalDst, libc::SOL_IP, libc::SO_ORIGINAL_DST, libc::sockaddr_in);
sockopt_impl!(Both, ReceiveTimestamp, libc::SOL_SOCKET, libc::SO_TIMESTAMP, bool);
#[cfg(any(target_os = "linux", target_os = "android"))]
sockopt_impl!(Both, IpTransparent, libc::SOL_IP, libc::IP_TRANSPARENT, bool);
#[cfg(target_os = "openbsd")]
sockopt_impl!(Both, BindAny, libc::SOL_SOCKET, libc::SO_BINDANY, bool);
#[cfg(target_os = "freebsd")]
sockopt_impl!(Both, BindAny, libc::IPPROTO_IP, libc::IP_BINDANY, bool);

/*
*
Expand Down

0 comments on commit 1b1e427

Please sign in to comment.