Hi, Current functionality ----------------------------
1. If the string starts with "[" we take everything up to "]" as the host, excluding the "[]". If there is a ":" following the "]" we take everything after it as the port. 2. If the string has a space, take everything up to the space (but excluding it) as the host. Anything after the space is the port. 3. If the string doesn't have a space, but has a ":" take everything up to the ":" (but excluding it) as a host, and anything after as the port. My proposal ----------------- Change 3 as follows: 3. If the string doesn't have a space, but has a single ":" take everything up to the ":" (but excluding it) as a host, and anything after as the port. If the string has 2 or more ":", take the whole string as a host without port. Examples -------------- 1.2.3.4 => host = 1.2.3.4 port = 1.2.3.4:80 => host = 1.2.3.4 port = 80 1.2.3.4 80 => host = 1.2.3.4 port = 80 foo.bar => host = foobar port = foo.bar:80 => host = foobar port = 80 foo.bar 80 => host = foobar port = 80 [::1] => host = ::1 port = [::1]:80 => host = ::1 port = 80 ::1 => host = ::1 port = ::1::2 => host = ::1::2 port = 1.2.3.4::80 => host = 1.2.3.4::80 port = With the current implementation ::1 would fail. It works with my patch. The last 2 would fail at getaddrinfo(), with or without my proposal. f.- On Wed, Oct 28, 2015 at 8:58 AM, Poul-Henning Kamp <[email protected]> wrote: > -------- > In message <CAJV_h0axHvroOtMPM83q= > [email protected]> > , 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 ? > > 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. > > -- > Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 > [email protected] | TCP/IP since RFC 956 > FreeBSD committer | BSD since 4.3-tahoe > Never attribute to malice what can adequately be explained by incompetence. >
_______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
