[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [puppetor/master] Make the tor executable configurable.
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue, 28 Jul 2009 21:11:49 +0200
Subject: Make the tor executable configurable.
Commit: e1081959873bbe01fd3b784f8a3e6f8053c2c29e
---
src/org/torproject/puppetor/ProxyNode.java | 15 ++++++++
.../torproject/puppetor/impl/ProxyNodeImpl.java | 37 ++++++++++++++++++--
2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/src/org/torproject/puppetor/ProxyNode.java b/src/org/torproject/puppetor/ProxyNode.java
index 8ddf3b5..50a5688 100644
--- a/src/org/torproject/puppetor/ProxyNode.java
+++ b/src/org/torproject/puppetor/ProxyNode.java
@@ -5,6 +5,7 @@
*/
package org.torproject.puppetor;
+import java.io.File;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;
@@ -306,4 +307,18 @@ public interface ProxyNode extends Remote {
*/
public abstract List<String> getConfiguration() throws RemoteException;
+ /**
+ * Configures this node to use the given tor executable rather than the
+ * one that is in the system path.
+ *
+ * @param executable
+ * The tor executable that will be used.
+ * @throws IllegalStateException
+ * Thrown if node is not in state
+ * <code>NodeState.CONFIGURING</code>.
+ * @throws IllegalArgumentException
+ * Thrown if the passed file does not exist or is a directory.
+ */
+ public abstract void setTorExecutable(File executable) throws RemoteException;
+
}
diff --git a/src/org/torproject/puppetor/impl/ProxyNodeImpl.java b/src/org/torproject/puppetor/impl/ProxyNodeImpl.java
index c7e4e4d..fc2bb72 100644
--- a/src/org/torproject/puppetor/impl/ProxyNodeImpl.java
+++ b/src/org/torproject/puppetor/impl/ProxyNodeImpl.java
@@ -38,10 +38,8 @@ public class ProxyNodeImpl extends UnicastRemoteObject implements ProxyNode {
/**
* Executable file containing Tor.
- *
- * TODO make this configurable!
*/
- protected static final File torExecutable = new File("tor");
+ protected File torExecutable = new File("tor");
/**
* The <code>torrc</code> configuration file of this Tor node.
@@ -719,6 +717,39 @@ public class ProxyNodeImpl extends UnicastRemoteObject implements ProxyNode {
return new ArrayList<String>(this.configuration);
}
+ public void setTorExecutable(File executable) {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "setTorExecutable");
+
+ // check state
+ if (this.nodeState != NodeState.CONFIGURING) {
+ IllegalStateException e = new IllegalStateException(
+ "Cannot change the tor executable after configuring!");
+ this.logger.throwing(this.getClass().getName(), "setTorExecutable",
+ e);
+ throw e;
+ }
+
+ // check if the file exists and is not a directory
+ if (executable == null || !executable.exists() ||
+ executable.isDirectory()) {
+ IllegalArgumentException e = new IllegalArgumentException(
+ "tor executable " + (executable == null ? "(null)"
+ : executable.getAbsolutePath()) + " is not a valid "
+ + "file!");
+ this.logger.throwing(this.getClass().getName(), "setTorExecutable",
+ e);
+ throw e;
+ }
+
+ // set executable
+ this.torExecutable = executable;
+
+ // log exiting
+ this.logger.exiting(this.getClass().getName(), "setTorExecutable");
+ }
+
/**
* Template configuration of proxy nodes.
*/
--
1.5.6.5