fix Resolver for ip direct and invalidHostname
This commit is contained in:
parent
ef7cbbadca
commit
08449e34ec
|
@ -81,7 +81,7 @@ public class Resolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Result fromHardCoded(String hostname, int port) {
|
public static Result fromHardCoded(final String hostname, final int port) {
|
||||||
final Result ipResult = fromIpAddress(hostname, port);
|
final Result ipResult = fromIpAddress(hostname, port);
|
||||||
if (ipResult != null) {
|
if (ipResult != null) {
|
||||||
ipResult.connect();
|
ipResult.connect();
|
||||||
|
@ -94,6 +94,15 @@ public class Resolver {
|
||||||
return port == 443 || port == 5223;
|
return port == 443 || port == 5223;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean invalidHostname(final String hostname) {
|
||||||
|
try {
|
||||||
|
DNSName.from(hostname);
|
||||||
|
return false;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Result resolve(String domain) {
|
public static Result resolve(String domain) {
|
||||||
final Result ipResult = fromIpAddress(domain, DEFAULT_PORT_XMPP);
|
final Result ipResult = fromIpAddress(domain, DEFAULT_PORT_XMPP);
|
||||||
if (ipResult != null) {
|
if (ipResult != null) {
|
||||||
|
@ -163,6 +172,7 @@ public class Resolver {
|
||||||
try {
|
try {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
result.ip = InetAddress.getByName(domain);
|
result.ip = InetAddress.getByName(domain);
|
||||||
|
result.hostname = DNSName.from(domain);
|
||||||
result.port = port;
|
result.port = port;
|
||||||
result.authenticated = true;
|
result.authenticated = true;
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue