commit af51a9853569da03c496ef859188512b47807d04
Author: Nathan Freitas <nat...@freitas.net>
Date:   Mon Jun 9 18:47:48 2014 -0400

    allow support for adding custom lines to torrc
---
 res/values/strings.xml                                       |    5 +++++
 res/xml/preferences.xml                                      |    8 ++++++++
 src/org/torproject/android/service/TorResourceInstaller.java |    9 ++++++++-
 src/org/torproject/android/service/TorService.java           |    5 ++++-
 src/org/torproject/android/service/TorServiceConstants.java  |    2 +-
 5 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/res/values/strings.xml b/res/values/strings.xml
index 42937d4..4456aff 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -261,4 +261,9 @@
     <string name="pref_socks_summary">IP and Port that Tor offers its SOCKS 
proxy on (default: 9050)</string>
     <string name="pref_socks_dialog">SOCKS Config (ip:port)</string>
     
+    <string name="pref_torrc_title">Torrc Custom Config</string>
+    <string name="pref_torrc_summary">EXPERTS ONLY: enter direct torrc config 
lines</string>
+    <string name="pref_torrc_dialog">Custom Torrc</string>
+    
+    
 </resources>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index e4984e2..0277343 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -204,6 +204,14 @@ android:dialogTitle="@string/pref_socks_dialog"
 android:defaultValue="9050"
 />
     
+  <EditTextPreference android:key="pref_custom_torrc"
+android:title="@string/pref_torrc_title"
+android:summary="@string/pref_torrc_summary"
+android:dialogTitle="@string/pref_torrc_dialog"
+android:defaultValue=""
+/>
+    
+  
 <CheckBoxPreference
 android:key="pref_enable_logging"
 android:defaultValue="false"
diff --git a/src/org/torproject/android/service/TorResourceInstaller.java 
b/src/org/torproject/android/service/TorResourceInstaller.java
index 438e68d..b8cdf26 100644
--- a/src/org/torproject/android/service/TorResourceInstaller.java
+++ b/src/org/torproject/android/service/TorResourceInstaller.java
@@ -11,6 +11,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.StringBufferInputStream;
 import java.util.ArrayList;
 import java.util.concurrent.TimeoutException;
 import java.util.zip.ZipEntry;
@@ -115,7 +116,7 @@ public class TorResourceInstaller implements 
TorServiceConstants {
                return true;
        }
        
-       public boolean installTorrc () throws IOException, 
FileNotFoundException, TimeoutException
+       public boolean installTorrc (String extraLines) throws IOException, 
FileNotFoundException, TimeoutException
        {
                
                InputStream is;
@@ -128,6 +129,12 @@ public class TorResourceInstaller implements 
TorServiceConstants {
                shell.add(new SimpleCommand(COMMAND_RM_FORCE + 
outFile.getAbsolutePath())).waitForFinish();
                streamToFile(is,outFile, false, false);
 
+               if (extraLines != null && extraLines.length() > 0)
+               {
+                       StringBufferInputStream sbis = new 
StringBufferInputStream('\n' + extraLines + '\n');
+                       streamToFile(sbis,outFile,true,false);
+               }
+               
                return true;
        }
        
diff --git a/src/org/torproject/android/service/TorService.java 
b/src/org/torproject/android/service/TorService.java
index 0e44545..ce2d075 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -557,7 +557,10 @@ public class TorService extends Service implements 
TorServiceConstants, TorConst
                stopTor();
                
        TorResourceInstaller installer = new TorResourceInstaller(this, 
appBinHome); 
-               boolean success = installer.installTorrc();
+       
+       String extraLines = prefs.getString("pref_custom_torrc", null);
+       
+               boolean success = installer.installTorrc(extraLines);
                
                if (version == null || (!version.equals(BINARY_TOR_VERSION)) || 
(!fileTor.exists()))
                {
diff --git a/src/org/torproject/android/service/TorServiceConstants.java 
b/src/org/torproject/android/service/TorServiceConstants.java
index e50c416..74b2ef7 100644
--- a/src/org/torproject/android/service/TorServiceConstants.java
+++ b/src/org/torproject/android/service/TorServiceConstants.java
@@ -76,7 +76,7 @@ public interface TorServiceConstants {
     public static final int DISABLE_TOR_MSG = 3;
     public static final int LOG_MSG = 4;
     
-    public static final String BINARY_TOR_VERSION = "0.2.4.22-openssl1.0.1h.2";
+    public static final String BINARY_TOR_VERSION = "0.2.4.22-openssl1.0.1h";
     public static final String PREF_BINARY_TOR_VERSION_INSTALLED = 
"BINARY_TOR_VERSION_INSTALLED";
     
     //obfsproxy 



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to