guillaume at varnish-software.com
Wed Oct 28 10:52:30 CET 2015
I'm in favor of mandatory brackets for IPv6, but would this do ?
- first char is [: it's IPv6
- if you find a letter or colon: it's IPv6
- if you get a dot or more than 3 numbers in a row: it's IPv4
and a colon announces a port if:
- it comes right after a ']' in ipv6
- it comes after a number in IPv4
Once set on a version, error as soon as something is amiss.
I'd refuse IPv6 with port without brackets is it will get confusing
("::1:8080" is clear, but what about "::1:80"?)
On Wed, Oct 28, 2015 at 10:32 AM, Tollef Fog Heen <tfheen at fastly.com> wrote:
> 2015-10-28 9:58 GMT+01:00 Poul-Henning Kamp <phk at phk.freebsd.dk>:
> > --------
> > In message <CAJV_h0axHvroOtMPM83q=
> dCFHBtDL_XMzmGLu0q8mwWnCbSEZw at mail.gmail.com>
> > , Federico Schwindt writes:
> >>While moving from 4.0.x to 4.1 I noticed that std.ip(..., "::1") doesn't
> >>work anymore.
> > I agree this is very far from optimal, but adding special-casing
> > IPv6 address by IPv6 address is certainly *not* the way forward.
> > The real question is, what does "::1:8080" mean ?
> It's the IPv6 address 0:0:0:0:0:0:1:8080. I don't see how it could
> mean anything else.
> > Please propose the exact algorithm you prose for turning strings
> > into IP numbers, and bear in mind that we need to be able to
> > include port numbers.
> I'm not Federico, and this is not an exact algorithm, but:
> If string contains four dots and 0 or 1 :-s → parse as v4 (with or
> without port depending on presence of :)
> If string contains four dots and more than 1 and no : → parse as v4
> mapped ipv6 (port is empty)
> If string contains four dots and more than 1 and : → parse as v4
> mapped ipv6 with port
> If string contains :: and no  → parse as v6 (port is empty)
> If string contains 7 :s and no , parse as v6 (port is empty).
> If string contains :: and  → parse as v6 with port
> If string contains 7 :s and , parse as v6 with port
> Yes, this means you can't use 127.1 and similar as valid IPs. Don't do
> that, then.
> IMO, etc.
> Tollef Fog Heen | Engineer
> fastly.com | @fastly | Linkedin
> varnish-dev mailing list
> varnish-dev at varnish-cache.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the varnish-dev