-
Notifications
You must be signed in to change notification settings - Fork 676
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
Add SO_ORIGINAL_DST #367
Add SO_ORIGINAL_DST #367
Conversation
@@ -1,7 +1,7 @@ | |||
use super::{ffi, consts, GetSockOpt, SetSockOpt}; | |||
use {Errno, Result}; | |||
use sys::time::TimeVal; | |||
use libc::{c_int, uint8_t, c_void, socklen_t}; | |||
use libc::{c_int, uint8_t, c_void, socklen_t, sockaddr_in}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a conditional use only for linux (see Travis-CI result).
When you fix the use error on apple, we can merge this. |
@fiveop Updated to fix the apple error, thanks! |
@@ -2,6 +2,8 @@ use super::{ffi, consts, GetSockOpt, SetSockOpt}; | |||
use {Errno, Result}; | |||
use sys::time::TimeVal; | |||
use libc::{c_int, uint8_t, c_void, socklen_t}; | |||
#[cfg(target_os = "linux")] | |||
use libc::{sockaddr_in}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: no need for braces if there's just a single name imported
@kamalmarhubi braces removed, thanks! |
@justinlatimer yay thanks! could you squash down to a single commit, and we'll get this merged :-) |
54087bf
to
3954580
Compare
@kamalmarhubi all squashed, thanks! |
Add SO_ORIGINAL_DST In Linux, the SO_ORIGINAL_DST socket option can be used to get the original destination, which can be needed if the connection is translated by a NAT, i.e. iptables. In C, this information can be obtained by ``getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &remote, &remote_len)`` and returns a ``sockaddr_in`` struct. I've added a binding for this option. Thanks!
Should this return EDIT: or a |
@sorz I can't find any documentation on |
In Linux, the SO_ORIGINAL_DST socket option can be used to get the original destination, which can be needed if the connection is translated by a NAT, i.e. iptables. In C, this information can be obtained by
getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &remote, &remote_len)
and returns asockaddr_in
struct. I've added a binding for this option.Thanks!