added proxy support to KeybaseLib
This commit is contained in:
parent
592b128596
commit
ec8c57b780
|
@ -65,20 +65,24 @@ public class CloudSearch {
|
|||
searchThread.start();
|
||||
}
|
||||
|
||||
// wait for either all the searches to come back, or 10 seconds
|
||||
// wait for either all the searches to come back, or 10 seconds. If using proxy, wait 30 seconds.
|
||||
synchronized (results) {
|
||||
try {
|
||||
results.wait(10 * SECONDS);
|
||||
if (proxy != null) {
|
||||
results.wait(30 * SECONDS);
|
||||
} else{
|
||||
results.wait(10 * SECONDS);
|
||||
}
|
||||
for (Thread thread : searchThreads) {
|
||||
// kill threads that haven't returned yet
|
||||
thread.interrupt();
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (results.outstandingSuppliers() > 0) {
|
||||
String message = "Launched " + servers.size() + " cloud searchers, but" +
|
||||
String message = "Launched " + servers.size() + " cloud searchers, but " +
|
||||
results.outstandingSuppliers() + "failed to complete.";
|
||||
problems.add(new Keyserver.QueryFailedException(message));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ public class KeybaseKeyserver extends Keyserver {
|
|||
@Override
|
||||
public ArrayList<ImportKeysListEntry> search(String query, Proxy proxy) throws QueryFailedException,
|
||||
QueryNeedsRepairException {
|
||||
// TODO: implement proxy
|
||||
ArrayList<ImportKeysListEntry> results = new ArrayList<>();
|
||||
|
||||
if (query.startsWith("0x")) {
|
||||
|
@ -50,7 +49,7 @@ public class KeybaseKeyserver extends Keyserver {
|
|||
mQuery = query;
|
||||
|
||||
try {
|
||||
Iterable<Match> matches = Search.search(query);
|
||||
Iterable<Match> matches = Search.search(query, proxy);
|
||||
for (Match match : matches) {
|
||||
results.add(makeEntry(match));
|
||||
}
|
||||
|
@ -101,9 +100,8 @@ public class KeybaseKeyserver extends Keyserver {
|
|||
|
||||
@Override
|
||||
public String get(String id, Proxy proxy) throws QueryFailedException {
|
||||
// TODO: implement proxy
|
||||
try {
|
||||
return User.keyForUsername(id);
|
||||
return User.keyForUsername(id, proxy);
|
||||
} catch (KeybaseException e) {
|
||||
throw new QueryFailedException(e.getMessage());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
|
@ -368,9 +367,9 @@ public class ImportKeysActivity extends BaseNfcActivity
|
|||
if (OrbotHelper.isOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTor, mProxyPrefs, this)) {
|
||||
mListFragment.loadNew(loaderState, mProxyPrefs.parcelableProxy);
|
||||
}
|
||||
} else if (loaderState instanceof ImportKeysListFragment.BytesLoaderState) { // must always be true
|
||||
mListFragment.loadNew(loaderState, mProxyPrefs.parcelableProxy);
|
||||
}
|
||||
|
||||
mListFragment.loadNew(loaderState, mProxyPrefs.parcelableProxy);
|
||||
}
|
||||
|
||||
private void handleMessage(Message message) {
|
||||
|
|
|
@ -51,7 +51,11 @@ import org.sufficientlysecure.keychain.service.KeybaseVerificationParcel;
|
|||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
@ -197,8 +201,21 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||
mStartSearch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mStartSearch.setEnabled(false);
|
||||
new DescribeKey().execute(fingerprint);
|
||||
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity()).getProxyPrefs();
|
||||
|
||||
Runnable ignoreTor = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mStartSearch.setEnabled(false);
|
||||
new DescribeKey(proxyPrefs.parcelableProxy).execute(fingerprint);
|
||||
}
|
||||
};
|
||||
|
||||
if (OrbotHelper.isOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTor, proxyPrefs,
|
||||
getActivity())) {
|
||||
mStartSearch.setEnabled(false);
|
||||
new DescribeKey(proxyPrefs.parcelableProxy).execute(fingerprint);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -229,6 +246,11 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||
// look for evidence from keybase in the background, make tabular version of result
|
||||
//
|
||||
private class DescribeKey extends AsyncTask<String, Void, ResultPage> {
|
||||
ParcelableProxy mParcelableProxy;
|
||||
|
||||
public DescribeKey(ParcelableProxy parcelableProxy) {
|
||||
mParcelableProxy = parcelableProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResultPage doInBackground(String... args) {
|
||||
|
@ -237,7 +259,7 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||
final ArrayList<CharSequence> proofList = new ArrayList<CharSequence>();
|
||||
final Hashtable<Integer, ArrayList<Proof>> proofs = new Hashtable<Integer, ArrayList<Proof>>();
|
||||
try {
|
||||
User keybaseUser = User.findByFingerprint(fingerprint);
|
||||
User keybaseUser = User.findByFingerprint(fingerprint, mParcelableProxy.getProxy());
|
||||
for (Proof proof : keybaseUser.getProofs()) {
|
||||
Integer proofType = proof.getType();
|
||||
appendIfOK(proofs, proofType, proof);
|
||||
|
|
2
extern/KeybaseLib
vendored
2
extern/KeybaseLib
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 9615d90b18d1aee4dad994aa45875adfdcfb3c34
|
||||
Subproject commit 187caa13d766fc92fa26b704183f6aebeb029f9e
|
Loading…
Reference in a new issue