mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
Merge pull request #686 from mar-v-in/minidns
Use minidns instead of dnsjava
This commit is contained in:
commit
c865de4002
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -28,9 +28,9 @@
|
||||
[submodule "extern/SuperToasts"]
|
||||
path = extern/SuperToasts
|
||||
url = https://github.com/open-keychain/SuperToasts.git
|
||||
[submodule "extern/dnsjava"]
|
||||
path = extern/dnsjava
|
||||
url = https://github.com/open-keychain/dnsjava.git
|
||||
[submodule "extern/KeybaseLib"]
|
||||
path = extern/KeybaseLib
|
||||
url = https://github.com/timbray/KeybaseLib.git
|
||||
[submodule "extern/minidns"]
|
||||
path = extern/minidns
|
||||
url = https://github.com/open-keychain/minidns.git
|
||||
|
@ -19,7 +19,7 @@ dependencies {
|
||||
compile project(':extern:spongycastle:prov')
|
||||
compile project(':extern:AppMsg:library')
|
||||
compile project(':extern:SuperToasts:supertoasts')
|
||||
compile project(':extern:dnsjava')
|
||||
compile project(':extern:minidns')
|
||||
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
|
||||
String[] servers = Preferences.getPreferences(context).getKeyServers();
|
||||
if (servers != null && servers.length != 0) {
|
||||
HkpKeyserver hkp = new HkpKeyserver(servers[0]);
|
||||
keys.addAll(getEmailKeys(mail, hkp));
|
||||
if (keys.isEmpty()) {
|
||||
// Most users don't have the SRV record, so ask a default server as well
|
||||
String[] servers = Preferences.getPreferences(context).getKeyServers();
|
||||
if (servers != null && servers.length != 0) {
|
||||
HkpKeyserver hkp = new HkpKeyserver(servers[0]);
|
||||
keys.addAll(getEmailKeys(mail, hkp));
|
||||
}
|
||||
}
|
||||
return new ArrayList<ImportKeysListEntry>(keys);
|
||||
}
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
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.HttpResponse;
|
||||
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.PgpKeyHelper;
|
||||
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.InputStream;
|
||||
@ -402,19 +402,20 @@ public class HkpKeyserver extends Keyserver {
|
||||
*/
|
||||
public static HkpKeyserver resolve(String domain) {
|
||||
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) {
|
||||
Arrays.sort(records, new Comparator<Record>() {
|
||||
@Override
|
||||
public int compare(Record lhs, Record rhs) {
|
||||
if (!(lhs instanceof SRVRecord)) return 1;
|
||||
if (!(rhs instanceof SRVRecord)) return -1;
|
||||
return ((SRVRecord) lhs).getPriority() - ((SRVRecord) rhs).getPriority();
|
||||
if (lhs.getPayload().getType() != Record.TYPE.SRV) return 1;
|
||||
if (rhs.getPayload().getType() != Record.TYPE.SRV) return -1;
|
||||
return ((SRV) lhs.getPayload()).getPriority() - ((SRV) rhs.getPayload()).getPriority();
|
||||
}
|
||||
});
|
||||
Record record = records[0]; // This is our best choice
|
||||
if (record instanceof SRVRecord) {
|
||||
return new HkpKeyserver(((SRVRecord) record).getTarget().toString(), (short) ((SRVRecord) record).getPort());
|
||||
if (record.getPayload().getType() == Record.TYPE.SRV) {
|
||||
return new HkpKeyserver(((SRV) record.getPayload()).getName(),
|
||||
(short) ((SRV) record.getPayload()).getPort());
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
1
extern/dnsjava
vendored
1
extern/dnsjava
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 71c8a9e56b19b34907e7e2e810ca15b57e3edc2b
|
1
extern/minidns
vendored
Submodule
1
extern/minidns
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit dcf62a8ac59d84072e66e71ec8a5d137784e760d
|
@ -12,5 +12,5 @@ include ':extern:spongycastle:pkix'
|
||||
include ':extern:spongycastle:prov'
|
||||
include ':extern:AppMsg:library'
|
||||
include ':extern:SuperToasts:supertoasts'
|
||||
include ':extern:dnsjava'
|
||||
include ':extern:minidns'
|
||||
include ':extern:KeybaseLib:Lib'
|
||||
|
Loading…
Reference in New Issue
Block a user