support for new minidns lib

This commit is contained in:
Adithya Abraham Philip 2015-06-17 11:39:22 +05:30
parent 2a003a6f6c
commit 0a7abd0c1f
5 changed files with 20 additions and 15 deletions

View File

@ -58,7 +58,7 @@ dependencies {
compile project(':extern:spongycastle:pg')
compile project(':extern:spongycastle:pkix')
compile project(':extern:spongycastle:prov')
compile project(':extern:minidns')
compile project(':extern:minidns:minidns-core')
compile project(':extern:KeybaseLib:Lib')
compile project(':extern:safeslinger-exchange')
}

View File

@ -23,6 +23,7 @@ import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import de.measite.minidns.DNSCache;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@ -45,7 +46,7 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import de.measite.minidns.Client;
import de.measite.minidns.DNSClient;
import de.measite.minidns.Question;
import de.measite.minidns.Record;
import de.measite.minidns.record.SRV;
@ -234,7 +235,7 @@ public class HkpKeyserver extends Keyserver {
} catch (IOException e) {
e.printStackTrace();
throw new QueryFailedException("Keyserver '" + mHost + "' is unavailable. Check your Internet connection!" +
proxy == null?"":" Using proxy " + proxy);
proxy == null ? "" : " Using proxy " + proxy);
}
}
@ -414,20 +415,21 @@ public class HkpKeyserver extends Keyserver {
*/
public static HkpKeyserver resolve(String domain) {
try {
Record[] records = new Client().query(new Question("_hkp._tcp." + domain, Record.TYPE.SRV)).getAnswers();
Record[] records = new DNSClient((DNSCache) null).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.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();
return ((SRV) lhs.getPayload()).priority - ((SRV) rhs.getPayload()).priority;
}
});
Record record = records[0]; // This is our best choice
if (record.getPayload().getType() == Record.TYPE.SRV) {
return new HkpKeyserver(((SRV) record.getPayload()).getName(),
(short) ((SRV) record.getPayload()).getPort());
return new HkpKeyserver(((SRV) record.getPayload()).name,
(short) ((SRV) record.getPayload()).port);
}
}
} catch (Exception ignored) {

View File

@ -73,14 +73,14 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import de.measite.minidns.Client;
import de.measite.minidns.DNSCache;
import de.measite.minidns.DNSClient;
import de.measite.minidns.DNSMessage;
import de.measite.minidns.Question;
import de.measite.minidns.Record;
import de.measite.minidns.record.Data;
import de.measite.minidns.record.TXT;
import org.sufficientlysecure.keychain.util.ParcelableProxy;
import org.sufficientlysecure.keychain.util.Preferences;
/**
* This Service contains all important long lasting operations for OpenKeychain. It receives Intents with
@ -254,7 +254,8 @@ public class KeychainService extends Service implements Progressable {
String domain = prover.dnsTxtCheckRequired();
if (domain != null) {
DNSMessage dnsQuery = new Client().query(new Question(domain, Record.TYPE.TXT));
DNSMessage dnsQuery = new DNSClient((DNSCache) null).query(new Question(domain,
Record.TYPE.TXT));
if (dnsQuery == null) {
sendProofError(prover.getLog(), getString(R.string.keybase_dns_query_failure));
return;
@ -329,7 +330,8 @@ public class KeychainService extends Service implements Progressable {
boolean isSecret = data.getBoolean(DELETE_IS_SECRET);
// Operation
DeleteOperation op = new DeleteOperation(KeychainService.this, providerHelper, KeychainService.this);
DeleteOperation op = new DeleteOperation(KeychainService.this, providerHelper,
KeychainService.this);
DeleteResult result = op.execute(masterKeyIds, isSecret);
// Result
@ -434,11 +436,12 @@ public class KeychainService extends Service implements Progressable {
HkpKeyserver server = new HkpKeyserver(keyServer);
CanonicalizedPublicKeyRing keyring = providerHelper.getCanonicalizedPublicKeyRing(dataUri);
ImportExportOperation importExportOperation = new ImportExportOperation(KeychainService.this,
ImportExportOperation importExportOperation = new ImportExportOperation(KeychainService
.this,
providerHelper, KeychainService.this);
ExportResult uploadResult = importExportOperation.uploadKeyRingToServer(server, keyring,
getProxyFromBundle(data));
getProxyFromBundle(data));
if (uploadResult.getResult() != ExportResult.RESULT_OK) {
throw new PgpGeneralException("Unable to export key to selected server");
}

2
extern/minidns vendored

@ -1 +1 @@
Subproject commit 969ffd2951fcaa07f46b441936a0c0fd4502dafd
Subproject commit d21e925423d6dad9501a0bec23a667438655f05f

View File

@ -5,6 +5,6 @@ include ':extern:spongycastle:core'
include ':extern:spongycastle:pg'
include ':extern:spongycastle:pkix'
include ':extern:spongycastle:prov'
include ':extern:minidns'
include ':extern:minidns:minidns-core'
include ':extern:KeybaseLib:Lib'
include ':extern:safeslinger-exchange'