[vlc-devel] [PATCH] demux: adaptive: fix http request with IPv6 reference
Xie Zhigang
zighouse at hotmail.com
Wed Dec 23 13:16:45 UTC 2020
In order to support IPv6 on both linux and windows, 3 patches are needed:
1. Patch to modules/demux/adaptive/http for proper HTTP requests on IPv6
hosts.
As commented to resort to inet_pton(), the changes in adaptive/http is
simplified.
But it needs more to patch, for inet_pton is not always valid. It makes
Patch2.
2. Patch to compat/inet_pton.c for providing IPv6 support on windows
release.
3. Patch to misc/httpcookies.c for storing cookies on IPv6 hosts.
Patch3 is used for connecting servers on IPv6 with cookies.
On 2020/12/20 下午4:13, Rémi Denis-Courmont wrote:
> Nihao,
>
> Comments inline...
>
> Le lauantaina 19. joulukuuta 2020, 11.53.48 EET Xie Zhigang a écrit :
>> +bool isIPv6() const;
>> +{
>> + return ipv6;
>> +}
>> +
>> +static int is_ipv6_addr (const char * host)
>> +{
>> + const char * p;
>> + unsigned colons = 0, nums = 0, decs = 0, dots = 0;
>> + if (!host)
>> + {
>> + return 0;
>> + }
>> + for (p = host; *p; p++)
>> + {
>> + char c = *p;
>> + if (c == ':')
>> + {
>> + colons ++;
>> + if (nums > 4)
>> + {
>> + return 0;
>> + }
>> + nums = 0;
>> + decs = 0;
>> + }
>> + else if (('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c &&
>> c <= 'f')) + {
>> + if ('0' <= c && c <= '9')
>> + {
>> + decs ++;
>> + }
>> + nums ++;
>> + }
>> + else if (c == '.')
>> + {
>> + dots ++;
>> + if (nums != decs)
>> + {
>> + return 0;
>> + }
>> + if (nums == 0 || 3 < nums)
>> + {
>> + return 0;
>> + }
>> + }
>> + else
>> + {
>> + return 0;
>> + }
>> + }
>> + return 2 <= colons && colons <= 7 && (dots == 0 || dots == 3);
>> +}
>> +
> This does not need so much complexity. If you really want to check for IPv6,
> there's inet_pton(), but you could just check if the string contains as colon.
>
> Also please try to stick to the same indentation style as the rest of the
> code.
>
>> void ConnectionParams::parse()
>> {
>> vlc_url_t url_components;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-demux-adaptive-fix-http-request-with-IPv6-reference.patch
Type: text/x-patch
Size: 3924 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20201223/c57cb5a7/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-compat-inet_pton-providing-quick-IPv6-support-for-de.patch
Type: text/x-patch
Size: 5789 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20201223/c57cb5a7/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-misc-httpcookies-IPv6-host-is-not-top-level-domain-a.patch
Type: text/x-patch
Size: 1057 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20201223/c57cb5a7/attachment-0002.bin>
More information about the vlc-devel
mailing list