Refactored TorMode classes

This commit is contained in:
Florian Reimair 2018-11-25 10:09:35 +01:00
parent 18cfc1a138
commit 6eeda23f31
3 changed files with 10 additions and 6 deletions

View File

@ -51,13 +51,12 @@ public class NewTor extends TorMode {
private final String torrcFile;
private final String torrcOptions;
private final Collection<String> bridgeEntries;
private final File torWorkikngDirectory;
public NewTor(File torWorkingDirectory, String torrcFile, String torrcOptions, Collection<String> bridgeEntries) {
super(torWorkingDirectory);
this.torrcFile = torrcFile;
this.torrcOptions = torrcOptions;
this.bridgeEntries = bridgeEntries;
this.torWorkikngDirectory = torWorkingDirectory;
}
@Override
@ -103,7 +102,7 @@ public class NewTor extends TorMode {
override = new Torrc(torrcOptionsMap);
log.info("Starting tor");
NativeTor result = new NativeTor(torWorkikngDirectory, bridgeEntries, override);
NativeTor result = new NativeTor(torDir, bridgeEntries, override);
log.info(
"\n################################################################\n"
+ "Tor started after {} ms. Start publishing hidden service.\n"

View File

@ -42,14 +42,13 @@ public class RunningTor extends TorMode {
private static final Logger log = LoggerFactory.getLogger(RunningTor.class);
private final int controlPort;
private final String password;
private final String torDir;
private final File cookieFile;
private final boolean useSafeCookieAuthentication;
public RunningTor(final File torDir, final int controlPort, final String password, final String cookieFile,
final boolean useSafeCookieAuthentication) {
this.torDir = torDir.getAbsolutePath();
super(torDir);
this.controlPort = controlPort;
this.password = password;
this.cookieFile = new File(cookieFile);
@ -81,7 +80,7 @@ public class RunningTor extends TorMode {
@Override
public String getHiddenServiceDirectory() {
return torDir + File.separator + "externalTorHiddenService";
return new File(torDir, "externalTorHiddenService").getAbsolutePath();
}
}

View File

@ -32,6 +32,12 @@ import org.berndpruenster.netlayer.tor.TorCtlException;
*/
public abstract class TorMode {
protected final File torDir;
public TorMode(File torDir) {
this.torDir = torDir;
}
/**
* Returns a fresh {@link Tor} object.
*