使用端口(例如localhost:12345)访问IPv6可解析的URL会导致Strawberry Perl 5.30.1中出现错误的地址

问题描述 投票:4回答:1

[在启用了IPv6的Windows 10下使用Strawberry Perl 5.30.1时,由于Perl的DNS解析器中似乎存在错误,因此无法正确解析带有端口号的URL。

对于下面的测试,我们有一个简单的网络服务器,在所有端口上监听端口8810。

端口12345不会NOT托管任何内容。

以下是我们用于复制的脚本:

use strict;
use warnings;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new();
my $result=$ua->get("http://localhost:8810/");
print "(DNS Expect: Success) The server responded with Status Code ".$result->status_line.".\n";
$result=$ua->get("http://localhost:12345/");
print "(DNS Expect: Failure) The server responded with Status Code ".$result->status_line.".\n";
$result=$ua->get("http://127.0.0.1:8810/");
print "(IPv4 Expect: Success) The server responded with Status Code ".$result->status_line.".\n";

用5.28.0执行时,我得到正确的响应

C:\perl-test>strawberry-perl-5-28-0-original\perl\bin\perl.exe test2.pl
(DNS Expect: Success) The server responded with Status Code 200 OK.
(DNS Expect: Failure) The server responded with Status Code 500 Can't connect to localhost:12345 (No connection could be made because the target machine actively refused it.).
(IPv4 Expect: Success) The server responded with Status Code 200 OK.

但是,当尝试使用5.30.1时,无论端口是否实际打开,我都会得到错误的地址

C:\perl-test>strawberry-perl-5-30-1-original\perl\bin\perl.exe test2.pl
(DNS Expect: Success) The server responded with Status Code 500 Can't connect to localhost:8810 (Bad address).
(DNS Expect: Failure) The server responded with Status Code 500 Can't connect to localhost:12345 (Bad address).
(IPv4 Expect: Success) The server responded with Status Code 200 OK.

请注意,如果我们直接提供IPv4地址,则5.30.1仍然能够实际请求信息。另外,对于不能解析为IPv6而是仅解析为IPv4的DNS,5.30.1似乎没有问题。

还有其他人遇到这个问题吗?如果是,这是否被认为是一个错误,或者我们只是以某种错误的方式使用了perl?

UPDATE:我发现了另一个似乎有助于解决的难题:

到目前为止,我们仅在公司的Windows机器上进行了尝试,所有机器在Perl 5.30.1和5.30.2上的行为都相同。但是,我现在也尝试了我的私有Windows 10,它可以正常工作。

然后,我对IPv4和IPv6进行了一些探讨,并提出了来自Microsoft的以下知识库文章:https://support.microsoft.com/en-us/help/929852/guidance-for-configuring-ipv6-in-windows-for-advanced-users

底线:我在注册表中设置Windows应该优先使用IPv4而不是IPv6(设置0x20),然后重新启动-并且它在我的公司Windows 10上可以正常工作!

因此,显然,我们有一些设置可以用perl固定,但是似乎仍然存在问题:当尝试访问无法访问的localhost端口时,我们仍然会收到“错误地址”错误,而不是“连接被拒绝”,这意味着仍然有一些东西无法解析我们的dns:port字符串。

此外,我希望perl到现在完全支持IPv6。

perl lwp strawberry-perl
1个回答
0
投票

我在运行Windows 10,Strawberry Perl 5.30.1,XAMPP 7.4.5的KVM虚拟机(在Ubuntu 20.04上尝试了此操作,虚拟主机在8080上进行侦听,根据Internet和Internet设置启用了IPv4和IPv6控制面板。

这似乎在这里很好用,test2.pl脚本的输出是:

(DNS Expect: Success) The server responded with Status Code 200 OK.
(DNS Expect: Failure) The server responded with Status Code 500 Can't connect to localhost:12345 (No connection could be made because the target machine actively refused it.).
(IPv4 Expect: Success) The server responded with Status Code 200 OK.
© www.soinside.com 2019 - 2024. All rights reserved.