跳到正文

Fast IP Ping

作者:fallen-breath

对于直接使用 IP 地址的服务器,跳过卡顿的反向 DNS 查询

收藏

截图

介绍

介绍由机器翻译自 Modrinth 原页面,仅供参考。

pinging

干掉针对字面 IP 服务器地址的卡顿反向 DNS 查询

提取自 TweakerMore 模组中的 yeetServerIpReversedDnsLookup 选项

是什么 & 为什么 & 怎么做

对于地址仅由字面 IP 表示的服务器,例如 192.168.2.10:25565,在对应的 InetAddress 对象中禁用反向 DNS 查询

许多非回环 IP 没有关联的域名,这会使反向查询耗时较长

// java.net.InetAddress#getHostName(boolean)
String getHostName(boolean check) {
    if (holder().getHostName() == null) {  // It will be null if InetAddress.getByName() received a literal IP
        holder().hostName = InetAddress.getHostFromNameService(this, check);  // <-- takes forever
    }
    return holder().getHostName();
}

此选项会直接将那些服务器的域名设置为其 IP,从而绕过反向 DNS 检查

这样一来,对于使用字面 IP 地址的服务器,可减少 1 秒 ~ 5 秒的时间。影响以下环境:

  • 在服务器列表界面中 ping 服务器
  • 连接到服务器

环境

  • 仅客户端
  • Fabric / Forge / NeoForge 模组加载器。无需额外要求

评论

登录后评论和评分

fallen-breath 的其他作品

查看全部 →