-
Notifications
You must be signed in to change notification settings - Fork 38.7k
net: Return IPv6 scope id in CNetAddr::ToStringIP()
#21985
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
Conversation
jonatack
left a comment
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.
ACK 90972a8962cfd9bf63f3b982f5a85fcdc41f253d according to https://datatracker.ietf.org/doc/html/rfc4007#section-11.2 and https://en.wikipedia.org/wiki/IPv6_address#zone_index numeric zone indices like these (% + uint32, default 0 that can be omitted) should be mandatory/universally supported
|
ACK c7d461b014422f1aaa13ae978d730864616ab7bb |
|
Code looks correct, so code review ACK c7d461b014422f1aaa13ae978d730864616ab7bb As stated in #21682 (comment) I have a slightly preference towards not including scope id in Also it is probably worth noting that the requirements for parsing and printing IPv6 addresses are not the same. |
|
@practicalswift Thank you for the review! I do not entirely understand your insistence on making our IPv6 formatting function the same as that of rust's IPv6 address type which is a different animal. It doesn't include a scope id, so cannot include it for formatting. In rust, the use std::net::{Ipv6Addr, SocketAddrV6};
fn main() {
let socket = SocketAddrV6::new(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1), 8080, 0, 32);
assert_eq!("[2001:db8::1%32]:8080".parse(), Ok(socket));
}
In any case I like to have the roundtrip here. The scope_id is part of the type so it makes some sense to be part of the string representation. This is clearly also useful for testing. Without the test, the scope id might as well be ignored by the parser 🙂 |
|
Thanks for providing the Rust
Is that a fair summary? :) |
|
For better or worse our data representation has an intermediate nesting level that doesn't neatly fit into that division. As this is our data representation I think the string representation should reflect this. |
vasild
left a comment
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.
ACK c7d461b014422f1aaa13ae978d730864616ab7bb
If the zone was (mostly) printed before (by getnameinfo()), keep printing it.
Twan1409
left a comment
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.
Ok
Twan1409
left a comment
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.
Ok
If a scope id is provided, return it back in the string representation. Also bring back the test. Closes bitcoin#21982. Co-authored-by: Jon Atack <[email protected]>
|
Updated the test for @vasild's comment. |
|
cr ACK 6c280ad
OK, I can see that point and I'm fine with that :) |
|
Post-merge ACK 6c280ad
git diff c7d461b 6c280ad diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index c0d3c3196e..7a122bd8b0 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -309,8 +309,7 @@ BOOST_AUTO_TEST_CASE(cnetaddr_basic)
BOOST_REQUIRE(addr.IsValid());
BOOST_REQUIRE(addr.IsIPv6());
BOOST_CHECK(!addr.IsBindAny());
- const std::string addr_str{addr.ToString()};
- BOOST_CHECK(addr_str == scoped_addr);
+ BOOST_CHECK_EQUAL(addr.ToString(), scoped_addr); |
…IP()` 6c280ad net: Return IPv6 scope id in `CNetAddr::ToStringIP()` (W. J. van der Laan) Pull request description: If a scope id is provided, return it back in the string representation. Also bring back the test (now in platform independent fashion). Closes bitcoin#21982. Includes bitcoin#21961 (apart from the MacOS remark). ACKs for top commit: practicalswift: cr ACK 6c280ad Tree-SHA512: 77792c35679b6c3545fd3a8d3d74c4f515ac2ee9f02d983251aeaaac715d55c122bbb0141abbeac272011f15520b439bd2db4ec8541a58df9b366921d212ca5f
If a scope id is provided, return it back in the string representation. Also bring back the test (now in platform independent fashion). Closes #21982. Includes #21961 (apart from the MacOS remark).