mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 11:25:13 +01:00
Sort SRV records on priority and weight
This commit is contained in:
@@ -56,6 +56,8 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
@@ -302,6 +304,21 @@ public class DnsHelper {
|
||||
record.authentic = data.isAuthenticData();
|
||||
}
|
||||
|
||||
if ("srv".equals(type))
|
||||
Collections.sort(result, new Comparator<DnsRecord>() {
|
||||
@Override
|
||||
public int compare(DnsRecord d1, DnsRecord d2) {
|
||||
int o = Integer.compare(
|
||||
d1.priority == null ? 0 : d1.priority,
|
||||
d2.priority == null ? 0 : d2.priority);
|
||||
if (o == 0)
|
||||
o = Integer.compare(
|
||||
d1.weight == null ? 0 : d1.weight,
|
||||
d2.weight == null ? 0 : d2.weight);
|
||||
return o;
|
||||
}
|
||||
});
|
||||
|
||||
return result.toArray(new DnsRecord[0]);
|
||||
} catch (Throwable ex) {
|
||||
if (ex instanceof DnssecValidationFailedException ||
|
||||
|
||||
Reference in New Issue
Block a user