4 ms·
It'll fail you with port vs. no port. 1234::5678:9876 is ambiguous. Is 9876 a port or part of the address? The common explicit format is [1234::5678]:9876/
by Cpoll 8y ago
It'll fail you with port vs. no port.
1234::5678:9876 is ambiguous. Is 9876 a port or part of the address?
The common explicit format is [1234::5678]:9876/
- ggm 8y agoIf you don't know if it has a port or not in advance, how can you know the last :thing is not part of the IPv6 address deterministically? If you luck into a four digit port, and the address has :: maximal compression you're SOL. I have exclusively done this :-1 knowing I had a port. Not all sources (tcpdump) use your canonical form.
- IgorPartola 8y agoYou should read TFA.
- ggm 8y agoI did. It basically said to change your input stream to avoid the problem. Not all data sources can be changed. If you don't have canonically parsable inputs, then assumptions don't work and you can't predict if an add::d:ress is with or without the :port syntax, a priori unless you know the input stream.
- IgorPartola 8y agoSo between your input and your parsing library you should put a bit of code to clean up the incoming data. Don’t create a library that processes incorrect data because at some point someone will absolutely try to use it to parse different input data and it will cause problems.