Fast IP Ping

Fast IP Ping

对于字面 IP 服务器地址,不再进行延迟的反向 DNS 查找

杂项

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 模组加载器。无需额外要求