Skip to content

Unresolved InetAddress if using hostname in [servers] section of configuration #1750

@qyl27

Description

@qyl27

Expected Behavior

It should resolve hostnames (e.g., localhost -> ::0) as the other program does.

Actual Behavior

It now has an unresolved InetAddress.

Steps to Reproduce

  1. Add exampleserver = 'some-hostname-that-should-resolve-by-dns:25565' in [servers] section of velocity.toml.
  2. Try to access the ServerInfo#getAddress() of exampleserver via any plugins in Velocity.
  3. We have an unresolved InetAddress.

Plugin List

Velocity Version

[15:55:57 INFO]: Velocity 3.5.0-SNAPSHOT (git-d11511c1-b584)
[15:55:57 INFO]: Copyright 2018-2026 Velocity Contributors。Velocity 以 GNU 通用公共许可证第三版授权。
[15:55:57 INFO]: PaperMC - GitHub

Additional Information

Ref:

public static InetSocketAddress parseAddress(String ip) {
Preconditions.checkNotNull(ip, "ip");
URI uri = URI.create("tcp://" + ip);
if (uri.getHost() == null) {
throw new IllegalStateException("Invalid hostname/IP " + ip);
}
int port = uri.getPort() == -1 ? DEFAULT_MINECRAFT_PORT : uri.getPort();
try {
InetAddress ia = InetAddresses.forUriString(uri.getHost());
return new InetSocketAddress(ia, port);
} catch (IllegalArgumentException e) {
return InetSocketAddress.createUnresolved(uri.getHost(), port);
}
}

Why didn't we always resolve the hostname?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions