ensure polipo conf is updated; default to 9051 for ctrl port
This commit is contained in:
parent
6ab9a7bff1
commit
c2be4ac15b
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue