mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Switch to dnsjava
This commit is contained in:
parent
6c42fe58bd
commit
2b18dc741a
@ -19,7 +19,7 @@ dependencies {
|
|||||||
compile project(':extern:spongycastle:prov')
|
compile project(':extern:spongycastle:prov')
|
||||||
compile project(':extern:AppMsg:library')
|
compile project(':extern:AppMsg:library')
|
||||||
compile project(':extern:SuperToasts:supertoasts')
|
compile project(':extern:SuperToasts:supertoasts')
|
||||||
compile project(':extern:dnsjava')
|
compile project(':extern:minidns')
|
||||||
compile project(':extern:KeybaseLib:Lib')
|
compile project(':extern:KeybaseLib:Lib')
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,11 +57,13 @@ public class EmailKeyHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Most users don't have the SRV record, so ask a default server as well
|
if (keys.isEmpty()) {
|
||||||
String[] servers = Preferences.getPreferences(context).getKeyServers();
|
// Most users don't have the SRV record, so ask a default server as well
|
||||||
if (servers != null && servers.length != 0) {
|
String[] servers = Preferences.getPreferences(context).getKeyServers();
|
||||||
HkpKeyserver hkp = new HkpKeyserver(servers[0]);
|
if (servers != null && servers.length != 0) {
|
||||||
keys.addAll(getEmailKeys(mail, hkp));
|
HkpKeyserver hkp = new HkpKeyserver(servers[0]);
|
||||||
|
keys.addAll(getEmailKeys(mail, hkp));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new ArrayList<ImportKeysListEntry>(keys);
|
return new ArrayList<ImportKeysListEntry>(keys);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.keyimport;
|
package org.sufficientlysecure.keychain.keyimport;
|
||||||
|
|
||||||
|
import de.measite.minidns.Client;
|
||||||
|
import de.measite.minidns.Question;
|
||||||
|
import de.measite.minidns.Record;
|
||||||
|
import de.measite.minidns.record.SRV;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
@ -33,10 +37,6 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.xbill.DNS.Lookup;
|
|
||||||
import org.xbill.DNS.Record;
|
|
||||||
import org.xbill.DNS.SRVRecord;
|
|
||||||
import org.xbill.DNS.Type;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -396,19 +396,20 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
*/
|
*/
|
||||||
public static HkpKeyserver resolve(String domain) {
|
public static HkpKeyserver resolve(String domain) {
|
||||||
try {
|
try {
|
||||||
Record[] records = new Lookup("_hkp._tcp." + domain, Type.SRV).run();
|
Record[] records = new Client().query(new Question("_hkp._tcp." + domain, Record.TYPE.SRV)).getAnswers();
|
||||||
if (records.length > 0) {
|
if (records.length > 0) {
|
||||||
Arrays.sort(records, new Comparator<Record>() {
|
Arrays.sort(records, new Comparator<Record>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Record lhs, Record rhs) {
|
public int compare(Record lhs, Record rhs) {
|
||||||
if (!(lhs instanceof SRVRecord)) return 1;
|
if (lhs.getPayload().getType() != Record.TYPE.SRV) return 1;
|
||||||
if (!(rhs instanceof SRVRecord)) return -1;
|
if (rhs.getPayload().getType() != Record.TYPE.SRV) return -1;
|
||||||
return ((SRVRecord) lhs).getPriority() - ((SRVRecord) rhs).getPriority();
|
return ((SRV) lhs.getPayload()).getPriority() - ((SRV) rhs.getPayload()).getPriority();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Record record = records[0]; // This is our best choice
|
Record record = records[0]; // This is our best choice
|
||||||
if (record instanceof SRVRecord) {
|
if (record.getPayload().getType() == Record.TYPE.SRV) {
|
||||||
return new HkpKeyserver(((SRVRecord) record).getTarget().toString(), (short) ((SRVRecord) record).getPort());
|
return new HkpKeyserver(((SRV) record.getPayload()).getName(),
|
||||||
|
(short) ((SRV) record.getPayload()).getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
@ -12,5 +12,5 @@ include ':extern:spongycastle:pkix'
|
|||||||
include ':extern:spongycastle:prov'
|
include ':extern:spongycastle:prov'
|
||||||
include ':extern:AppMsg:library'
|
include ':extern:AppMsg:library'
|
||||||
include ':extern:SuperToasts:supertoasts'
|
include ':extern:SuperToasts:supertoasts'
|
||||||
include ':extern:dnsjava'
|
include ':extern:minidns'
|
||||||
include ':extern:KeybaseLib:Lib'
|
include ':extern:KeybaseLib:Lib'
|
||||||
|
Loading…
Reference in New Issue
Block a user