IPv[46] parsing

Federico Schwindt fgsch at lodoss.net
Mon Nov 2 14:58:14 CET 2015


Hi,

As requested I've provided the details of how this currently works and my
proposal.

Any comments?

On Wed, Oct 28, 2015 at 1:38 PM, Federico Schwindt <fgsch at lodoss.net> wrote:

> 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 <phk at phk.freebsd.dk>
> wrote:
>
>> --------
>> 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 ?
>>
>> 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
>> phk at FreeBSD.ORG         | TCP/IP since RFC 956
>> FreeBSD committer       | BSD since 4.3-tahoe
>> Never attribute to malice what can adequately be explained by
>> incompetence.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20151102/06e37c10/attachment.html>


More information about the varnish-dev mailing list