happy eyeball: fix connection without dns

This commit is contained in:
genofire 2020-02-13 14:58:56 +01:00
parent e3b5be777c
commit b465011045
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 19 additions and 4 deletions

View File

@ -80,7 +80,12 @@ public class Resolver {
public static Result fromHardCoded(String hostname, int port) {
final Result ipResult = fromIpAddress(hostname, port);
if (ipResult != null) {
try {
ipResult.connect();
} catch (Exception e) {
Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": from hardcoded unable to connect: "+ e);
return null;
}
return ipResult;
}
return happyEyeball(resolveNoSrvRecords(DNSName.from(hostname), port, true));
@ -94,7 +99,12 @@ public class Resolver {
public static Result resolve(String domain) {
final Result ipResult = fromIpAddress(domain, DEFAULT_PORT_XMPP);
if (ipResult != null) {
try {
ipResult.connect();
} catch (Exception e) {
Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": from hardcoded unable to connect: "+ e);
return null;
}
return ipResult;
}
final List<Result> results = new ArrayList<>();
@ -304,7 +314,12 @@ public class Resolver {
if (r.size() == 1) {
result = r.get(0);
result.setLogID(logID);
try {
result.connect();
} catch (Exception e) {
Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": from hardcoded unable to connect: "+ e);
return null;
}
return result;
}
@ -361,7 +376,7 @@ public class Resolver {
private int priority;
private Socket socket;
private String logID;
private String logID = "";
static Result fromRecord(SRV srv, boolean directTls) {
Result result = new Result();