[tor-commits] [orbot/master] ensure polipo conf is updated; default to 9051 for ctrl port

n8fr8 at torproject.org n8fr8 at torproject.org
Wed Jun 11 15:28:00 UTC 2014


commit c2be4ac15b4faeb65d00965ba2d5dc02b15a52cd
Author: Nathan Freitas <nathan at freitas.net>
Date:   Wed Jun 11 11:26:30 2014 -0400

    ensure polipo conf is updated; default to 9051 for ctrl port
---
 .../android/service/TorResourceInstaller.java          |   16 ++++++++++++++++
 src/org/torproject/android/service/TorService.java     |    7 ++++++-
 .../android/service/TorServiceConstants.java           |    2 ++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/org/torproject/android/service/TorResourceInstaller.java b/src/org/torproject/android/service/TorResourceInstaller.java
index b8cdf26..414c33c 100644
--- a/src/org/torproject/android/service/TorResourceInstaller.java
+++ b/src/org/torproject/android/service/TorResourceInstaller.java
@@ -138,6 +138,22 @@ public class TorResourceInstaller implements TorServiceConstants {
 		return true;
 	}
 	
+	public boolean installPolipoConf () throws IOException, FileNotFoundException, TimeoutException
+	{
+		
+		InputStream is;
+        File outFile;
+        
+        Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
+        
+        is = context.getResources().openRawResource(R.raw.torpolipo);
+		outFile = new File(installFolder, POLIPOCONFIG_ASSET_KEY);
+		shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
+		streamToFile(is,outFile, false, false);
+		
+		return true;
+	}
+	
 	/*
 	 * Extract the Tor binary from the APK file using ZIP
 	 */
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 49bd672..aac581b 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -561,6 +561,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
     	String extraLines = prefs.getString("pref_custom_torrc", null);
     	
 		boolean success = installer.installTorrc(extraLines);
+		success = installer.installPolipoConf();
 		
 		if (version == null || (!version.equals(BINARY_TOR_VERSION)) || (!fileTor.exists()))
 		{
@@ -881,10 +882,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
 					{
 						
 						int controlPort = getControlPort();
-						logNotice( "Connecting to control port: " + controlPort);
+						
+						if (controlPort == -1 && i == maxAttempts)
+							controlPort = DEFAULT_CONTROL_PORT;
 						
 						if (controlPort != -1)
 						{
+							logNotice( "Connecting to control port: " + controlPort);
+							
 							torConnSocket = new Socket(IP_LOCALHOST, controlPort);
 							torConnSocket.setSoTimeout(CONTROL_SOCKET_TIMEOUT);
 							
diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java
index 449e535..58f59ab 100644
--- a/src/org/torproject/android/service/TorServiceConstants.java
+++ b/src/org/torproject/android/service/TorServiceConstants.java
@@ -88,5 +88,7 @@ public interface TorServiceConstants {
 	//name of the iptables binary
 	public final static String IPTABLES_ASSET_KEY = "xtables";	
 	
+	public final static int DEFAULT_CONTROL_PORT = 9051;
+	
 
 }





More information about the tor-commits mailing list