include dynamic proxy config info in ACTION_STATUS replies
This includes extras in the Intents that are sent as replies to the two different requests to start tor (ACTION_START and ACTION_START_TOR). These extras give all of the current SOCKS and HTTP proxy settings, so that the app can dynamically use the correct settings. Sometimes there are port conflicts, so apps should dynamically adjust in order to reliably find tor. closes #3612 https://dev.guardianproject.info/issues/3612 refs #4419 https://dev.guardianproject.info/issues/4419 refs #3690 https://dev.guardianproject.info/issues/3690 refs #3687 https://dev.guardianproject.info/issues/3687 refs #3859 https://dev.guardianproject.info/issues/3859
This commit is contained in:
parent
0937c8838f
commit
b620f828a1
|
@ -85,7 +85,8 @@ public class OrbotMainActivity extends Activity
|
|||
|
||||
/* Some tracking bits */
|
||||
private String torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
|
||||
|
||||
private Intent lastStatusIntent; // the last ACTION_STATUS Intent received
|
||||
|
||||
private SharedPreferences mPrefs = null;
|
||||
|
||||
private boolean autoStartFromIntent = false;
|
||||
|
@ -164,6 +165,7 @@ public class OrbotMainActivity extends Activity
|
|||
mStatusUpdateHandler.sendMessage(msg);
|
||||
|
||||
} else if (action.equals(TorServiceConstants.ACTION_STATUS)) {
|
||||
lastStatusIntent = intent;
|
||||
torStatus = intent.getStringExtra(TorServiceConstants.EXTRA_STATUS);
|
||||
Message msg = mStatusUpdateHandler.obtainMessage(STATUS_UPDATE);
|
||||
msg.obj = "";
|
||||
|
@ -554,24 +556,21 @@ public class OrbotMainActivity extends Activity
|
|||
else if (action.equals("org.torproject.android.START_TOR"))
|
||||
{
|
||||
autoStartFromIntent = true;
|
||||
try {
|
||||
Log.i(TAG, "action equals org.torproject.android.START_TOR");
|
||||
startTor();
|
||||
|
||||
Intent resultIntent = new Intent(intent);
|
||||
resultIntent.putExtra("socks_proxy", "socks://127.0.0.1:" + TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT);
|
||||
resultIntent.putExtra("socks_proxy_host", "127.0.0.1");
|
||||
resultIntent.putExtra("socks_proxy_port", TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT);
|
||||
resultIntent.putExtra("http_proxy", "http://127.0.0.1" + TorServiceConstants.HTTP_PROXY_PORT_DEFAULT);
|
||||
resultIntent.putExtra("http_proxy_host", "127.0.0.1");
|
||||
resultIntent.putExtra("http_proxy_port", TorServiceConstants.HTTP_PROXY_PORT_DEFAULT);
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
finish();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
startTor();
|
||||
|
||||
Intent resultIntent;
|
||||
if (lastStatusIntent == null) {
|
||||
resultIntent = new Intent(intent);
|
||||
} else {
|
||||
resultIntent = lastStatusIntent;
|
||||
}
|
||||
resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
finish();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (action.equals(Intent.ACTION_VIEW))
|
||||
{
|
||||
|
|
|
@ -762,6 +762,12 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
}
|
||||
Intent reply = new Intent(ACTION_STATUS);
|
||||
reply.putExtra(EXTRA_STATUS, mCurrentStatus);
|
||||
reply.putExtra(EXTRA_SOCKS_PROXY, "socks://127.0.0.1:" + mPortSOCKS);
|
||||
reply.putExtra(EXTRA_SOCKS_PROXY_HOST, "127.0.0.1");
|
||||
reply.putExtra(EXTRA_SOCKS_PROXY_PORT, mPortSOCKS);
|
||||
reply.putExtra(EXTRA_HTTP_PROXY, "http://127.0.0.1" + mPortHTTP);
|
||||
reply.putExtra(EXTRA_HTTP_PROXY_HOST, "127.0.0.1");
|
||||
reply.putExtra(EXTRA_HTTP_PROXY_PORT, mPortHTTP);
|
||||
reply.setPackage(packageName);
|
||||
sendBroadcast(reply);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,18 @@ public interface TorServiceConstants {
|
|||
* to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
|
||||
*/
|
||||
public final static String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
|
||||
/**
|
||||
* The SOCKS proxy settings in URL form.
|
||||
*/
|
||||
public final static String EXTRA_SOCKS_PROXY = "org.torproject.android.intent.extra.SOCKS_PROXY";
|
||||
public final static String EXTRA_SOCKS_PROXY_HOST = "org.torproject.android.intent.extra.SOCKS_PROXY_HOST";
|
||||
public final static String EXTRA_SOCKS_PROXY_PORT = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
|
||||
/**
|
||||
* The HTTP proxy settings in URL form.
|
||||
*/
|
||||
public final static String EXTRA_HTTP_PROXY = "org.torproject.android.intent.extra.HTTP_PROXY";
|
||||
public final static String EXTRA_HTTP_PROXY_HOST = "org.torproject.android.intent.extra.HTTP_PROXY_HOST";
|
||||
public final static String EXTRA_HTTP_PROXY_PORT = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
|
||||
|
||||
public final static String LOCAL_ACTION_LOG = "log";
|
||||
public final static String LOCAL_ACTION_BANDWIDTH = "bandwidth";
|
||||
|
|
Loading…
Reference in New Issue