commit 623084548d2f5fc8d87a63e21c7f9b413e3633f0 Author: Hans-Christoph Steiner hans@eds.org Date: Thu Jun 11 16:31:39 2015 -0400
standardize network port constant variables
use consistent naming and types for code clarity --- src/org/torproject/android/OrbotMainActivity.java | 8 ++++---- src/org/torproject/android/service/TorService.java | 3 ++- .../android/service/TorServiceConstants.java | 18 +++++------------- src/org/torproject/android/vpn/OrbotVpnService.java | 3 ++- 4 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java index bfa777d..978d8cc 100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@ -559,12 +559,12 @@ public class OrbotMainActivity extends Activity startTor();
Intent resultIntent = new Intent(intent); - resultIntent.putExtra("socks_proxy", "socks://127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT); + 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.PORT_SOCKS_DEFAULT); - resultIntent.putExtra("http_proxy", "http://127.0.0.1" + TorServiceConstants.PORT_HTTP); + 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.PORT_HTTP); + resultIntent.putExtra("http_proxy_port", TorServiceConstants.HTTP_PROXY_PORT_DEFAULT); setResult(RESULT_OK, resultIntent); finish(); } catch (RemoteException e) { diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index ccfc4c8..018adb2 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -1168,7 +1168,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
- String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT); + String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS, + String.valueOf(TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT)); if (socksPortPref.indexOf(':')!=-1) socksPortPref = socksPortPref.split(":")[1];
diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java index 80b37f8..a0aed24 100644 --- a/src/org/torproject/android/service/TorServiceConstants.java +++ b/src/org/torproject/android/service/TorServiceConstants.java @@ -49,21 +49,16 @@ public interface TorServiceConstants { public final static String CHMOD_EXE_VALUE = "770";
public final static int FILE_WRITE_BUFFER_SIZE = 1024; - - //HTTP Proxy server port - public static int PORT_HTTP = 8118; //just like Privoxy! - - //Socks port client connects to, server is the Tor binary - public static String PORT_SOCKS_DEFAULT = "9050"; - - - //what is says! + public final static String IP_LOCALHOST = "127.0.0.1"; public final static int UPDATE_TIMEOUT = 1000; public final static int TOR_TRANSPROXY_PORT_DEFAULT = 9040; public final static int STANDARD_DNS_PORT = 53; public final static int TOR_DNS_PORT_DEFAULT = 5400; - + public final static int CONTROL_PORT_DEFAULT = 9051; + public final static int HTTP_PROXY_PORT_DEFAULT = 8118; // like Privoxy! + public final static int SOCKS_PROXY_PORT_DEFAULT = 9050; + //path to check Tor against public final static String URL_TOR_CHECK = "https://check.torproject.org";
@@ -127,8 +122,5 @@ public interface TorServiceConstants { public static final String MEEK_ASSET_KEY = "meek-client"; //name of the iptables binary public final static String IPTABLES_ASSET_KEY = "xtables"; - - public final static int DEFAULT_CONTROL_PORT = 9051; -
} diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java index 1096906..e202078 100644 --- a/src/org/torproject/android/vpn/OrbotVpnService.java +++ b/src/org/torproject/android/vpn/OrbotVpnService.java @@ -241,7 +241,8 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { final String virtualGateway = "10.0.0.1"; final String virtualIP = "10.0.0.2"; final String virtualNetMask = "255.255.255.0"; - final String localSocks = "127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT; + final String localSocks = "127.0.0.1:" + + String.valueOf(TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT); final String localDNS = "10.0.0.1:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT; Builder builder = new Builder();
tor-commits@lists.torproject.org