@@ -884,41 +884,6 @@ impl Socket {
884
884
}
885
885
}
886
886
887
- /// IP_TRANSPARENT (since Linux 2.6.24)
888
- /// Setting this boolean option enables transparent proxying
889
- /// on this socket. This socket option allows the calling
890
- /// application to bind to a nonlocal IP address and operate
891
- /// both as a client and a server with the foreign address as
892
- /// the local endpoint. NOTE: this requires that routing be
893
- /// set up in a way that packets going to the foreign address
894
- /// are routed through the TProxy box (i.e., the system
895
- /// hosting the application that employs the IP_TRANSPARENT
896
- /// socket option). Enabling this socket option requires
897
- /// superuser privileges (the CAP_NET_ADMIN capability).
898
- ///
899
- /// TProxy redirection with the iptables TPROXY target also
900
- /// requires that this option be set on the redirected socket.
901
- /// this feature is only available on linux
902
- #[ cfg( any( target_os = "linux" ) ) ]
903
- pub fn set_ip_transparent ( & self , transparent : bool ) -> io:: Result < ( ) > {
904
- unsafe {
905
- setsockopt (
906
- self . inner ,
907
- sys:: IPPROTO_IP ,
908
- libc:: IP_TRANSPARENT ,
909
- transparent as c_int ,
910
- )
911
- }
912
- }
913
- /// Get whether the IP_TRANSPARENT is set for this socket.
914
- #[ cfg( any( target_os = "linux" ) ) ]
915
- pub fn ip_transparent ( & self ) -> io:: Result < bool > {
916
- unsafe {
917
- getsockopt :: < c_int > ( self . inner , sys:: IPPROTO_IP , libc:: IP_TRANSPARENT )
918
- . map ( |transparent| transparent != 0 )
919
- }
920
- }
921
-
922
887
/// Get the value of the `SO_SNDBUF` option on this socket.
923
888
///
924
889
/// For more information about this option, see [`set_send_buffer_size`].
@@ -990,6 +955,46 @@ fn into_linger(duration: Option<Duration>) -> sys::linger {
990
955
/// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html>
991
956
/// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
992
957
impl Socket {
958
+ /// Get the value of the `IP_TRANSPARENTF` option on this socket.
959
+ ///
960
+ /// For more information about this option, see [`set_ip_transparent`].
961
+ ///
962
+ /// [`ip_transparent`]: Socket::set_ip_transparent
963
+ #[ cfg( all( feature = "all" , target_os = "linux" ) ) ]
964
+ pub fn ip_transparent ( & self ) -> io:: Result < bool > {
965
+ unsafe {
966
+ getsockopt :: < c_int > ( self . inner , sys:: IPPROTO_IP , libc:: IP_TRANSPARENT )
967
+ . map ( |transparent| transparent != 0 )
968
+ }
969
+ }
970
+
971
+ /// IP_TRANSPARENT (since Linux 2.6.24)
972
+ /// Setting this boolean option enables transparent proxying
973
+ /// on this socket. This socket option allows the calling
974
+ /// application to bind to a nonlocal IP address and operate
975
+ /// both as a client and a server with the foreign address as
976
+ /// the local endpoint. NOTE: this requires that routing be
977
+ /// set up in a way that packets going to the foreign address
978
+ /// are routed through the TProxy box (i.e., the system
979
+ /// hosting the application that employs the IP_TRANSPARENT
980
+ /// socket option). Enabling this socket option requires
981
+ /// superuser privileges (the CAP_NET_ADMIN capability).
982
+ ///
983
+ /// TProxy redirection with the iptables TPROXY target also
984
+ /// requires that this option be set on the redirected socket.
985
+ /// this feature is only available on linux
986
+ #[ cfg( all( feature = "all" , target_os = "linux" ) ) ]
987
+ pub fn set_ip_transparent ( & self , transparent : bool ) -> io:: Result < ( ) > {
988
+ unsafe {
989
+ setsockopt (
990
+ self . inner ,
991
+ sys:: IPPROTO_IP ,
992
+ libc:: IP_TRANSPARENT ,
993
+ transparent as c_int ,
994
+ )
995
+ }
996
+ }
997
+
993
998
/// Join a multicast group using `IP_ADD_MEMBERSHIP` option on this socket.
994
999
///
995
1000
/// This function specifies a new multicast group for this socket to join.
0 commit comments