[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r11525: prepared all interfaces for remote access via RMI, enabled r (in puppetor/trunk/src/de/uniba/wiai/lspi/puppetor: . diststorage examples impl)
Author: kloesing
Date: 2007-09-19 16:30:32 -0400 (Wed, 19 Sep 2007)
New Revision: 11525
Modified:
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/AdvertisingAndAccessingV2HiddenServiceOverPrivateTorNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/DistributedStorage.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServDirectoryTest.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServRoutingTable.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/RendezvousServiceDescriptor.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java
Log:
prepared all interfaces for remote access via RMI, enabled router and directory nodes to specify another listen address than localhost
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,6 @@
package de.uniba.wiai.lspi.puppetor;
+import java.rmi.RemoteException;
import java.util.Set;
/**
@@ -23,9 +24,11 @@
* @throws TorProcessException
* Thrown if a problem occurs when determining the fingerprint
* of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract String determineDirServerString()
- throws TorProcessException;
+ throws TorProcessException, RemoteException;
/**
* Writes the given (possibly empty) set of onion router fingerprints to the
@@ -43,7 +46,31 @@
* @throws TorProcessException
* Thrown if the <code>approved-routers</code> file cannot be
* written to disk.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public void writeApprovedRouters(Set<String> approvedRouters)
- throws TorProcessException;
+ throws TorProcessException, RemoteException;
+
+ /**
+ * Adds the given set of onion router fingerprints to the
+ * <code>approved-routers</code> file of this node. This will confirm to
+ * directory clients, that the given routers can be trusted.
+ *
+ * @param approvedRouters
+ * The set of approved routers to be added. Each provided string
+ * must be formatted as
+ * <code>nickname 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000</code>.
+ * @throws IllegalArgumentException
+ * Thrown if <code>null</code> is passed as parameter;
+ * however, if an empty set is passed, the
+ * <code>approved-routers</code> file will not be changed.
+ * @throws TorProcessException
+ * Thrown if the <code>approved-routers</code> file cannot be
+ * written to disk.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public void addApprovedRouters(Set<String> approvedRouters)
+ throws TorProcessException, RemoteException;
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,16 +1,21 @@
package de.uniba.wiai.lspi.puppetor;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
/**
* Super-interface of those interfaces that can be the source for events.
*
* @author kloesing
*/
-public interface EventSource {
+public interface EventSource extends Remote {
/**
- * TODO document me
+ * Returns the name of this event source.
*
- * @return
+ * @return The name of this event source
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract String getName();
+ public abstract String getName() throws RemoteException;
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,6 +1,8 @@
package de.uniba.wiai.lspi.puppetor;
import java.io.File;
+import java.rmi.RemoteException;
+import java.util.Map;
/**
* A Network instance constitutes the central object of any test run and is
@@ -67,8 +69,11 @@
* <code>--list-fingerprint</code> option, reading files from
* the nodes' working directories, or writing the
* <code>approved-routers</code> files.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void configureAsPrivateNetwork() throws TorProcessException;
+ public abstract void configureAsPrivateNetwork()
+ throws TorProcessException, RemoteException;
/**
* Creates a new client application, but does not yet perform a request.
@@ -121,6 +126,33 @@
public abstract DirectoryNode createDirectory(String nodeName);
/**
+ * Creates a new directory node with automatically assigned ports that will
+ * listen on the given IP address and adds it to the network, but does not
+ * yet write its configuration to disk or start the corresponding Tor
+ * process. This operation can only be invoked, if network status is
+ * <code>NetworkState.CONFIGURING_NODES</code>.
+ *
+ * @param nodeName
+ * The name for this node, which is used as name for the working
+ * directory, for logging purposes, and as node nickname. May
+ * neither be <code>null</code> or have zero or more than 19
+ * alpha-numeric characters. The node name needs to be unique in
+ * this network.
+ * @param serverIpAddress
+ * The IP address on which the node will listen. Must be a valid
+ * IP v4 address in dotted decimal notation. May not be
+ * <code>null</code>.
+ * @return Reference to the created directory node.
+ * @throws IllegalStateException
+ * Thrown if network is not in state
+ * <code>NetworkState.CONFIGURING_NODES</code>.
+ * @throws IllegalArgumentException
+ * Thrown if an invalid value is given as node name.
+ */
+ public abstract DirectoryNode createDirectory(String nodeName,
+ String serverIpAddress);
+
+ /**
* Creates a new directory node and adds it to the network, but does not yet
* write its configuration to disk or start the corresponding Tor process.
* This operation can only be invoked, if network status is
@@ -159,6 +191,49 @@
int controlPort, int socksPort, int orPort, int dirPort);
/**
+ * Creates a new directory node that will listen on the given IP address and
+ * adds it to the network, but does not yet write its configuration to disk
+ * or start the corresponding Tor process. This operation can only be
+ * invoked, if network status is <code>NetworkState.CONFIGURING_NODES</code>.
+ *
+ * @param nodeName
+ * The name for this node, which is used as name for the working
+ * directory, for logging purposes, and as node nickname. May
+ * neither be <code>null</code> or have zero or more than 19
+ * alpha-numeric characters. The node name needs to be unique in
+ * this network.
+ * @param controlPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for a controller. May not be negative or greater than 65535.
+ * @param socksPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for incoming SOCKS requests. May not be negative or greater
+ * than 65535.
+ * @param orPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for incoming requests from other onion routers. May not be
+ * negative or greater than 65535.
+ * @param dirPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for incoming directory requests. May not be negative or
+ * greater than 65535.
+ * @param serverIpAddress
+ * The IP address on which the node will listen. Must be a valid
+ * IP v4 address in dotted decimal notation. May not be
+ * <code>null</code>.
+ * @return Reference to the created directory node.
+ * @throws IllegalStateException
+ * Thrown if network is not in state
+ * <code>NetworkState.CONFIGURING_NODES</code>.
+ * @throws IllegalArgumentException
+ * Thrown if an invalid value is given for either of the
+ * parameters.
+ */
+ public abstract DirectoryNode createDirectory(String nodeName,
+ int controlPort, int socksPort, int orPort, int dirPort,
+ String serverIpAddress);
+
+ /**
* Creates a new <code>ProxyNode</code> with automatically assigned ports
* and adds it to the network, but does not yet write its configuration to
* disk or start the corresponding Tor process.
@@ -252,6 +327,68 @@
int socksPort, int orPort, int dirPort);
/**
+ * Creates a new <code>RouterNode</code> with automatically assigned ports
+ * that will listen on the given IP address and adds it to the network, but
+ * does not yet write its configuration to disk or start the corresponding
+ * Tor process.
+ *
+ * @param nodeName
+ * The name for this node, which is used as name for the working
+ * directory, for logging purposes, and as node nickname. May
+ * neither be <code>null</code> or have zero or more than 19
+ * alpha-numeric characters. The node name needs to be unique in
+ * this network.
+ * @param serverIpAddress
+ * The IP address on which the node will listen. Must be a valid
+ * IP v4 address in dotted decimal notation. May not be
+ * <code>null</code>.
+ * @return Reference to the created router node.
+ * @throws IllegalArgumentException
+ * Thrown if an invalid value is given as node name.
+ */
+ public abstract RouterNode createRouter(String nodeName,
+ String serverIpAddress);
+
+ /**
+ * Creates a new <code>RouterNode</code> that will listen on the given IP
+ * address and adds it to the network, but does not yet write its
+ * configuration to disk or start the corresponding Tor process.
+ *
+ * @param nodeName
+ * The name for this node, which is used as name for the working
+ * directory, for logging purposes, and as node nickname. May
+ * neither be <code>null</code> or have zero or more than 19
+ * alpha-numeric characters. The node name needs to be unique in
+ * this network.
+ * @param controlPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for a controller. May not be negative or greater than 65535.
+ * @param socksPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for incoming SOCKS requests. May not be negative or greater
+ * than 65535.
+ * @param orPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for incoming requests from other onion routers. May not be
+ * negative or greater than 65535.
+ * @param dirPort
+ * The TCP port on which the corresponding Tor process will wait
+ * for incoming directory requests which in fact are requests for
+ * the mirrored directory. May not be negative or greater than
+ * 65535.
+ * @param serverIpAddress
+ * The IP address on which the node will listen. Must be a valid
+ * IP v4 address in dotted decimal notation. May not be
+ * <code>null</code>.
+ * @return Reference to the created router node.
+ * @throws IllegalArgumentException
+ * Thrown if an invalid value is given for either of the
+ * parameters.
+ */
+ public abstract RouterNode createRouter(String nodeName, int controlPort,
+ int socksPort, int orPort, int dirPort, String serverIpAddress);
+
+ /**
* Creates a new <code>ServerApplication</code> with automatically
* assigned ports, but does not start listening for incoming requests.
*
@@ -300,8 +437,17 @@
public abstract NetworkState getNetworkState();
/**
- * Returns the <code>ProxyNode</code> with name <code>nodeName</code>.
+ * Returns (a copy of) the map containing the names of all directory nodes
+ * as keys and the corresponding directory nodes as values.
*
+ * @return Map containing all directory nodes.
+ */
+ public abstract Map<String, DirectoryNode> getAllDirectoryNodes();
+
+ /**
+ * Returns the <code>ProxyNode</code> with name <code>nodeName</code> or
+ * <code>null</code> if no such node exists.
+ *
* @param nodeName
* The node name to look up.
* @return The <code>ProxyNode</code> with name <code>nodeName</code>.
@@ -309,6 +455,26 @@
public abstract ProxyNode getProxyNode(String nodeName);
/**
+ * Returns the <code>RouterNode</code> with name <code>nodeName</code>
+ * or <code>null</code> if no such node exists.
+ *
+ * @param nodeName
+ * The node name to look up.
+ * @return The <code>RouterNode</code> with name <code>nodeName</code>.
+ */
+ public abstract RouterNode getRouterNode(String nodeName);
+
+ /**
+ * Returns the <code>DirectoryNode</code> with name <code>nodeName</code>
+ * or <code>null</code> if no such node exists.
+ *
+ * @param nodeName
+ * The node name to look up.
+ * @return The <code>DirectoryNode</code> with name <code>nodeName</code>.
+ */
+ public abstract DirectoryNode getDirectoryNode(String nodeName);
+
+ /**
* <p>
* Sends a HUP signal to all nodes in the network in regular intervals and
* blocks the invoking thread until all nodes have reported to have
@@ -350,9 +516,11 @@
* Thrown if an I/O problem occurs while sending HUP signals.
* @return <code>true</code> if all nodes have reported to have
* successfully opened a circuit, <code>false</code> otherwise.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract boolean hupUntilUp(int tries, long hupInterval)
- throws TorProcessException;
+ throws TorProcessException, RemoteException;
/**
* Attempts to shut down all running nodes. The method blocks until all
@@ -367,8 +535,11 @@
* @throws TorProcessException
* Thrown if an I/O problem occurs while shutting down the
* nodes.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void shutdownNodes() throws TorProcessException;
+ public abstract void shutdownNodes() throws TorProcessException,
+ RemoteException;
/**
* Attempts to start all nodes within a given timeout of
@@ -411,9 +582,12 @@
* @throws TorProcessException
* Thrown if an I/O problem occurs while writing to the nodes'
* working directories.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void writeConfigurations() throws TorProcessException;
-
+ public abstract void writeConfigurations() throws TorProcessException,
+ RemoteException;
+
/**
* Returns the working directory of this network configuration which is in
* test-env/networkName/.
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -42,7 +42,6 @@
* nodes created by this <code>Network</code>; must be a value
* between 1024 and 65535.
* @return A new network instance.
- * @throws RemoteException
*/
public static Network createNetwork(String networkName, int startPort) {
return new NetworkImpl(networkName, startPort);
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,8 @@
package de.uniba.wiai.lspi.puppetor;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.List;
import java.util.Set;
/**
@@ -37,7 +40,7 @@
*
* @author kloesing
*/
-public interface ProxyNode extends EventSource {
+public interface ProxyNode extends EventSource, Remote {
/**
* Adds the entries for a hidden service to the configuration of this node.
@@ -66,9 +69,11 @@
* @throws IllegalArgumentException
* Thrown if an invalid value is given for either of the
* parameters.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract void addHiddenService(String serviceName, int servicePort,
- int virtualPort);
+ int virtualPort) throws RemoteException;
/**
* Adds the given set of DirServer configuration entries to the
@@ -84,9 +89,11 @@
* <code>null</code>, but may be an empty set.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed as parameter.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract void configureDirServers(
- Set<String> authorizedDirServerStrings);
+ Set<String> authorizedDirServerStrings) throws RemoteException;
/**
* Adds the given configuration string, consisting of "<configuration key>
@@ -101,8 +108,11 @@
* @throws IllegalStateException
* Thrown if not invoked in state
* <code>NodeState.CONFIGURING</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void addConfiguration(String configurationString);
+ public abstract void addConfiguration(String configurationString)
+ throws RemoteException;
/**
* Replaces the first configuration string, consisting of "<configuration
@@ -121,22 +131,29 @@
* @throws IllegalStateException
* Thrown if not invoked in state
* <code>NodeState.CONFIGURING</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void replaceConfiguration(String configurationString);
+ public abstract void replaceConfiguration(String configurationString)
+ throws RemoteException;
/**
* Returns the name of this node.
*
* @return The name of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract String getNodeName();
+ public abstract String getNodeName() throws RemoteException;
/**
* Returns the state of this node.
*
* @return The state of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract NodeState getNodeState();
+ public abstract NodeState getNodeState() throws RemoteException;
/**
* Determines the onion address for a previously added hidden service with
@@ -162,9 +179,11 @@
* the given <code>serviceName</code> as directory, if the
* given <code>version</code> is invalid, or if the
* <code>hostname</code> file could not be read.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract String getOnionAddress(String serviceName, int version)
- throws TorProcessException;
+ throws TorProcessException, RemoteException;
/**
* Sends a HUP command to the process via its control port to restart it;
@@ -217,9 +236,11 @@
* @throws TorProcessException
* Thrown if either the process could not be started, or the
* connection to the control port could not be established.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract boolean startNode(long maximumTimeToWaitInMillis)
- throws TorProcessException;
+ throws TorProcessException, RemoteException;
/**
* Writes the configuration of this node to the <code>torrc</code> file in
@@ -232,21 +253,39 @@
* @throws TorProcessException
* Thrown if the configuration file <code>torrc</code> cannot
* be written to disk.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void writeConfiguration() throws TorProcessException;
+ public abstract void writeConfiguration() throws TorProcessException,
+ RemoteException;
/**
* Returns the SOCKS port of this node.
*
* @return The SOCKS port of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract int getSocksPort();
+ public abstract int getSocksPort() throws RemoteException;
/**
* Returns the control port of this node.
*
* @return The control port of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract int getControlPort();
+ public abstract int getControlPort() throws RemoteException;
+ /**
+ * Returns (a copy of) the list of strings containing the configuration of
+ * this node.
+ *
+ * @return (A copy of) the list of strings containing the configuration of
+ * this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public abstract List<String> getConfiguration() throws RemoteException;
+
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor;
+import java.rmi.RemoteException;
+
/**
* A <code>RouterNode</code> represents a Tor process that is configured to
* both, relay traffic from a local application to the Tor network and to route
@@ -50,8 +52,11 @@
* configuration file cannot be written, the Tor process cannot
* be started temporarily, or the fingerprint file cannot be
* read.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract String determineFingerprint() throws TorProcessException;
+ public abstract String determineFingerprint() throws TorProcessException,
+ RemoteException;
/**
* Returns the base32-encoded fingerprint of this node.
@@ -61,21 +66,40 @@
* Thrown if node is neither in state
* <code>NodeState.RUNNING</code> or
* <code>NodeState.SHUT_DOWN</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract String getFingerprintBase32();
+ public abstract String getFingerprintBase32() throws RemoteException;
/**
* Returns the dir port of this node.
*
* @return The dir port of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract int getDirPort();
+ public abstract int getDirPort() throws RemoteException;
/**
* Returns the onion port of this node.
*
* @return The onion port of this node.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract int getOrPort();
+ public abstract int getOrPort() throws RemoteException;
+ /**
+ * Returns the fingerprint of this node formatted like
+ * <code>0000 0000 0000 0000 0000 0000 0000 0000 0000 0000</code>.
+ *
+ * @return The fingerprint of this node.
+ * @throws IllegalStateException
+ * Thrown if node is neither in state
+ * <code>NodeState.RUNNING</code> or
+ * <code>NodeState.SHUT_DOWN</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public abstract String getFingerprint() throws RemoteException;
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/AdvertisingAndAccessingV2HiddenServiceOverPrivateTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/AdvertisingAndAccessingV2HiddenServiceOverPrivateTorNetwork.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/AdvertisingAndAccessingV2HiddenServiceOverPrivateTorNetwork.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,6 @@
package de.uniba.wiai.lspi.puppetor.diststorage;
+import java.rmi.RemoteException;
import java.util.Date;
import java.util.Random;
@@ -31,8 +32,11 @@
* @throws TorProcessException
* Thrown if there is a problem with the JVM-external Tor
* processes that we cannot handle.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static void main(String[] args) throws TorProcessException {
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
int portStart = 7000;
@@ -179,14 +183,14 @@
server.listen();
System.out.println("Started server with onion address '" + onionAddress
+ "'");
-
+
Random rnd = new Random();
for (int i = 0; i < 10; i++) {
int socksPort = portStart + 22 + rnd.nextInt(4) * 10;
System.out.println("Socks Port = " + socksPort);
-
+
// create client application
ClientApplication client = network.createClient("client",
onionAddress, 80, socksPort);
@@ -199,7 +203,7 @@
} catch (InterruptedException e) {
}
}
-
+
// shut down nodes
network.shutdownNodes();
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/DistributedStorage.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/DistributedStorage.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/DistributedStorage.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -11,6 +11,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -148,7 +149,11 @@
this.twentyFourHoursUp = true;
// add to set of running hidden service directories
- globalRoutingTable.addHiddenServiceDirectory(this.hsdNode);
+ try {
+ globalRoutingTable.addHiddenServiceDirectory(this.hsdNode);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
// measure how long the current nodes need to get aware of this
// hidden service directory
@@ -188,7 +193,12 @@
}
// remove from set of running hidden service directories
- globalRoutingTable.removeHiddenServiceDirectory(this.hsdNode);
+ try {
+ globalRoutingTable
+ .removeHiddenServiceDirectory(this.hsdNode);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
// stop listening for events
manager.removeEventListener(this);
@@ -197,21 +207,30 @@
// handle it any more
this.twentyFourHoursUp = false;
- } else if (event.getType() == EventType.NODE_ROUTING_TABLE_CHANGED
- && event.getMessage().contains(
- this.hsdNode.getFingerprintBase32())) {
- // when some node reports to have changed its routing table and
- // now includes the node ID of the represented node, remember
- // that node for later offline propagation measurement
- nodesThatKnowMe.add(event.getSource());
+ } else
+ try {
+ if (event.getType() == EventType.NODE_ROUTING_TABLE_CHANGED
+ && event.getMessage().contains(
+ this.hsdNode.getFingerprintBase32())) {
+ // when some node reports to have changed its routing
+ // table and
+ // now includes the node ID of the represented node,
+ // remember
+ // that node for later offline propagation measurement
+ nodesThatKnowMe.add(event.getSource());
- } else if (event.getType() == EventType.NODE_STOPPED
- && event.getSource() != this.hsdNode) {
- // when some other node is stopped, remove it from the list of
- // nodes that know that the represented hidden service directory
- // is online
- nodesThatKnowMe.remove(event.getSource());
- }
+ } else if (event.getType() == EventType.NODE_STOPPED
+ && event.getSource() != this.hsdNode) {
+ // when some other node is stopped, remove it from the
+ // list of
+ // nodes that know that the represented hidden service
+ // directory
+ // is online
+ nodesThatKnowMe.remove(event.getSource());
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
}
@@ -319,11 +338,16 @@
// print out measurement result
long duration = System.currentTimeMillis() - startingTime;
- System.out.println(new Date() + ": Online propagation for HSDir "
- + this.hsdNode.getName() + " to node "
- + this.node.getName() + " took " + (duration / 1000)
- + " seconds and ended in state "
- + measurementState.toString());
+ try {
+ System.out.println(new Date()
+ + ": Online propagation for HSDir "
+ + this.hsdNode.getName() + " to node "
+ + this.node.getName() + " took " + (duration / 1000)
+ + " seconds and ended in state "
+ + measurementState.toString());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
if (this.measurementState == MeasurementState.SUCCEEDED) {
resultWriter.writeOnlinePropagation(duration / 1000);
} else if (this.measurementState == MeasurementState.FAILED) {
@@ -338,21 +362,26 @@
return;
}
- if (event.getSource() == this.node
- && event.getType() == EventType.NODE_ROUTING_TABLE_CHANGED
- && event.getMessage().contains(
- this.hsdNode.getFingerprintBase32())) {
- // when the node has added the node ID of the hidden service
- // directory, succeed the measurement
- this.measurementState = MeasurementState.SUCCEEDED;
- notify();
+ try {
+ if (event.getSource() == this.node
+ && event.getType() == EventType.NODE_ROUTING_TABLE_CHANGED
+ && event.getMessage().contains(
+ this.hsdNode.getFingerprintBase32())) {
+ // when the node has added the node ID of the hidden service
+ // directory, succeed the measurement
+ this.measurementState = MeasurementState.SUCCEEDED;
+ notify();
- } else if (event.getType() == EventType.NODE_STOPPED) {
- // when either the node or the hidden service directory were
- // stopped within the one hour period, the measurement cannot be
- // succeeded anymore and is therefore aborted
- this.measurementState = MeasurementState.ABORTED;
- notify();
+ } else if (event.getType() == EventType.NODE_STOPPED) {
+ // when either the node or the hidden service directory were
+ // stopped within the one hour period, the measurement
+ // cannot be
+ // succeeded anymore and is therefore aborted
+ this.measurementState = MeasurementState.ABORTED;
+ notify();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
}
}
}
@@ -432,11 +461,16 @@
// print out measurement result
long duration = System.currentTimeMillis() - startingTime;
- System.out.println(new Date() + ": Offline propagation for HSDir "
- + this.hsdNode.getName() + " to node "
- + this.node.getName() + " took " + (duration / 1000)
- + " seconds and ended in state "
- + measurementState.toString());
+ try {
+ System.out.println(new Date()
+ + ": Offline propagation for HSDir "
+ + this.hsdNode.getName() + " to node "
+ + this.node.getName() + " took " + (duration / 1000)
+ + " seconds and ended in state "
+ + measurementState.toString());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
if (this.measurementState == MeasurementState.SUCCEEDED) {
resultWriter.writeOfflinePropagation(duration / 1000);
} else if (this.measurementState == MeasurementState.FAILED) {
@@ -451,20 +485,25 @@
return;
}
- if (event.getType() == EventType.NODE_ROUTING_TABLE_CHANGED
- && !event.getMessage().contains(
- this.hsdNode.getFingerprintBase32())) {
- // when the node has removed the node ID of the hidden service
- // directory, succeed the measurement
- this.measurementState = MeasurementState.SUCCEEDED;
- notify();
+ try {
+ if (event.getType() == EventType.NODE_ROUTING_TABLE_CHANGED
+ && !event.getMessage().contains(
+ this.hsdNode.getFingerprintBase32())) {
+ // when the node has removed the node ID of the hidden
+ // service
+ // directory, succeed the measurement
+ this.measurementState = MeasurementState.SUCCEEDED;
+ notify();
- } else if (event.getType() == EventType.NODE_STOPPED) {
- // when the node was stopped within the waiting period, the
- // measurement cannot be
- // succeeded anymore and is therefore aborted
- this.measurementState = MeasurementState.ABORTED;
- notify();
+ } else if (event.getType() == EventType.NODE_STOPPED) {
+ // when the node was stopped within the waiting period, the
+ // measurement cannot be
+ // succeeded anymore and is therefore aborted
+ this.measurementState = MeasurementState.ABORTED;
+ notify();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
}
}
}
@@ -708,12 +747,16 @@
// print out measurement result
long duration = System.currentTimeMillis() - startingTime;
- System.out.println(new Date()
- + ": Descriptor propagation for desc ID " + this.descid
- + " took " + (duration / 1000)
- + " seconds to responsible HS directory "
- + this.responsibleHSDir.getName() + " and ended in state "
- + measurementState.toString());
+ try {
+ System.out.println(new Date()
+ + ": Descriptor propagation for desc ID " + this.descid
+ + " took " + (duration / 1000)
+ + " seconds to responsible HS directory "
+ + this.responsibleHSDir.getName()
+ + " and ended in state " + measurementState.toString());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
if (this.measurementState == MeasurementState.SUCCEEDED) {
resultWriter.writeDescriptorPropagation(duration / 1000);
} else if (this.measurementState == MeasurementState.FAILED) {
@@ -926,7 +969,12 @@
manager.addEventListener(useAsProxy, this);
// determine socks port of proxy
- int socksPort = useAsProxy.getSocksPort();
+ int socksPort = 0;
+ try {
+ socksPort = useAsProxy.getSocksPort();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
// create client application and register for events originating
// from it
@@ -968,19 +1016,23 @@
manager.removeEventListener(this);
// print out measurement result
- System.out
- .println(System.currentTimeMillis()
- + ": Hidden service request for onion address "
- + this.onionAddress
- + " running on node "
- + this.providingNode.getName()
- + " using node "
- + this.useAsProxy.getName()
- + " as proxy took "
- + (replyReceivedAtClient > 0
- && requestSentFromClient > 0 ? ((replyReceivedAtClient - requestSentFromClient) / 1000)
- : -1) + " seconds and ended in state "
- + measurementState.toString());
+ try {
+ System.out
+ .println(System.currentTimeMillis()
+ + ": Hidden service request for onion address "
+ + this.onionAddress
+ + " running on node "
+ + this.providingNode.getName()
+ + " using node "
+ + this.useAsProxy.getName()
+ + " as proxy took "
+ + (replyReceivedAtClient > 0
+ && requestSentFromClient > 0 ? ((replyReceivedAtClient - requestSentFromClient) / 1000)
+ : -1) + " seconds and ended in state "
+ + measurementState.toString());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
if (this.measurementState == MeasurementState.SUCCEEDED) {
resultWriter
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServDirectoryTest.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServDirectoryTest.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServDirectoryTest.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -5,6 +5,7 @@
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
+import java.rmi.RemoteException;
import java.security.Security;
import java.util.ArrayList;
import java.util.Date;
@@ -173,8 +174,11 @@
* @throws TorProcessException
* Thrown if there is a problem with the JVM-external Tor
* processes that we cannot handle.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static void main(String[] args) throws TorProcessException {
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
int portStart = 7000;
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServRoutingTable.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServRoutingTable.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/HidServRoutingTable.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,6 @@
package de.uniba.wiai.lspi.puppetor.diststorage;
+import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
@@ -101,8 +102,11 @@
*
* @param hsdNode
* The node to be added as hidden service directory.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public synchronized void addHiddenServiceDirectory(RouterNode hsdNode) {
+ public synchronized void addHiddenServiceDirectory(RouterNode hsdNode)
+ throws RemoteException {
this.hsDirs.put(hsdNode.getFingerprintBase32(), hsdNode);
notifyAll();
}
@@ -111,8 +115,8 @@
StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()
+ ": hsdirs={ ");
for (String nodeID : this.hsDirs.keySet()) {
- sb.append(this.hsDirs.get(nodeID).getName() + "("
- + nodeID.substring(0, 4) + "),");
+ sb.append(this.hsDirs.get(nodeID) + "(" + nodeID.substring(0, 4)
+ + "),");
}
String result = sb.toString();
result = result.substring(0, result.length() - 1) + " }";
@@ -124,8 +128,11 @@
*
* @param hsdNode
* The hidden service directory to be removed.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public synchronized void removeHiddenServiceDirectory(RouterNode hsdNode) {
+ public synchronized void removeHiddenServiceDirectory(RouterNode hsdNode)
+ throws RemoteException {
this.hsDirs.remove(hsdNode.getFingerprintBase32());
notifyAll();
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/RendezvousServiceDescriptor.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/RendezvousServiceDescriptor.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/RendezvousServiceDescriptor.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -13,7 +13,6 @@
import java.util.Random;
import org.bouncycastle.asn1.ASN1OutputStream;
-import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
import org.bouncycastle.asn1.x509.RSAPublicKeyStructure;
import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.crypto.digests.SHA1Digest;
@@ -91,9 +90,9 @@
RSAPublicKeyStructure key = new RSAPublicKeyStructure(pubKey
.getModulus(), pubKey.getPublicExponent());
rsd.publicKeyString = getPEMStringFromRSAPublicKey(key);
- RSAPrivateKeyStructure privateKey = new RSAPrivateKeyStructure(
- privKey.getModulus(), pubKey.getPublicExponent(), privKey
- .getPrivateExponent(), null, null, null, null, null);
+ // RSAPrivateKeyStructure privateKey = new RSAPrivateKeyStructure(
+ // privKey.getModulus(), pubKey.getPublicExponent(), privKey
+ // .getPrivateExponent(), null, null, null, null, null);
Random rnd = new Random();
byte[] secretIdPartBytes = new byte[20];
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor.examples;
+import java.rmi.RemoteException;
+
import de.uniba.wiai.lspi.puppetor.ClientApplication;
import de.uniba.wiai.lspi.puppetor.Event;
import de.uniba.wiai.lspi.puppetor.EventListener;
@@ -25,8 +27,11 @@
* @throws TorProcessException
* Thrown if there is a problem with the JVM-external Tor
* processes that we cannot handle.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static void main(String[] args) throws TorProcessException {
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
// though we only need a single proxy, we always need to create a
// network to initialize a test case.
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor.examples;
+import java.rmi.RemoteException;
+
import de.uniba.wiai.lspi.puppetor.ClientApplication;
import de.uniba.wiai.lspi.puppetor.Event;
import de.uniba.wiai.lspi.puppetor.EventListener;
@@ -27,8 +29,11 @@
* @throws TorProcessException
* Thrown if there is a problem with the JVM-external Tor
* processes that we cannot handle.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static void main(String[] args) throws TorProcessException {
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
// create a network to initialize a test case
Network network = NetworkFactory.createNetwork("example4");
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor.examples;
+import java.rmi.RemoteException;
+
import de.uniba.wiai.lspi.puppetor.ClientApplication;
import de.uniba.wiai.lspi.puppetor.Event;
import de.uniba.wiai.lspi.puppetor.EventListener;
@@ -27,8 +29,11 @@
* @throws TorProcessException
* Thrown if there is a problem with the JVM-external Tor
* processes that we cannot handle.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static void main(String[] args) throws TorProcessException {
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
// create a network to initialize a test case
Network network = NetworkFactory.createNetwork("example3");
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor.examples;
+import java.rmi.RemoteException;
+
import de.uniba.wiai.lspi.puppetor.Event;
import de.uniba.wiai.lspi.puppetor.EventListener;
import de.uniba.wiai.lspi.puppetor.EventManager;
@@ -24,8 +26,11 @@
* @throws TorProcessException
* Thrown if there is a problem with the JVM-external Tor
* processes that we cannot handle.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static void main(String[] args) throws TorProcessException {
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
// though we only need one proxy, we always need to create a network
// to initialize a test case
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -4,6 +4,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.rmi.RemoteException;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -19,6 +20,11 @@
public class DirectoryNodeImpl extends RouterNodeImpl implements DirectoryNode {
/**
+ * Set of routers that are approved by this directory node.
+ */
+ private SortedSet<String> approvedRouters;
+
+ /**
* Creates a <code>DirectoryNodeImpl</code> and adds it to the given
* <code>network</code>, but does not yet write its configuration to disk
* or start the corresponding Tor process.
@@ -43,22 +49,30 @@
* Port on which the Tor node will be listening for directory
* requests from other Tor nodes. May not be negative or greater
* than 65535.
+ * @param serverIpAddress
+ * The IP address on which the node will listen. Must be a valid
+ * IP v4 address in dotted decimal notation. May not be
+ * <code>null</code>.
* @throws IllegalArgumentException
* If at least one of the parameters is <code>null</code> or
* has an invalid value.
*/
DirectoryNodeImpl(NetworkImpl network, String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress) {
// create superclass instance; parameter checking is done in super
// constructor
- super(network, nodeName, controlPort, socksPort, orPort, dirPort);
+ super(network, nodeName, controlPort, socksPort, orPort, dirPort,
+ serverIpAddress);
// log entering
this.logger.entering(this.getClass().getName(), "DirectoryNodeImpl",
new Object[] { network, nodeName, controlPort, socksPort,
orPort, dirPort });
+ // initialize attribute
+ this.approvedRouters = new TreeSet<String>();
+
// configure this node as an authoritative directory
this.configuration.add("AuthoritativeDirectory 1");
@@ -102,8 +116,8 @@
// put everything together
String dirServerString = "DirServer " + this.nodeName + " hs orport="
- + this.orPort + " " + localIpAddress + ":" + this.dirPort + " "
- + fingerprint;
+ + this.orPort + " " + this.serverIpAddress + ":" + this.dirPort
+ + " " + fingerprint;
// log exiting and return dir server string
this.logger.exiting(this.getClass().getName(),
@@ -111,44 +125,62 @@
return dirServerString;
}
- public synchronized void writeApprovedRouters(Set<String> approvedRouters)
- throws TorProcessException {
+ public synchronized void writeApprovedRouters(Set<String> routers)
+ throws TorProcessException, RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "writeApprovedRouters",
- approvedRouters);
+ routers);
+ // clear the existing set of approved routers
+ this.approvedRouters.clear();
+
+ // invoke addApprovedRouters to perform the actual work
+ this.addApprovedRouters(routers);
+
+ // log exiting
+ this.logger.exiting(this.getClass().getName(), "writeApprovedRouters");
+ }
+
+ public void addApprovedRouters(Set<String> routers)
+ throws TorProcessException, RemoteException {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "addApprovedRouters",
+ routers);
+
// check parameter
- if (approvedRouters == null) {
+ if (routers == null) {
IllegalArgumentException e = new IllegalArgumentException();
this.logger.throwing(this.getClass().getName(),
- "writeApprovedRouters", e);
+ "addApprovedRouters", e);
throw e;
}
- // sort the given approved router strings alphabetically and store them
- // to file
+ // add the given approved router strings to the sorted set of already
+ // known strings (if any)
+ this.approvedRouters.addAll(routers);
+
+ // store the complete set of approved router strings to file
try {
File approvedRoutersFile = new File(this.workingDir
.getAbsolutePath()
+ File.separator + "approved-routers");
BufferedWriter bw = new BufferedWriter(new FileWriter(
approvedRoutersFile));
- SortedSet<String> sortedApprovedRouters = new TreeSet<String>(
- approvedRouters);
- for (String approvedRouter : sortedApprovedRouters) {
+ for (String approvedRouter : this.approvedRouters) {
bw.write(approvedRouter + "\n");
}
bw.close();
} catch (IOException e) {
TorProcessException ex = new TorProcessException(e);
this.logger.throwing(this.getClass().getName(),
- "writeApprovedRouters", ex);
+ "addApprovedRouters", ex);
throw ex;
}
// log exiting
- this.logger.exiting(this.getClass().getName(), "writeApprovedRouters");
+ this.logger.exiting(this.getClass().getName(), "addApprovedRouters");
}
public synchronized String determineFingerprint()
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -87,7 +87,7 @@
public String toString() {
return this.getClass().getSimpleName() + ": occurenceTime="
+ new Date(this.occurrenceTime) + ", source=\""
- + this.source.getName() + "\", type=" + this.type.toString()
+ + this.source.toString() + "\", type=" + this.type.toString()
+ ", message=\"" + this.message + "\"";
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -1,8 +1,10 @@
package de.uniba.wiai.lspi.puppetor.impl;
import java.io.File;
+import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -77,6 +79,11 @@
"Caught an exception while determining fingerprint for "
+ "node " + node.toString() + "!");
this.caughtException = e;
+ } catch (RemoteException e) {
+ logger.log(Level.SEVERE,
+ "Caught a remote exception while determining fingerprint for "
+ + "node " + node.toString() + "!");
+ // TODO handle exception appropriately
}
// log exiting
@@ -149,6 +156,11 @@
// if an exception is caught, store it, but don't throw it (the
// thread wouldn't care)
this.caughtException = e;
+ } catch (RemoteException e) {
+ logger.log(Level.SEVERE,
+ "Caught a remote exception while starting " + "node "
+ + node.toString() + "!");
+ // TODO handle exception appropriately
}
// log exiting
@@ -327,7 +339,8 @@
return true;
}
- public void configureAsPrivateNetwork() throws TorProcessException {
+ public void configureAsPrivateNetwork() throws TorProcessException,
+ RemoteException {
// log entering
this.logger.entering(this.getClass().getName(),
@@ -433,12 +446,12 @@
}
public DirectoryNode createDirectory(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress) {
// log entering
this.logger.entering(this.getClass().getName(), "createDirectory",
new Object[] { nodeName, controlPort, socksPort, orPort,
- dirPort });
+ dirPort, serverIpAddress });
// check state
if (this.networkState != NetworkState.CONFIGURING_NODES) {
@@ -459,16 +472,49 @@
// create directory node; parameter checking is done in constructor
DirectoryNode dir = new DirectoryNodeImpl(this, nodeName, controlPort,
- socksPort, orPort, dirPort);
+ socksPort, orPort, dirPort, serverIpAddress);
// add new directory node to nodes collection
- this.nodes.put(dir.getNodeName(), dir);
+ this.nodes.put(nodeName, dir);
// log exiting and return directory node
this.logger.exiting(this.getClass().getName(), "createDirectory", dir);
return dir;
}
+ public DirectoryNode createDirectory(String nodeName, int controlPort,
+ int socksPort, int orPort, int dirPort) {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "createDirectory",
+ new Object[] { nodeName, controlPort, socksPort, orPort,
+ dirPort });
+
+ // invoke overloaded method
+ DirectoryNode dir = this.createDirectory(nodeName, controlPort,
+ socksPort, orPort, dirPort, "127.0.0.1");
+
+ // log exiting and return directory node
+ this.logger.exiting(this.getClass().getName(), "createDirectory", dir);
+ return dir;
+ }
+
+ public DirectoryNode createDirectory(String nodeName, String serverIpAddress) {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "createDirectory",
+ new Object[] { nodeName, serverIpAddress });
+
+ // invoke overloaded method
+ DirectoryNode dir = this.createDirectory(nodeName, this.portCounter++,
+ this.portCounter++, this.portCounter++, this.portCounter++,
+ serverIpAddress);
+
+ // log exiting and return directory node
+ this.logger.exiting(this.getClass().getName(), "createDirectory", dir);
+ return dir;
+ }
+
public DirectoryNode createDirectory(String nodeName) {
// log entering
@@ -476,8 +522,9 @@
nodeName);
// invoke overloaded method
- DirectoryNode dir = this.createDirectory(nodeName, portCounter++,
- portCounter++, portCounter++, portCounter++);
+ DirectoryNode dir = this.createDirectory(nodeName, this.portCounter++,
+ this.portCounter++, this.portCounter++, this.portCounter++,
+ "127.0.0.1");
// log exiting and return directory node
this.logger.exiting(this.getClass().getName(), "createDirectory", dir);
@@ -504,7 +551,7 @@
socksPort);
// add new proxy node to nodes collection
- this.nodes.put(proxy.getNodeName(), proxy);
+ this.nodes.put(nodeName, proxy);
// log exiting and return proxy node
this.logger.exiting(this.getClass().getName(), "createProxy", proxy);
@@ -518,8 +565,8 @@
.entering(this.getClass().getName(), "createProxy", nodeName);
// invoke overloaded method
- ProxyNode proxy = this.createProxy(nodeName, portCounter++,
- portCounter++);
+ ProxyNode proxy = this.createProxy(nodeName, this.portCounter++,
+ this.portCounter++);
// log exiting and return proxy node
this.logger.exiting(this.getClass().getName(), "createProxy", proxy);
@@ -527,12 +574,12 @@
}
public RouterNode createRouter(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress) {
// log entering
this.logger.entering(this.getClass().getName(), "createRouter",
new Object[] { nodeName, controlPort, socksPort, orPort,
- dirPort });
+ dirPort, serverIpAddress });
// check if there is already a node with this name
if (this.nodes.containsKey(nodeName)) {
@@ -544,16 +591,49 @@
// create router node; parameter checking is done in constructor
RouterNode router = new RouterNodeImpl(this, nodeName, controlPort,
- socksPort, orPort, dirPort);
+ socksPort, orPort, dirPort, serverIpAddress);
// add new router node to nodes collection
- this.nodes.put(router.getNodeName(), router);
+ this.nodes.put(nodeName, router);
// log exiting and return router node
this.logger.exiting(this.getClass().getName(), "createRouter", router);
return router;
}
+ public RouterNode createRouter(String nodeName, int controlPort,
+ int socksPort, int orPort, int dirPort) {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "createRouter",
+ new Object[] { nodeName, controlPort, socksPort, orPort,
+ dirPort });
+
+ // invoke overloaded method
+ DirectoryNode dir = this.createDirectory(nodeName, controlPort,
+ socksPort, orPort, dirPort, "127.0.0.1");
+
+ // log exiting and return directory node
+ this.logger.exiting(this.getClass().getName(), "createRouter", dir);
+ return dir;
+ }
+
+ public RouterNode createRouter(String nodeName, String serverIpAddress) {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "createRouter",
+ new Object[] { nodeName, serverIpAddress });
+
+ // invoke overloaded method
+ RouterNode dir = this.createRouter(nodeName, this.portCounter++,
+ this.portCounter++, this.portCounter++, this.portCounter++,
+ serverIpAddress);
+
+ // log exiting and return directory node
+ this.logger.exiting(this.getClass().getName(), "createRouter", dir);
+ return dir;
+ }
+
public RouterNode createRouter(String nodeName) {
// log entering
@@ -561,8 +641,9 @@
nodeName);
// invoke overloaded method
- RouterNode router = this.createRouter(nodeName, portCounter++,
- portCounter++, portCounter++, portCounter++);
+ RouterNode router = this.createRouter(nodeName, this.portCounter++,
+ this.portCounter++, this.portCounter++, this.portCounter++,
+ "127.0.0.1");
// log exiting and return router node
this.logger.exiting(this.getClass().getName(), "createRouter", router);
@@ -593,7 +674,7 @@
// invoke overloaded method
ServerApplication server = this.createServer(serverApplicationName,
- portCounter++);
+ this.portCounter++);
// log exiting and return server
this.logger.exiting(this.getClass().getName(), "createServer", server);
@@ -625,8 +706,28 @@
return this.nodes.get(nodeName);
}
+ public RouterNode getRouterNode(String nodeName) {
+ ProxyNode node = this.nodes.get(nodeName);
+ return (node instanceof RouterNode ? (RouterNode) node : null);
+ }
+
+ public DirectoryNode getDirectoryNode(String nodeName) {
+ ProxyNode node = this.nodes.get(nodeName);
+ return (node instanceof DirectoryNode ? (DirectoryNode) node : null);
+ }
+
+ public Map<String, DirectoryNode> getAllDirectoryNodes() {
+ Map<String, DirectoryNode> result = new HashMap<String, DirectoryNode>();
+ for (String nodeName : this.nodes.keySet()) {
+ if (this.nodes.get(nodeName) instanceof DirectoryNode) {
+ result.put(nodeName, (DirectoryNode) this.nodes.get(nodeName));
+ }
+ }
+ return result;
+ }
+
public boolean hupUntilUp(int tries, long hupInterval)
- throws TorProcessException {
+ throws TorProcessException, RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "hupUntilUp",
@@ -705,7 +806,7 @@
return false;
}
- public void shutdownNodes() throws TorProcessException {
+ public void shutdownNodes() throws TorProcessException, RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "shutdownNodes");
@@ -840,7 +941,8 @@
+ this.nodes.size();
}
- public void writeConfigurations() throws TorProcessException {
+ public void writeConfigurations() throws TorProcessException,
+ RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "writeConfigurations");
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -275,8 +275,9 @@
replaced = true;
}
}
-
- // if no such configuration key was found, append the configuration string
+
+ // if no such configuration key was found, append the configuration
+ // string
if (!replaced) {
this.configuration.add(configurationString);
}
@@ -863,4 +864,8 @@
public int getControlPort() {
return this.controlPort;
}
+
+ public List<String> getConfiguration() {
+ return new ArrayList<String>(this.configuration);
+ }
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -7,9 +7,11 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.rmi.RemoteException;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
+import java.util.regex.Pattern;
import de.uniba.wiai.lspi.puppetor.NodeState;
import de.uniba.wiai.lspi.puppetor.RouterNode;
@@ -30,6 +32,12 @@
protected int dirPort;
/**
+ * The IP v4 address on which the node will listen in dotted decimal
+ * notation.
+ */
+ protected String serverIpAddress;
+
+ /**
* Temporary config file that is used to determine the fingerprint of this
* node.
*/
@@ -47,10 +55,11 @@
protected String fingerprintBase32;
/**
- * The IP address of local nodes (typically <code>localhost</code> or
- * <code>127.0.0.1</code>).
+ * The pattern for valid IP v4 addresses in dotted decimal notation.
*/
- protected final String localIpAddress = "127.0.0.1";
+ private static final Pattern validIpAddressPattern = Pattern
+ .compile("([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
+ + "(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){1,3}");
/**
* Port on which the Tor node will be listening for onion requests by other
@@ -83,12 +92,16 @@
* Port on which the Tor node will be listening for directory
* requests from other Tor nodes. May not be negative or greater
* than 65535.
+ * @param serverIpAddress
+ * The IP address on which the node will listen. Must be a valid
+ * IP v4 address in dotted decimal notation. May not be
+ * <code>null</code>.
* @throws IllegalArgumentException
* If at least one of the parameters is <code>null</code> or
* has an invalid value.
*/
RouterNodeImpl(NetworkImpl network, String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress) {
// create superclass instance; parameter checking is done in super
// constructor
@@ -97,10 +110,12 @@
// log entering
this.logger.entering(this.getClass().getName(), "RouterNodeImpl",
new Object[] { network, nodeName, controlPort, socksPort,
- orPort, dirPort });
+ orPort, dirPort, serverIpAddress });
// check parameters
- if (orPort < 0 || orPort > 65535 || dirPort < 0 || dirPort > 65535) {
+ if (orPort < 0 || orPort > 65535 || dirPort < 0 || dirPort > 65535
+ || serverIpAddress == null
+ || !validIpAddressPattern.matcher(serverIpAddress).matches()) {
IllegalArgumentException e = new IllegalArgumentException();
this.logger
.throwing(this.getClass().getName(), "RouterNodeImpl", e);
@@ -110,6 +125,7 @@
// remember parameters
this.orPort = orPort;
this.dirPort = dirPort;
+ this.serverIpAddress = serverIpAddress;
// add further configuration to make this node a router node
this.configuration.add("ORPort " + orPort);
@@ -120,14 +136,14 @@
this.configuration.add("DirPort " + dirPort);
// the address of this node should be localhost and not guessed by Tor
- this.configuration.add("Address " + localIpAddress);
+ this.configuration.add("Address " + serverIpAddress);
// the OR port may only be contacted locally
- this.configuration.add("ORListenAddress " + localIpAddress);
+ this.configuration.add("ORListenAddress " + serverIpAddress);
// offer directory only locally (either by being an authority, or by
// mirroring it)
- this.configuration.add("DirListenAddress " + localIpAddress);
+ this.configuration.add("DirListenAddress " + serverIpAddress);
// allow exit to private network and everything else (node will only
// be used by other nodes in the private network, so no worry)
@@ -165,9 +181,34 @@
// log exiting
this.logger.exiting(this.getClass().getName(), "getFingerprintBase32",
this.fingerprintBase32);
- return fingerprintBase32;
+ return this.fingerprintBase32;
}
+ public String getFingerprint() throws RemoteException {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "getFingerprint");
+
+ // check state
+ if (this.nodeState != NodeState.RUNNING
+ && this.nodeState != NodeState.SHUT_DOWN) {
+ String reason = "Node is neither in state NodeState.RUNNING "
+ + "nor in NodeState.SHUT_DOWN, but in state "
+ + this.nodeState + "!";
+ IllegalStateException e = new IllegalStateException(reason);
+ this.logger
+ .throwing(this.getClass().getName(), "getFingerprint", e);
+ throw e;
+ }
+ String result = this.fingerprint.substring(this.fingerprint
+ .indexOf(" ") + 1);
+
+ // log exiting
+ this.logger
+ .exiting(this.getClass().getName(), "getFingerprint", result);
+ return result;
+ }
+
public synchronized String determineFingerprint()
throws TorProcessException {
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java 2007-09-19 16:55:27 UTC (rev 11524)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java 2007-09-19 20:30:32 UTC (rev 11525)
@@ -200,8 +200,8 @@
}
/**
- * Event manager to which all events concerning this server application
- * are notified.
+ * Event manager to which all events concerning this server application are
+ * notified.
*/
private EventManagerImpl eventManager;