resolver results need to be editable if we inject see-other-host

This commit is contained in:
Daniel Gultsch 2024-02-18 10:20:54 +01:00
parent d175843cbd
commit a62a7a4a84
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
2 changed files with 9 additions and 8 deletions

View file

@ -166,15 +166,15 @@ public class Resolver {
threads[2].interrupt(); threads[2].interrupt();
synchronized (results) { synchronized (results) {
Collections.sort(results); Collections.sort(results);
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + results.toString()); Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + results);
return new ArrayList<>(results); return results;
} }
} else { } else {
threads[2].join(); threads[2].join();
synchronized (fallbackResults) { synchronized (fallbackResults) {
Collections.sort(fallbackResults); Collections.sort(fallbackResults);
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + fallbackResults.toString()); Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + fallbackResults);
return new ArrayList<>(fallbackResults); return fallbackResults;
} }
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -257,7 +257,7 @@ public class Resolver {
} }
private static List<Result> resolveNoSrvRecords(DNSName dnsName, boolean withCnames) { private static List<Result> resolveNoSrvRecords(DNSName dnsName, boolean withCnames) {
List<Result> results = new ArrayList<>(); final List<Result> results = new ArrayList<>();
try { try {
for (A a : resolveWithFallback(dnsName, A.class, false).getAnswersOrEmptySet()) { for (A a : resolveWithFallback(dnsName, A.class, false).getAnswersOrEmptySet()) {
results.add(Result.createDefault(dnsName, a.getInetAddress())); results.add(Result.createDefault(dnsName, a.getInetAddress()));

View file

@ -338,12 +338,13 @@ public class XmppConnection implements Runnable {
} }
} else { } else {
final String domain = account.getServer(); final String domain = account.getServer();
final List<Resolver.Result> results; final List<Resolver.Result> results = new ArrayList<>();
final boolean hardcoded = extended && !account.getHostname().isEmpty(); final boolean hardcoded = extended && !account.getHostname().isEmpty();
if (hardcoded) { if (hardcoded) {
results = Resolver.fromHardCoded(account.getHostname(), account.getPort()); results.addAll(
Resolver.fromHardCoded(account.getHostname(), account.getPort()));
} else { } else {
results = Resolver.resolve(domain); results.addAll(Resolver.resolve(domain));
} }
if (Thread.currentThread().isInterrupted()) { if (Thread.currentThread().isInterrupted()) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": Thread was interrupted"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": Thread was interrupted");