-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Allow to lookup the initial local IP address #943
Conversation
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.
Nice work! Just some cosmetic thoughts + the CI issue.
7b8bc69
to
be481ab
Compare
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.
LGTM, thanks!
Could we add coverage for this in the quinn
-level unit tests, perhaps?
I added some minimal coverage by reading the field and checking that it's available on Linux, and points to the loopback client. I think this covers the most important part (reading the cmsgs). Everything else is pretty much just plumbing. |
quinn-proto/src/connection/mod.rs
Outdated
/// This can be different from the address the endpoint is bound to, in case | ||
/// the endpoint is bound to a wildcard address like `0.0.0.0` or `::`. | ||
/// | ||
/// This will return `None` for clients, as well for servers if capturing |
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.
as well for
seems a bit odd, add an extra as
? I also think this docstring would be more useful if it explicitly lists supported platforms.
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.
Alternatively, and
might be a bit more concise.
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.
I went for listing the supported platform[s]
if cfg!(target_os = "linux") { | ||
let local_ip = incoming.local_ip().expect("Local IP must be available"); | ||
assert!(local_ip.is_loopback()); | ||
} else { | ||
assert_eq!(None, incoming.local_ip()); | ||
} |
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.
Add a note here to update the getter docs in case the platform support falls out of sync?
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.
Here, or rather to the platform files? This might be the place where people realize that more changes are necessary - because CI fails. But I somehow don't think that "update doc comments" is best kept in the tests. In the platform files - maybe. But if someone works on adding it to windows they won't look at the unix file.
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.
I mean, it could be both, but as you say, I'm not sure someone adding support for a different platform would review the code for unix. So I think adding it here would definitely be useful, maybe do the platform files as well (I didn't see a straightforward single location where it could be added, but I could easily be wrong about that).
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
Thanks for working through this! |
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for quinn-rs#943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
This is a follow-up for #943. When a socket is bound to a wildcard IP address, sending the outgoing IP might use a different source IP address than the one the packet was received on, since the OS might not be able to identify the necessary route. This would lead packets not allowing to reach the client. This change adds a setting which will set an explicit source address in all outgoing packets. The source address which will be used is the local IP address which was used to receive the initial incoming packet.
When a listener is bound to multiple network interfaces (e.g.
::0
),it is not obvious which IP the peer used to send a packet. We however
might need this information to send packets back to the peer with the
same source address.
This problem is described in #508.
This change makes the destination IP address which was used to send
the initial packet available in the
Conneting
andConnection
types.The information is far available only on Linux due to missing test on
other platforms.