updates to properly support tor-tether mode

This commit is contained in:
Nathan Freitas 2011-10-28 23:53:40 -04:00
parent 73265cec1d
commit ef5c506fdd
7 changed files with 52 additions and 6 deletions

View File

@ -1,14 +1,14 @@
SocksPort 9050 SocksPort 9050
SafeSocks 1 SafeSocks 1
Log notice stdout Log notice stdout
ControlListenAddress 127.0.0.1
ControlPort 9051 ControlPort 9051
CookieAuthentication 1 CookieAuthentication 1
RelayBandwidthRate 20 KBytes RelayBandwidthRate 20 KBytes
RelayBandwidthBurst 20 KBytes RelayBandwidthBurst 20 KBytes
UseBridges 0 UseBridges 0
AutomapHostsOnResolve 1 AutomapHostsOnResolve 1
TransListenAddress 0.0.0.0 TransListenAddress 127.0.0.1
TransPort 9040 TransPort 9040
DNSListenAddress 0.0.0.0 DNSListenAddress 127.0.0.1
DNSPort 5400 DNSPort 5400

14
res/raw/torrctether Normal file
View File

@ -0,0 +1,14 @@
SocksPort 9050
SafeSocks 1
Log notice stdout
ControlListenAddress 127.0.0.1
ControlPort 9051
CookieAuthentication 1
RelayBandwidthRate 20 KBytes
RelayBandwidthBurst 20 KBytes
UseBridges 0
AutomapHostsOnResolve 1
TransListenAddress 0.0.0.0
TransPort 9040
DNSListenAddress 0.0.0.0
DNSPort 5400

View File

@ -588,7 +588,10 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
lblStatus.setText(lblMsg); lblStatus.setText(lblMsg);
if (torServiceMsg != null && torServiceMsg.length() > 0) if (torServiceMsg != null && torServiceMsg.length() > 0)
showAlert("Update", torServiceMsg, false); {
// showAlert("Update", torServiceMsg, false);
lblStatus.setText(torServiceMsg);
}
boolean showFirstTime = prefs.getBoolean("connect_first_time",true); boolean showFirstTime = prefs.getBoolean("connect_first_time",true);

View File

@ -50,6 +50,9 @@ public class TorBinaryInstaller implements TorServiceConstants {
is = context.getResources().openRawResource(R.raw.torrc); is = context.getResources().openRawResource(R.raw.torrc);
streamToFile(is,installFolder, TORRC_ASSET_KEY, false, false); streamToFile(is,installFolder, TORRC_ASSET_KEY, false, false);
is = context.getResources().openRawResource(R.raw.torrctether);
streamToFile(is,installFolder, TORRC_TETHER_KEY, false, false);
is = context.getResources().openRawResource(R.raw.privoxy); is = context.getResources().openRawResource(R.raw.privoxy);
streamToFile(is,installFolder, PRIVOXY_ASSET_KEY, false, false); streamToFile(is,installFolder, PRIVOXY_ASSET_KEY, false, false);

View File

@ -582,6 +582,10 @@ public class TorService extends Service implements TorServiceConstants, TorConst
showAlert("Status", "TransProxy enabled for Tethering!"); showAlert("Status", "TransProxy enabled for Tethering!");
TorTransProxy.enableTetheringRules(this); TorTransProxy.enableTetheringRules(this);
// mBinder.updateConfiguration("TransListenAddress", "0.0.0.0", false);
// mBinder.updateConfiguration("DNSListenAddress", "0.0.0.0", false);
} }
} }
else else
@ -617,6 +621,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
String torrcPath = new File(appBinHome, TORRC_ASSET_KEY).getAbsolutePath(); String torrcPath = new File(appBinHome, TORRC_ASSET_KEY).getAbsolutePath();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean transProxyTethering = prefs.getBoolean("pref_transparent_tethering", false);
if (transProxyTethering)
{
torrcPath = new File(appBinHome, TORRC_TETHER_KEY).getAbsolutePath();
}
String[] torCmd = {torBinaryPath + " DataDirectory " + appDataHome.getAbsolutePath() + " -f " + torrcPath + " || exit\n"}; String[] torCmd = {torBinaryPath + " DataDirectory " + appDataHome.getAbsolutePath() + " -f " + torrcPath + " || exit\n"};
boolean runAsRootFalse = false; boolean runAsRootFalse = false;
@ -1430,7 +1442,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mBinder.updateConfiguration("HiddenServiceDir","", false); mBinder.updateConfiguration("HiddenServiceDir","", false);
} }
mBinder.saveConfiguration(); mBinder.saveConfiguration();
return true; return true;

View File

@ -15,6 +15,8 @@ public interface TorServiceConstants {
//torrc (tor config file) //torrc (tor config file)
public final static String TORRC_ASSET_KEY = "torrc"; public final static String TORRC_ASSET_KEY = "torrc";
public final static String TORRC_TETHER_KEY = "torrctether";
public final static String TOR_CONTROL_COOKIE = "control_auth_cookie"; public final static String TOR_CONTROL_COOKIE = "control_auth_cookie";
//how to launch tor //how to launch tor

View File

@ -137,6 +137,18 @@ public class Permissions extends Activity implements TorConstants {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean hasRoot = prefs.getBoolean("has_root",false); boolean hasRoot = prefs.getBoolean("has_root",false);
if (!hasRoot)
{
hasRoot = TorServiceUtils.isRootPossible();
Editor pEdit = prefs.edit();
pEdit.putBoolean(PREF_HAS_ROOT,hasRoot);
pEdit.commit();
}
if (hasRoot) if (hasRoot)
{ {
try { try {