auto-restart Tor when config changes
This commit is contained in:
parent
384fe1c21e
commit
e6fe25267f
|
@ -822,6 +822,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
else if (request == REQUEST_VPN && response == RESULT_OK)
|
else if (request == REQUEST_VPN && response == RESULT_OK)
|
||||||
{
|
{
|
||||||
startService(TorServiceConstants.CMD_VPN);
|
startService(TorServiceConstants.CMD_VPN);
|
||||||
|
restartTor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(request, response, data);
|
IntentResult scanResult = IntentIntegrator.parseActivityResult(request, response, data);
|
||||||
|
@ -1005,30 +1006,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
String bridgeList = mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST,null);
|
String bridgeList = mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST,null);
|
||||||
if (bridgeList != null && bridgeList.length() > 0)
|
if (bridgeList != null && bridgeList.length() > 0)
|
||||||
{
|
{
|
||||||
try
|
restartTor ();
|
||||||
{
|
|
||||||
//do auto restart
|
|
||||||
stopTor ();
|
|
||||||
|
|
||||||
mHandler.postDelayed(new Runnable () {
|
|
||||||
|
|
||||||
public void run ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
startTor();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.e(TAG,"can't start orbot",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.e(TAG,"can't stop orbot",e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1036,6 +1014,34 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restartTor ()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//do auto restart
|
||||||
|
stopTor ();
|
||||||
|
|
||||||
|
mHandler.postDelayed(new Runnable () {
|
||||||
|
|
||||||
|
public void run ()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
startTor();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.e(TAG,"can't start orbot",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.e(TAG,"can't stop orbot",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void promptStartVpnService ()
|
public void promptStartVpnService ()
|
||||||
{
|
{
|
||||||
LayoutInflater li = LayoutInflater.from(this);
|
LayoutInflater li = LayoutInflater.from(this);
|
||||||
|
@ -1086,13 +1092,14 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
startService(TorServiceConstants.CMD_VPN);
|
startService(TorServiceConstants.CMD_VPN);
|
||||||
|
restartTor ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopVpnService ()
|
public void stopVpnService ()
|
||||||
{
|
{
|
||||||
startService(TorServiceConstants.CMD_VPN_CLEAR);
|
startService(TorServiceConstants.CMD_VPN_CLEAR);
|
||||||
|
restartTor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean flushTransProxy ()
|
private boolean flushTransProxy ()
|
||||||
|
|
Loading…
Reference in New Issue