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,6 +85,7 @@ public class OrbotMainActivity extends Activity
|
||||||
|
|
||||||
/* Some tracking bits */
|
/* Some tracking bits */
|
||||||
private String torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
|
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 SharedPreferences mPrefs = null;
|
||||||
|
|
||||||
|
@ -164,6 +165,7 @@ public class OrbotMainActivity extends Activity
|
||||||
mStatusUpdateHandler.sendMessage(msg);
|
mStatusUpdateHandler.sendMessage(msg);
|
||||||
|
|
||||||
} else if (action.equals(TorServiceConstants.ACTION_STATUS)) {
|
} else if (action.equals(TorServiceConstants.ACTION_STATUS)) {
|
||||||
|
lastStatusIntent = intent;
|
||||||
torStatus = intent.getStringExtra(TorServiceConstants.EXTRA_STATUS);
|
torStatus = intent.getStringExtra(TorServiceConstants.EXTRA_STATUS);
|
||||||
Message msg = mStatusUpdateHandler.obtainMessage(STATUS_UPDATE);
|
Message msg = mStatusUpdateHandler.obtainMessage(STATUS_UPDATE);
|
||||||
msg.obj = "";
|
msg.obj = "";
|
||||||
|
@ -555,23 +557,20 @@ public class OrbotMainActivity extends Activity
|
||||||
{
|
{
|
||||||
autoStartFromIntent = true;
|
autoStartFromIntent = true;
|
||||||
try {
|
try {
|
||||||
Log.i(TAG, "action equals org.torproject.android.START_TOR");
|
|
||||||
startTor();
|
startTor();
|
||||||
|
|
||||||
Intent resultIntent = new Intent(intent);
|
Intent resultIntent;
|
||||||
resultIntent.putExtra("socks_proxy", "socks://127.0.0.1:" + TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT);
|
if (lastStatusIntent == null) {
|
||||||
resultIntent.putExtra("socks_proxy_host", "127.0.0.1");
|
resultIntent = new Intent(intent);
|
||||||
resultIntent.putExtra("socks_proxy_port", TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT);
|
} else {
|
||||||
resultIntent.putExtra("http_proxy", "http://127.0.0.1" + TorServiceConstants.HTTP_PROXY_PORT_DEFAULT);
|
resultIntent = lastStatusIntent;
|
||||||
resultIntent.putExtra("http_proxy_host", "127.0.0.1");
|
}
|
||||||
resultIntent.putExtra("http_proxy_port", TorServiceConstants.HTTP_PROXY_PORT_DEFAULT);
|
resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
|
||||||
setResult(RESULT_OK, resultIntent);
|
setResult(RESULT_OK, resultIntent);
|
||||||
finish();
|
finish();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (action.equals(Intent.ACTION_VIEW))
|
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);
|
Intent reply = new Intent(ACTION_STATUS);
|
||||||
reply.putExtra(EXTRA_STATUS, mCurrentStatus);
|
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);
|
reply.setPackage(packageName);
|
||||||
sendBroadcast(reply);
|
sendBroadcast(reply);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,18 @@ public interface TorServiceConstants {
|
||||||
* to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
|
* 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";
|
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_LOG = "log";
|
||||||
public final static String LOCAL_ACTION_BANDWIDTH = "bandwidth";
|
public final static String LOCAL_ACTION_BANDWIDTH = "bandwidth";
|
||||||
|
|
Loading…
Reference in New Issue