Skip to content

std.net.parseIp6() only supports the basic form of addresses #3564

@euantorano

Description

@euantorano

Already posted this here, but I thought it was worth creating an issue so it doesn't get lost.

std.net.parseIp6 currently supports only the most basic full version of an IPv6 address. The following valid addresses are not supported:

  • ::1
  • :: (all segments are 0)
  • 2001:db8:: (last 6 segments are 0)
  • ::1234:5678 (first 6 segments are 0)
  • 2001:db8::1234:5678 (middle 4 segments are 0)

There is a check that when a : is encountered, if no digits have been seen then an error is returned: https://github.com/ziglang/zig/blob/master/lib/std/net.zig#L79:L81

I also don't know if it's intended to support IPv4 mapped or IPv4 compatible IPv6 addresses, but it would be nice to do so as they're quite common:

  • ::ffff:192.0.2.128 (IPv4 mapped IPv6 address)
  • ::192.0.2.128 (IPv4 comaptible - though this format is deprecated)

It might also be nice to add some more helper functions related to IP addresses. For example, see the Rust documentation for std::net::IpAddr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions