You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
根据 #420 所述,服务商更改了 api 地址,现在是之前使用的myip4.ipip.net合并到了myip.ipip.net,不确定将来会不会myip6.ipip.net也合并过来…… 虽然目前还没见到像之前搜狐的 api 全部指向上海的离谱情况(#367#368),但是 ipip.net 对于该 api 的说明中写道不能保证这个服务的质量,结合下一条问题,我建议更换新的默认 api。
根据 #420 所述,服务商更改了 api 地址,现在是之前使用的
myip4.ipip.net
合并到了myip.ipip.net
,不确定将来会不会myip6.ipip.net
也合并过来…… 虽然目前还没见到像之前搜狐的 api 全部指向上海的离谱情况(#367 #368),但是 ipip.net 对于该 api 的说明中写道不能保证这个服务的质量,结合下一条问题,我建议更换新的默认 api。现在
myip6.ipip.net
同时指向了 ipv4 和 ipv6 两个地址,故响应会根据请求分别返回 ipv4 和 ipv6 地址。根据代码,对于 URL 的访问采用了 urllib 的 urlopen 函数,该函数并不能控制通过哪一个版本的 ip 协议连接到服务器,即具体返回哪一个取决于系统优先使用哪一个连接…… 个人认为将其交由系统决定或许不是一个明智的选择。nslookup 命令返回的结果
综上,我建议撤销 #420 的合并。
将 urlopen 方法使用 socket 重写可以一劳永逸,但重构代价或许远高于更换 api 的方法。
能够区分 ipv4 和 ipv6 的 api 例如 ip.sb 提供的 api。其提供的
https://api-ipv4.ip.sb/ip
和https://api-ipv6.ip.sb/ip
分别只解析到了 ipv4 和 ipv6。nslookup 命令返回的结果
在我尝试修改 api之后发现相应会出现权限错误,检查文档后发现其要求使用
Mozilla
作为 UA。经过实测,该 api 屏蔽了 UA 中包含curl
的请求,只要不包含curl
作为 UA 即可获取到正确的结果。因此我将 UA 修改为Mozilla/5.0 Python/ddns
。commit: 8219fa2
PR: #418
The text was updated successfully, but these errors were encountered: