bradclawsie / Net-IP-Parse

Other
0 stars 4 forks source link

Esoteric forms don't warn #1

Closed skids closed 7 years ago

skids commented 7 years ago

Hi!

A long, long time ago I started a similar module, but rakudo was very young back then and I was trying very hard to do some things I could not, because we didn't have NativeCall yet (I wanted to store compactly as a uint32).

What I did manage to do was explore some of the ancient history of IPv4 textual representations. For example, did you know that the following string containing an IP address will be parsed differently depending on what program you ask?

$ ping 10.10.10.010 PING 10.10.10.010 (10.10.10.8) 56(84) bytes of data.

...the rather ancient, but still perniciously supported, behavior is that a leading zero means octal.

Another quirk is short addresses:

$ ping 10.10 PING 10.10 (10.0.0.10) 56(84) bytes of data.

A lot of newer code does not know, or follow these traditions -- and I think it is right to not do so, because nobody uses them. But since there is room for ambiguity, it is probably better to warn or refuse to process older formats unless the user uses flags to say they know what they are doing.

Anyway, I wrote this up in more detail in the pod of the module I was making, and you are welcome to steal whatever you like from it or its test suite (it is likely not working on modern rakudo):

https://github.com/skids/perl6netpack/tree/master/IPv4

(Also just as an aside, personally I think Net:: got way overused in Perl5 and should be used for things like Network testing utils and network gear APIs rather than "any protocol that goes over a network", which is why I put that under IPv4::)

bradclawsie commented 7 years ago

thanks skids! I'm not an IP expert by any means, and one of the things I was in search of was a list of test cases.

bradclawsie commented 7 years ago

closing since I have bookmarked the test suite in question and will hopefully use them in the future, but not sure when