allow support for adding custom lines to torrc

This commit is contained in:
Nathan Freitas 2014-06-09 18:47:48 -04:00
parent 22938c9ed9
commit af51a98535
5 changed files with 26 additions and 3 deletions

View File

@ -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>

View File

@ -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"

View File

@ -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;
}

View File

@ -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()))
{

View File

@ -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