-
-
Notifications
You must be signed in to change notification settings - Fork 202
proposal: extend netip.Addr support to ipv6 #792
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
base: main
Are you sure you want to change the base?
proposal: extend netip.Addr support to ipv6 #792
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.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #792 +/- ##
=======================================
Coverage 93.10% 93.11%
=======================================
Files 23 23
Lines 5296 5300 +4
=======================================
+ Hits 4931 4935 +4
Misses 313 313
Partials 52 52 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Taking a second look at this, it appears it is possible to support dual-stack input by setting That doesn't seem very intuitive and could maybe warrant a doc fix? Personally I'd try making this a bit more explicit: the Also, it may be a good idea to switch to
|
case "ip": | ||
if _, err := netip.ParseAddr(str); err != nil { | ||
res.Add(path, str, validation.MsgExpectedRFCIPAddr) | ||
} |
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.
@costela I love this! One concern I have is that ipv4
and ipv6
are actually in the JSON Schema spec but ip
is not. See https://json-schema.org/understanding-json-schema/reference/type#ip-addresses.
I wonder if we should support all three? The two standard ones, and then ip
for either one since Go supports it well. What do you think?
edit: just saw your other comment which is similar to mine, sorry 😂
netip.Addr supports parsing both ipv4 and ipv6 out of the box. So it is a bit surprising to have a
netip.Addr
field in an API only support ipv4 and no easy way to add "dual-stack" support for APIs.I propose to extend the support for
netip.Addr
added in #396 and support ipv6 out of the box as well.format
detection fornetip.Addr
fields may be considered breaking, since existing APIs will start accepting IPv6 addresses and people may be counting on that limitation. I'd argue that it's worth it, but if not, we can remove that single change, while still adding support for theip
dual-stack format, to be used explicitly.WDYT?