Definitely, tho if you store it as a u32 that is fixed magically. Because 1.2.3.4 and 1.02.003.04 both map to the same number.
What I mean by storing it as a u32 is to convert it to a number, similar to how the IP gets sent over the wire, so for v4:
octet[3] | octet[2] << 8 | octet[1] << 16 | octet[0] << 24
or in more human terms:
(fourth octet) + (first octet * 256^3) + (second octet * 256^2) + (third octet * 256)
azertyfun@sh.itjust.works 11 months ago
Fuck that, if for whatever reason I’m writing an IP validator by hand I’m disallowing leading zeros. Parsers are very inconsistent, some will parse 010 as 10, others as 0o10 == 8 (you can try that right now with a POSIX
ping
). Talk about a footgun.stringere@reddthat.com 11 months ago
…and that’s me in the fetal position, thanks.