ensure readers are closed; ensure socks settings are applied

This commit is contained in:
Nathan Freitas 2014-06-11 08:08:11 -04:00
parent b4fa943fe9
commit aa8ff95e29
1 changed files with 11 additions and 7 deletions

View File

@ -948,9 +948,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
private int getControlPort () private int getControlPort ()
{ {
File fileControl = new File(appBinHome,"control.txt");
int result = -1;
try try
{ {
File fileControl = new File(appBinHome,"control.txt");
logNotice("Reading control port config file: " + fileControl.getAbsolutePath()); logNotice("Reading control port config file: " + fileControl.getAbsolutePath());
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileControl)); BufferedReader bufferedReader = new BufferedReader(new FileReader(fileControl));
@ -961,22 +963,23 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (line != null) if (line != null)
{ {
String[] lineParts = line.split(":"); String[] lineParts = line.split(":");
return Integer.parseInt(lineParts[1]); result = Integer.parseInt(lineParts[1]);
} }
bufferedReader.close();
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
logNotice("unable to get control port: no file yet"); logNotice("unable to get control port; no file at: " + fileControl.getAbsolutePath());
} }
catch (IOException e) catch (IOException e)
{ {
logNotice("unable to get control port IOException"); logNotice("unable to read control port config file");
} }
return -1; return result;
} }
private void checkAddressAndCountry () throws IOException private void checkAddressAndCountry () throws IOException
@ -2006,7 +2009,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mBinder.updateConfiguration("SafeSocks", safeSocks ? "1" : "0", false); mBinder.updateConfiguration("SafeSocks", safeSocks ? "1" : "0", false);
mBinder.updateConfiguration("TestSocks", "1", false); mBinder.updateConfiguration("TestSocks", "1", false);
mBinder.updateConfiguration("WarnUnsafeSocks", "1", false); mBinder.updateConfiguration("WarnUnsafeSocks", "1", false);
mBinder.saveConfiguration();
} }
private void blockPlaintextPorts (String portList) throws RemoteException private void blockPlaintextPorts (String portList) throws RemoteException