[or-cvs] r11593: made some more interfaces remotely accessible, added test cl (in puppetor/trunk: lib src/de/uniba/wiai/lspi/puppetor src/de/uniba/wiai/lspi/puppetor/diststorage src/de/uniba/wiai/lspi/puppetor/groovy src/de/uniba/wiai/lspi/puppetor/impl src/de/uniba/wiai/lspi/puppetor/rmi)
kloesing at seul.org
kloesing at seul.org
Sun Sep 23 15:48:14 UTC 2007
Author: kloesing
Date: 2007-09-23 11:48:14 -0400 (Sun, 23 Sep 2007)
New Revision: 11593
Added:
puppetor/trunk/lib/groovy-all-1.0.jar
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MetaNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/MetaNetworkImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithDir.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java
Modified:
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.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/diststorage/DistributedStorage.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.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
Log:
made some more interfaces remotely accessible, added test classes for RMI access, added MetaNetwork class to connect multiple networks, added Groovy shell for interactive usage, and added some utility methods
Added: puppetor/trunk/lib/groovy-all-1.0.jar
===================================================================
(Binary files differ)
Property changes on: puppetor/trunk/lib/groovy-all-1.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java 2007-09-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
import java.util.List;
/**
@@ -12,7 +14,7 @@
* @author kloesing
*/
-public interface EventManager {
+public interface EventManager extends Remote {
/**
* Registers the given <code>listener</code> as event listener for events
@@ -40,9 +42,11 @@
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
* parameters.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract List<Event> addEventListener(EventSource source,
- EventListener listener);
+ EventListener listener) throws RemoteException;
/**
* Registers the given <code>listener</code> as event listener for future
@@ -58,8 +62,11 @@
* <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for the parameter.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void addEventListener(EventListener listener);
+ public abstract void addEventListener(EventListener listener)
+ throws RemoteException;
/**
* Returns the list of all previously observed events from the given
@@ -72,8 +79,11 @@
* Thrown if <code>null</code> is passed as parameter.
* @return List of all previously observed events from the given
* <code>source</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract List<Event> getEventHistory(EventSource source);
+ public abstract List<Event> getEventHistory(EventSource source)
+ throws RemoteException;
/**
* Returns whether the given <code>event</code> has been observed from the
@@ -90,8 +100,11 @@
* parameters.
* @return <code>true</code> if the event has been observed from the
* source before, <code>false</code> otherwise.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract boolean hasEventOccured(EventSource source, EventType event);
+ public abstract boolean hasEventOccured(EventSource source, EventType event)
+ throws RemoteException;
/**
* Removes the given <code>listener</code> as event listener from all
@@ -108,8 +121,11 @@
* listeners. May not be <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed as parameter.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void removeEventListener(EventListener listener);
+ public abstract void removeEventListener(EventListener listener)
+ throws RemoteException;
/**
* Checks if the given <code>event</code> has been observed from the given
@@ -127,8 +143,11 @@
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
* parameters.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void waitForAnyOccurence(EventSource source, EventType event);
+ public abstract void waitForAnyOccurence(EventSource source, EventType event)
+ throws RemoteException;
/**
* Checks if the given <code>event</code> has been observed from the given
@@ -153,9 +172,12 @@
* @throws IllegalArgumentException
* Thrown if an invalid value is passed for either of the
* parameters.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract boolean waitForAnyOccurence(EventSource source,
- EventType event, long maximumTimeToWaitInMillis);
+ EventType event, long maximumTimeToWaitInMillis)
+ throws RemoteException;
/**
* Blocks the invoking thread until the next <code>event</code> is fired
@@ -174,9 +196,11 @@
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
* parameters.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract void waitForNextOccurence(EventSource source,
- EventType event);
+ EventType event) throws RemoteException;
/**
* Blocks the invoking thread until the next <code>event</code> is fired
@@ -201,9 +225,12 @@
* @throws IllegalArgumentException
* Thrown if an invalid value is passed for either of the
* parameters.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract boolean waitForNextOccurence(EventSource source,
- EventType event, long maximumTimeToWaitInMillis);
+ EventType event, long maximumTimeToWaitInMillis)
+ throws RemoteException;
/**
* Registers a new event type by passing a pattern string that can be
@@ -217,7 +244,9 @@
* @param eventType
* The event type that will be fired when a log statement was
* parsed that includes the given pattern.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract void registerEventTypePattern(String patternString,
- EventType eventType);
+ EventType eventType) throws RemoteException;
}
Added: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MetaNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MetaNetwork.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MetaNetwork.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -0,0 +1,22 @@
+/*
+ *
+ * WARNING! This class is untested, yet! Don't rely on it!
+ *
+ */
+
+/**
+ * @author pgeyer, jjungkunst, sschilling
+ */
+package de.uniba.wiai.lspi.puppetor;
+
+import java.net.MalformedURLException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+
+public interface MetaNetwork {
+
+ public abstract Network connectNetwork(String remoteHost, String bindingName)
+ throws MalformedURLException, RemoteException, NotBoundException;
+
+ public abstract void mergeNetworks(Network first, Network second);
+}
\ No newline at end of file
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java 2007-09-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -1,8 +1,11 @@
package de.uniba.wiai.lspi.puppetor;
import java.io.File;
+import java.rmi.Remote;
import java.rmi.RemoteException;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* A Network instance constitutes the central object of any test run and is
@@ -13,7 +16,7 @@
*
* @author kloesing
*/
-public interface Network extends EventSource {
+public interface Network extends EventSource, Remote {
/**
* <p>
@@ -48,8 +51,8 @@
* <p>
* A second, non-trivial task is to authorize routers and directory nodes.
* Therefore, an authoritative directory needs to know all fingerprints of
- * authorized nodes. They are stored in the \texttt{approved-routers} file
- * in the working directory of the directory node.
+ * authorized nodes. They are stored in the <code>approved-routers</code>
+ * file in the working directory of the directory node.
* </p>
*
* <p>
@@ -99,10 +102,12 @@
* @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 ClientApplication createClient(
String clientApplicationName, String targetAddress, int targetPort,
- int socksPort);
+ int socksPort) throws RemoteException;
/**
* Creates a new directory node with automatically assigned ports and adds
@@ -122,8 +127,11 @@
* <code>NetworkState.CONFIGURING_NODES</code>.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract DirectoryNode createDirectory(String nodeName);
+ public abstract DirectoryNode createDirectory(String nodeName)
+ throws RemoteException;
/**
* Creates a new directory node with automatically assigned ports that will
@@ -148,9 +156,11 @@
* <code>NetworkState.CONFIGURING_NODES</code>.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract DirectoryNode createDirectory(String nodeName,
- String serverIpAddress);
+ String serverIpAddress) throws RemoteException;
/**
* Creates a new directory node and adds it to the network, but does not yet
@@ -186,9 +196,12 @@
* @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 DirectoryNode createDirectory(String nodeName,
- int controlPort, int socksPort, int orPort, int dirPort);
+ int controlPort, int socksPort, int orPort, int dirPort)
+ throws RemoteException;
/**
* Creates a new directory node that will listen on the given IP address and
@@ -228,10 +241,12 @@
* @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 DirectoryNode createDirectory(String nodeName,
int controlPort, int socksPort, int orPort, int dirPort,
- String serverIpAddress);
+ String serverIpAddress) throws RemoteException;
/**
* Creates a new <code>ProxyNode</code> with automatically assigned ports
@@ -246,8 +261,11 @@
* @return Reference to the created proxy node.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract ProxyNode createProxy(String nodeName);
+ public abstract ProxyNode createProxy(String nodeName)
+ throws RemoteException;
/**
* Creates a new <code>ProxyNode</code> and adds it to the network, but
@@ -270,9 +288,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 ProxyNode createProxy(String nodeName, int controlPort,
- int socksPort);
+ int socksPort) throws RemoteException;
/**
* Creates a new <code>RouterNode</code> with automatically assigned ports
@@ -288,8 +308,11 @@
* @return Reference to the created router node.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract RouterNode createRouter(String nodeName);
+ public abstract RouterNode createRouter(String nodeName)
+ throws RemoteException;
/**
* Creates a new <code>RouterNode</code> and adds it to the network, but
@@ -322,9 +345,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 RouterNode createRouter(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort);
+ int socksPort, int orPort, int dirPort) throws RemoteException;
/**
* Creates a new <code>RouterNode</code> with automatically assigned ports
@@ -345,9 +370,11 @@
* @return Reference to the created router node.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract RouterNode createRouter(String nodeName,
- String serverIpAddress);
+ String serverIpAddress) throws RemoteException;
/**
* Creates a new <code>RouterNode</code> that will listen on the given IP
@@ -384,9 +411,12 @@
* @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 RouterNode createRouter(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort, String serverIpAddress);
+ int socksPort, int orPort, int dirPort, String serverIpAddress)
+ throws RemoteException;
/**
* Creates a new <code>ServerApplication</code> with automatically
@@ -400,8 +430,11 @@
* @throws IllegalArgumentException
* Thrown if an invalid value is given as server application
* name.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract ServerApplication createServer(String serverApplicationName);
+ public abstract ServerApplication createServer(String serverApplicationName)
+ throws RemoteException;
/**
* Creates a new <code>ServerApplication</code>, but does not start
@@ -418,41 +451,80 @@
* @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 ServerApplication createServer(
- String serverApplicationName, int serverPort);
+ String serverApplicationName, int serverPort)
+ throws RemoteException;
/**
* Returns a reference on the (single) event manager for this network.
*
* @return Reference on the (single) event manager for this network.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract EventManager getEventManager();
+ public abstract EventManager getEventManager() throws RemoteException;
/**
* Returns the current network state.
*
* @return Current network state.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract NetworkState getNetworkState();
+ public abstract NetworkState getNetworkState() throws RemoteException;
/**
* 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.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract Map<String, DirectoryNode> getAllDirectoryNodes();
+ public abstract Map<String, DirectoryNode> getAllDirectoryNodes()
+ throws RemoteException;
/**
+ * Returns (a copy of) the map containing the names of all router nodes
+ * (only those that are not acting as directory nodes at the same time) as
+ * keys and the corresponding router nodes as values.
+ *
+ * TODO is this important: returns the stubs for remote access.
+ *
+ * @return Map containing all router nodes.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public Map<String, RouterNode> getAllRouterNodes() throws RemoteException;
+
+ /**
+ * Returns (a copy of) the map containing the names of all proxy nodes (only
+ * those that are not acting as router or directory nodes at the same time)
+ * as keys and the corresponding proxy nodes as values.
+ *
+ * TODO is this important: returns the stubs for remote access.
+ *
+ * @return Map containing all proxy nodes.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public Map<String, ProxyNode> getAllProxyNodes() throws RemoteException;
+
+ /**
* 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>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract ProxyNode getProxyNode(String nodeName);
+ public abstract ProxyNode getProxyNode(String nodeName)
+ throws RemoteException;
/**
* Returns the <code>RouterNode</code> with name <code>nodeName</code>
@@ -461,8 +533,11 @@
* @param nodeName
* The node name to look up.
* @return The <code>RouterNode</code> with name <code>nodeName</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract RouterNode getRouterNode(String nodeName);
+ public abstract RouterNode getRouterNode(String nodeName)
+ throws RemoteException;
/**
* Returns the <code>DirectoryNode</code> with name <code>nodeName</code>
@@ -471,8 +546,11 @@
* @param nodeName
* The node name to look up.
* @return The <code>DirectoryNode</code> with name <code>nodeName</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract DirectoryNode getDirectoryNode(String nodeName);
+ public abstract DirectoryNode getDirectoryNode(String nodeName)
+ throws RemoteException;
/**
* <p>
@@ -564,9 +642,11 @@
* <code>NetworkState.CONFIGURATIONS_WRITTEN</code>.
* @throws TorProcessException
* Thrown if an I/O problem occurs while starting the nodes.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
public abstract boolean startNodes(long maximumTimeToWaitInMillis)
- throws TorProcessException;
+ throws TorProcessException, RemoteException;
/**
* Writes the configurations for all nodes in the network to disk, including
@@ -593,6 +673,54 @@
* test-env/networkName/.
*
* @return Working directory of this network.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract File getWorkingDirectory();
+ public abstract File getWorkingDirectory() throws RemoteException;
+
+ /**
+ * Returns whether all nodes in this network are up, or not.
+ *
+ * @return <code>true</code> if all nodes are up, <code>false</code> if
+ * at least one node is not up.
+ */
+ public abstract boolean allNodesUp() throws RemoteException;
+
+ /**
+ * Appends the given directory server strings to the configurations of all
+ * nodes in this network. This enables the nodes to use the directories of a
+ * remote network.
+ *
+ * TODO when is the TorProcessException thrown?
+ *
+ * TODO in which state is this method permitted?
+ *
+ * @param dirServerStrings
+ * A list containing the directory server strings of the nodes
+ * which should be added to the network.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public abstract void addDirectoryStrings(List<String> dirServerStrings)
+ throws RemoteException, TorProcessException;
+
+ /**
+ * Appends the fingerprints of the given routers to the approved routers
+ * file of all directory nodes of this network, thereby approving these
+ * router nodes.
+ *
+ * TODO in which state is this method permitted?
+ *
+ * @param approvedRoutersStrings
+ * A set containing the fingerprints of the router nodes which
+ * should be approved by the Network.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ * @throws TorProcessException
+ * Thrown if an <code>approved-routers</code> file cannot be
+ * written to disk.
+ */
+ public abstract void addApprovedRouters(Set<String> approvedRoutersStrings)
+ throws RemoteException, TorProcessException;
+
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java 2007-09-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor;
+import java.rmi.RemoteException;
+
import de.uniba.wiai.lspi.puppetor.impl.NetworkImpl;
/**
@@ -25,8 +27,11 @@
* @param networkName
* Name of this network configuration.
* @return A new network instance.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static Network createNetwork(String networkName) {
+ public static Network createNetwork(String networkName)
+ throws RemoteException {
return new NetworkImpl(networkName);
}
@@ -42,8 +47,11 @@
* nodes created by this <code>Network</code>; must be a value
* between 1024 and 65535.
* @return A new network instance.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public static Network createNetwork(String networkName, int startPort) {
+ public static Network createNetwork(String networkName, int startPort)
+ throws RemoteException {
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-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -19,24 +19,24 @@
* in private networks in the same way as router nodes will fail! Tor has two
* different strategies for downloading network status documents: Directory
* caches (router nodes) download these documents after every HUP signal and
- * then accept all contained router entries. But directory clients (proxy
- * nodes) only download network status documents, if the most recent download
- * lies at least 30 minutes in the past, and then accept only those of the
- * contained router entries that are at least 10 minutes old. However, when
- * starting all nodes of a private network at once, directories cannot contain
- * 10 minutes old router descriptors. You have at least the following options
- * to cope with this problem:
+ * then accept all contained router entries. But directory clients (proxy nodes)
+ * only download network status documents, if the most recent download lies at
+ * least 30 minutes in the past, and then accept only those of the contained
+ * router entries that are at least 10 minutes old. However, when starting all
+ * nodes of a private network at once, directories cannot contain 10 minutes old
+ * router descriptors. You have at least the following options to cope with this
+ * problem:
* </p>
*
* <ul>
* <li>Use router nodes instead of proxy nodes,</li>
* <li>start proxy nodes with a delay of at least 10 minutes to be sure that
- * the router descriptors stored at directory authorities will be accepted
- * by directory clients, or</li>
+ * the router descriptors stored at directory authorities will be accepted by
+ * directory clients, or</li>
* <li>change the constants ESTIMATED_PROPAGATION_TIME and
* NETWORKSTATUS_CLIENT_DL_INTERVAL in Tor to values smaller than your overall
* HUP time for starting the network.</li>
- * </ul>
+ * </ul>
*
* @author kloesing
*/
@@ -115,6 +115,26 @@
throws RemoteException;
/**
+ * Adds the given configuration strings, each consisting of "<configuration
+ * key> <configuration value>", to the configuration of this node.
+ *
+ * @param configurationStrings
+ * A list of the configuration strings to be added.
+ * @throws IllegalArgumentException
+ * Thrown if the given list is <code>null</code>, or any of
+ * the contained strings is either <code>null</code>, a
+ * zero-length string, or does not consist of configuration key
+ * and value.
+ * @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 addConfigurations(List<String> configurationStrings)
+ throws RemoteException;
+
+ /**
* Replaces the first configuration string, consisting of "<configuration
* key> <configuration value>", that contains the same configuration key as
* <code>configurationString</code> by this new configuration string; if
@@ -194,8 +214,10 @@
* Thrown if an I/O problem occurs while sending the HUP signal.
* @throws IllegalStateException
* Thrown if node is not in state <code>NodeState.RUNNING</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void hup() throws TorProcessException;
+ public abstract void hup() throws TorProcessException, RemoteException;
/**
* Shuts down the Tor process corresponding to this node immediately. This
@@ -209,8 +231,10 @@
* @throws TorProcessException
* Thrown if an I/O problem occurs while sending the
* <code>SHUTDOWN</code> signal.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public abstract void shutdown() throws TorProcessException;
+ public abstract void shutdown() throws TorProcessException, RemoteException;
/**
* Starts the Tor process for this node and connects to the control port as
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-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/DistributedStorage.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -120,11 +120,15 @@
// remember the args
this.hsdNode = hsdNode;
- // listen for events coming from my HSDir
- manager.addEventListener(hsdNode, this);
+ try {
+ // listen for events coming from my HSDir
+ manager.addEventListener(hsdNode, this);
- // listen for starting/stopping nodes
- manager.addEventListener(this);
+ // listen for starting/stopping nodes
+ manager.addEventListener(this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
@Override
@@ -201,7 +205,11 @@
}
// stop listening for events
- manager.removeEventListener(this);
+ try {
+ manager.removeEventListener(this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
// just in case that there is another event in the queue, don't
// handle it any more
@@ -304,8 +312,12 @@
// listen for events coming from the node and the hidden service
// directory
- manager.addEventListener(node, this);
- manager.addEventListener(hsdNode, this);
+ try {
+ manager.addEventListener(node, this);
+ manager.addEventListener(hsdNode, this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
@@ -334,7 +346,11 @@
}
// unregister event listener
- manager.removeEventListener(this);
+ try {
+ manager.removeEventListener(this);
+ } catch (RemoteException e1) {
+ e1.printStackTrace();
+ }
// print out measurement result
long duration = System.currentTimeMillis() - startingTime;
@@ -429,7 +445,11 @@
// register for events from the node that should observe the offline
// status
- manager.addEventListener(node, this);
+ try {
+ manager.addEventListener(node, this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
@Override
@@ -457,7 +477,11 @@
}
// unregister event listener
- manager.removeEventListener(this);
+ try {
+ manager.removeEventListener(this);
+ } catch (RemoteException e1) {
+ e1.printStackTrace();
+ }
// print out measurement result
long duration = System.currentTimeMillis() - startingTime;
@@ -531,7 +555,11 @@
* Creates a new observer that starts listening for events.
*/
private DescriptorObserverStarter() {
- manager.addEventListener(this);
+ try {
+ manager.addEventListener(this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
public void handleEvent(Event event) {
@@ -703,7 +731,11 @@
this.descid = descid;
// register for events from the hidden service directory
- manager.addEventListener(responsibleHSDir, this);
+ try {
+ manager.addEventListener(responsibleHSDir, this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
@Override
@@ -743,7 +775,11 @@
}
// unregister event listener
- manager.removeEventListener(this);
+ try {
+ manager.removeEventListener(this);
+ } catch (RemoteException e1) {
+ e1.printStackTrace();
+ }
// print out measurement result
long duration = System.currentTimeMillis() - startingTime;
@@ -812,7 +848,11 @@
this.providingNode = providingNode;
// listen for events coming from the providing node
- manager.addEventListener(providingNode, this);
+ try {
+ manager.addEventListener(providingNode, this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
/**
@@ -965,8 +1005,12 @@
this.useAsProxy = useAsProxy;
// register for events from the two involved nodes
- manager.addEventListener(providingNode, this);
- manager.addEventListener(useAsProxy, this);
+ try {
+ manager.addEventListener(providingNode, this);
+ manager.addEventListener(useAsProxy, this);
+ } catch (RemoteException e1) {
+ e1.printStackTrace();
+ }
// determine socks port of proxy
int socksPort = 0;
@@ -978,9 +1022,17 @@
// create client application and register for events originating
// from it
- this.clientApp = network.createClient("client", onionAddress, 80,
- socksPort);
- manager.addEventListener(this.clientApp, this);
+ try {
+ this.clientApp = network.createClient("client", onionAddress,
+ 80, socksPort);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ try {
+ manager.addEventListener(this.clientApp, this);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
@Override
@@ -1013,7 +1065,11 @@
}
// unregister event listener
- manager.removeEventListener(this);
+ try {
+ manager.removeEventListener(this);
+ } catch (RemoteException e1) {
+ e1.printStackTrace();
+ }
// print out measurement result
try {
Added: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -0,0 +1,206 @@
+/*
+ *
+ * WARNING! This class is untested, yet! Don't rely on it!
+ *
+ */
+
+/**
+ * @author pgeyer, jjungkunst, sschilling
+ */
+package de.uniba.wiai.lspi.puppetor.groovy;
+
+import groovy.lang.GroovyShell;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import de.uniba.wiai.lspi.puppetor.MetaNetwork;
+import de.uniba.wiai.lspi.puppetor.impl.MetaNetworkImpl;
+
+ at SuppressWarnings("serial")
+public class RmiPuppetzShell extends JFrame {
+
+ private GroovyShell shell; // @jve:decl-index=0:
+
+ private JPanel jContentPane = null;
+
+ private JTextArea jTextArea = null;
+
+ private JButton jButton = null;
+
+ private MetaNetwork metaNetwork = null; // @jve:decl-index=0:
+
+ private JPanel jPanel = null;
+
+ private JButton jButton1 = null;
+
+ private JTextArea jTextArea1 = null;
+
+ private JSplitPane jSplitPane = null;
+
+ /**
+ * This method initializes this
+ */
+ private void initialize() {
+ this.setSize(new Dimension(531, 256));
+ this.setPreferredSize(new Dimension(100, 150));
+ this.setContentPane(getJContentPane());
+ this.setTitle("Rmi-Puppetz Shell");
+ this.setVisible(true);
+ this.setDefaultCloseOperation(EXIT_ON_CLOSE);
+ shell = new GroovyShell();
+ metaNetwork = new MetaNetworkImpl();
+ try {
+ shell.setVariable("network", metaNetwork);
+ /* A problem occurred on this link */
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(new BorderLayout());
+ jContentPane.add(getJPanel(), BorderLayout.SOUTH);
+ jContentPane.add(getJSplitPane(), BorderLayout.CENTER);
+ }
+ return jContentPane;
+ }
+
+ /**
+ * This method initializes jTextArea
+ *
+ * @return javax.swing.JTextArea
+ */
+ private JTextArea getJTextArea() {
+ if (jTextArea == null) {
+ jTextArea = new JTextArea();
+ jTextArea.setColumns(1);
+ jTextArea.setPreferredSize(new Dimension(350, 150));
+ jTextArea.setBackground(Color.white);
+ jTextArea.setRows(1);
+ }
+ return jTextArea;
+ }
+
+ /**
+ * This method initializes jButton
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton() {
+ if (jButton == null) {
+ jButton = new JButton();
+ jButton.setText("OK");
+ jButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mouseReleased(java.awt.event.MouseEvent e) {
+ try {
+ shell.evaluate(jTextArea.getText());
+ } catch (Exception e1) {
+ jTextArea1.append("Unkorrekte eingabe" + "\n");
+ e1.printStackTrace();
+ }
+
+ }
+ });
+ }
+ return jButton;
+ }
+
+ public void lala(String string) {
+ System.out.println(string);
+ }
+
+ /**
+ * This method initializes jPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanel() {
+ if (jPanel == null) {
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
+ jPanel = new JPanel();
+ jPanel.setLayout(new GridBagLayout());
+ jPanel.setPreferredSize(new Dimension(100, 30));
+ GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+ gridBagConstraints1.gridx = 0;
+ gridBagConstraints1.gridy = 0;
+ jPanel.add(getJButton1(), gridBagConstraints);
+ jPanel.add(getJButton(), gridBagConstraints1);
+
+ }
+ return jPanel;
+ }
+
+ /**
+ * This method initializes jButton1
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton1() {
+ if (jButton1 == null) {
+ jButton1 = new JButton();
+ jButton1.setText("Startup");
+ jButton1.setFont(new Font("Dialog", Font.BOLD, 12));
+ jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mouseReleased(java.awt.event.MouseEvent e) {
+ shell.evaluate("network.startupNetwork();");
+ }
+ });
+ }
+ return jButton1;
+ }
+
+ /**
+ * This method initializes jTextArea1
+ *
+ * @return javax.swing.JTextArea
+ */
+ private JTextArea getJTextArea1() {
+ if (jTextArea1 == null) {
+ jTextArea1 = new JTextArea();
+ jTextArea1.setEditable(false);
+ jTextArea1.setBackground(Color.lightGray);
+ }
+ return jTextArea1;
+ }
+
+ /**
+ * This method initializes jSplitPane
+ *
+ * @return javax.swing.JSplitPane
+ */
+ private JSplitPane getJSplitPane() {
+ if (jSplitPane == null) {
+ jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ getJTextArea(), getJTextArea1());
+ jSplitPane.setContinuousLayout(true);
+ }
+ return jSplitPane;
+ }
+
+ public static void main(String args[]) {
+ new RmiPuppetzShell();
+ }
+
+ public RmiPuppetzShell() {
+ initialize();
+ }
+
+} // @jve:decl-index=0:visual-constraint="10,10"
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-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -56,9 +56,12 @@
* @throws IllegalArgumentException
* If at least one of the parameters is <code>null</code> or
* has an invalid value.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
DirectoryNodeImpl(NetworkImpl network, String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort, String serverIpAddress) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress)
+ throws RemoteException {
// create superclass instance; parameter checking is done in super
// constructor
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java 2007-09-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -1,5 +1,7 @@
package de.uniba.wiai.lspi.puppetor.impl;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -26,7 +28,8 @@
/**
* Implementation of <code>EventManager</code>.
*/
-public class EventManagerImpl implements EventManager {
+public class EventManagerImpl extends UnicastRemoteObject implements
+ EventManager {
/**
* Registered event handlers for specific sources.
@@ -60,7 +63,7 @@
* Thrown if the given <code>networkName</code> is either
* <code>null</code> or a zero-length string.
*/
- EventManagerImpl(String networkName) {
+ EventManagerImpl(String networkName) throws RemoteException {
// check if networkName can be used as logger name
if (networkName == null || networkName.length() == 0) {
Added: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/MetaNetworkImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/MetaNetworkImpl.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/MetaNetworkImpl.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -0,0 +1,144 @@
+/*
+ *
+ * WARNING! This class is untested, yet! Don't rely on it!
+ *
+ */
+
+package de.uniba.wiai.lspi.puppetor.impl;
+
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import de.uniba.wiai.lspi.puppetor.DirectoryNode;
+import de.uniba.wiai.lspi.puppetor.MetaNetwork;
+import de.uniba.wiai.lspi.puppetor.Network;
+import de.uniba.wiai.lspi.puppetor.RouterNode;
+import de.uniba.wiai.lspi.puppetor.TorProcessException;
+
+/**
+ * @author pgeyer, jjungkunst, sschilling
+ */
+public class MetaNetworkImpl implements MetaNetwork {
+
+ private HashMap<String, Network> allNetworks = new HashMap<String, Network>();
+
+ public Network connectNetwork(String remoteHost, String bindingName)
+ throws MalformedURLException, RemoteException, NotBoundException {
+
+ Network network = (Network) Naming.lookup("rmi://" + remoteHost + "/"
+ + bindingName);
+ allNetworks.put(bindingName, network);
+ return network;
+ }
+
+ public void mergeNetworks(Network first, Network second) {
+ try {
+ HashMap<String, DirectoryNode> temp = (HashMap<String, DirectoryNode>) first
+ .getAllDirectoryNodes();
+ if (first.getAllDirectoryNodes().size() > 0) {
+ if (second.getAllDirectoryNodes().size() > 0) {
+ configureAsWithDir(first, second);
+ } else {
+ configureAsWithoutDir(first, second);
+ }
+ } else {
+ configureAsWithoutDir(second, first);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void configureAsWithoutDir(Network first, Network second) {
+ try {
+
+ exchangeDirectories(first, second);
+ startRouters(second);
+ hupRouters(second);
+ exchangeFingerprints(second, first);
+ hupDirectories(first);
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void configureAsWithDir(Network first, Network second) {
+ try {
+
+ exchangeDirectories(first, second);
+ exchangeDirectories(second, first);
+ exchangeFingerprints(first, second);
+ exchangeFingerprints(second, first);
+
+ hupDirectories(first);
+ hupDirectories(second);
+ hupRouters(first);
+ hupRouters(second);
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void exchangeDirectories(Network first, Network second)
+ throws RemoteException, TorProcessException {
+ HashMap<String, DirectoryNode> directories = (HashMap<String, DirectoryNode>) first
+ .getAllDirectoryNodes();
+ List<String> dirServerStrings = new ArrayList<String>();
+ for (DirectoryNode directory : directories.values()) {
+ dirServerStrings.add(directory.determineDirServerString());
+ }
+ second.addDirectoryStrings(dirServerStrings);
+ }
+
+ private void exchangeFingerprints(Network first, Network second)
+ throws RemoteException, TorProcessException {
+ HashMap<String, RouterNode> routers = (HashMap<String, RouterNode>) first
+ .getAllRouterNodes();
+ Set<String> approvedRoutersStrings = new TreeSet<String>();
+ for (RouterNode router : routers.values()) {
+ approvedRoutersStrings.add(router.getNodeName() + " "
+ + router.getFingerprint());
+ }
+ second.addApprovedRouters(approvedRoutersStrings);
+ }
+
+ private void startRouters(Network network) throws RemoteException,
+ TorProcessException {
+ HashMap<String, RouterNode> routers = (HashMap<String, RouterNode>) network
+ .getAllRouterNodes();
+ for (RouterNode router : routers.values()) {
+ router.startNode(5000);
+ }
+ }
+
+ private void hupDirectories(Network network) throws RemoteException,
+ TorProcessException {
+ HashMap<String, DirectoryNode> directories = (HashMap<String, DirectoryNode>) network
+ .getAllDirectoryNodes();
+ for (DirectoryNode directory : directories.values()) {
+ directory.hup();
+ }
+ }
+
+ private void hupRouters(Network network) throws RemoteException,
+ TorProcessException {
+ HashMap<String, RouterNode> routers = (HashMap<String, RouterNode>) network
+ .getAllRouterNodes();
+ for (RouterNode router : routers.values()) {
+ router.hup();
+ }
+ }
+}
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-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -2,8 +2,10 @@
import java.io.File;
import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@@ -28,7 +30,7 @@
*
* @author kloesing
*/
-public class NetworkImpl implements Network {
+public class NetworkImpl extends UnicastRemoteObject implements Network {
/**
* Internal thread class that is used to determine fingerprints in parallel.
@@ -235,8 +237,11 @@
* Thrown if the given <code>networkName</code> is either
* <code>null</code> or a zero-length string, or if an illegal
* number is given for <code>startPort</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public NetworkImpl(String networkName, int startPort) {
+ public NetworkImpl(String networkName, int startPort)
+ throws RemoteException {
// initialize using overloaded constructor
this(networkName);
@@ -264,8 +269,10 @@
* @throws IllegalArgumentException
* Thrown if the given <code>networkName</code> is either
* <code>null</code> or a zero-length string.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
- public NetworkImpl(String networkName) {
+ public NetworkImpl(String networkName) throws RemoteException {
// check if networkName can be used as logger name
if (networkName == null || networkName.length() == 0) {
@@ -303,13 +310,7 @@
this.logger.exiting(this.getClass().getName(), "NetworkImpl");
}
- /**
- * Returns whether all nodes in this network are up, or not.
- *
- * @return <code>true</code> if all nodes are up, <code>false</code> if
- * at least one node is not up.
- */
- private boolean allNodesUp() {
+ public boolean allNodesUp() throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "allNodesUp");
@@ -446,7 +447,8 @@
}
public DirectoryNode createDirectory(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort, String serverIpAddress) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress)
+ throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createDirectory",
@@ -483,7 +485,7 @@
}
public DirectoryNode createDirectory(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort) {
+ int socksPort, int orPort, int dirPort) throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createDirectory",
@@ -499,7 +501,8 @@
return dir;
}
- public DirectoryNode createDirectory(String nodeName, String serverIpAddress) {
+ public DirectoryNode createDirectory(String nodeName, String serverIpAddress)
+ throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createDirectory",
@@ -515,7 +518,8 @@
return dir;
}
- public DirectoryNode createDirectory(String nodeName) {
+ public DirectoryNode createDirectory(String nodeName)
+ throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createDirectory",
@@ -532,7 +536,7 @@
}
public synchronized ProxyNode createProxy(String nodeName, int controlPort,
- int socksPort) {
+ int socksPort) throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createProxy",
@@ -558,7 +562,7 @@
return proxy;
}
- public ProxyNode createProxy(String nodeName) {
+ public ProxyNode createProxy(String nodeName) throws RemoteException {
// log entering
this.logger
@@ -574,7 +578,8 @@
}
public RouterNode createRouter(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort, String serverIpAddress) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress)
+ throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createRouter",
@@ -602,7 +607,7 @@
}
public RouterNode createRouter(String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort) {
+ int socksPort, int orPort, int dirPort) throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createRouter",
@@ -618,7 +623,8 @@
return dir;
}
- public RouterNode createRouter(String nodeName, String serverIpAddress) {
+ public RouterNode createRouter(String nodeName, String serverIpAddress)
+ throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createRouter",
@@ -634,7 +640,7 @@
return dir;
}
- public RouterNode createRouter(String nodeName) {
+ public RouterNode createRouter(String nodeName) throws RemoteException {
// log entering
this.logger.entering(this.getClass().getName(), "createRouter",
@@ -716,11 +722,34 @@
return (node instanceof DirectoryNode ? (DirectoryNode) node : null);
}
+ public Map<String, ProxyNode> getAllProxyNodes() {
+ Map<String, ProxyNode> result = new HashMap<String, ProxyNode>();
+ for (String nodeName : this.nodes.keySet()) {
+ ProxyNode node = this.nodes.get(nodeName);
+ if (!(node instanceof RouterNode)) {
+ result.put(nodeName, node);
+ }
+ }
+ return result;
+ }
+
+ public Map<String, RouterNode> getAllRouterNodes() {
+ Map<String, RouterNode> result = new HashMap<String, RouterNode>();
+ for (String nodeName : this.nodes.keySet()) {
+ ProxyNode node = this.nodes.get(nodeName);
+ if (node instanceof RouterNode && !(node instanceof DirectoryNode)) {
+ result.put(nodeName, (RouterNode) node);
+ }
+ }
+ return result;
+ }
+
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));
+ ProxyNode node = this.nodes.get(nodeName);
+ if (node instanceof DirectoryNode) {
+ result.put(nodeName, (DirectoryNode) node);
}
}
return result;
@@ -972,4 +1001,38 @@
public String getName() {
return this.networkName;
}
+
+ public void addApprovedRouters(Set<String> approvedRoutersString)
+ throws RemoteException, TorProcessException {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "addApprovedRouters",
+ approvedRoutersString);
+
+ for (ProxyNode tempNode : nodes.values()) {
+ if (tempNode instanceof DirectoryNode) {
+ DirectoryNode tempDirNode = (DirectoryNode) tempNode;
+ tempDirNode.addApprovedRouters(approvedRoutersString);
+ }
+ }
+
+ // log exiting
+ this.logger.exiting(this.getClass().getName(), "addApprovedRouters");
+ }
+
+ public void addDirectoryStrings(List<String> dirServerStrings)
+ throws RemoteException, TorProcessException {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "addDirectoryStrings",
+ dirServerStrings);
+
+ // add configuration strings to all nodes
+ for (ProxyNode node : this.nodes.values()) {
+ node.addConfigurations(dirServerStrings);
+ }
+
+ // log exiting
+ this.logger.exiting(this.getClass().getName(), "addDirectoryStrings");
+ }
}
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-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -8,6 +8,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -26,7 +28,7 @@
*
* @author kloesing
*/
-public class ProxyNodeImpl implements ProxyNode {
+public class ProxyNodeImpl extends UnicastRemoteObject implements ProxyNode {
/**
* Executable file containing Tor.
@@ -119,9 +121,11 @@
* @throws IllegalArgumentException
* If at least one of the parameters is <code>null</code> or
* has an invalid value.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.s
*/
ProxyNodeImpl(NetworkImpl network, String nodeName, int controlPort,
- int socksPort) {
+ int socksPort) throws RemoteException {
// make sure that nodeName is a valid logger name
if (nodeName == null || nodeName.length() < 1 || nodeName.length() > 19
@@ -235,6 +239,37 @@
this.logger.exiting(this.getClass().getName(), "addConfiguration");
}
+ public void addConfigurations(List<String> configurationStrings) {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(), "addConfigurations",
+ configurationStrings);
+
+ // check state
+ if (this.nodeState != NodeState.CONFIGURING) {
+ IllegalStateException e = new IllegalStateException();
+ this.logger.throwing(this.getClass().getName(),
+ "addConfigurations", e);
+ throw e;
+ }
+
+ // check parameter
+ if (configurationStrings == null) {
+ IllegalArgumentException e = new IllegalArgumentException();
+ this.logger.throwing(this.getClass().getName(),
+ "addConfigurations", e);
+ throw e;
+ }
+
+ // add configuration strings one by one
+ for (String conf : configurationStrings) {
+ this.addConfiguration(conf);
+ }
+
+ // log exiting
+ this.logger.exiting(this.getClass().getName(), "addConfigurations");
+ }
+
public void replaceConfiguration(String configurationString) {
// log entering
@@ -832,25 +867,52 @@
}
// write config file
+ this.writeConfigurationFile(this.configFile, this.configuration);
+
+ // change state
+ this.nodeState = NodeState.CONFIGURATION_WRITTEN;
+
+ // log exiting
+ this.logger.exiting(this.getClass().getName(), "writeConfiguration");
+ }
+
+ /**
+ * Writes the given configuration strings to the given configuration file.
+ *
+ * @param configurationFile
+ * File to write the configuration to.
+ * @param configurationStrings
+ * Configuration strings to be written.
+ * @throws TorProcessException
+ * Thrown if the configuration file cannot be written to disk.
+ */
+ protected void writeConfigurationFile(File configurationFile,
+ List<String> configurationStrings) throws TorProcessException {
+
+ // log entering
+ this.logger.entering(this.getClass().getName(),
+ "writeConfigurationFile", new Object[] { configurationFile,
+ configurationStrings });
+
+ // write config file
try {
- BufferedWriter bw = new BufferedWriter(new FileWriter(configFile));
- for (String c : this.configuration) {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(
+ configurationFile));
+ for (String c : configurationStrings) {
bw.write(c + "\n");
}
bw.close();
} catch (IOException e) {
TorProcessException ex = new TorProcessException(
- "Could not write configuration!", e);
+ "Could not write configuration file!", e);
this.logger.throwing(this.getClass().getName(),
- "writeConfiguration", ex);
+ "writeConfigurationFile", ex);
throw ex;
}
- // change state
- this.nodeState = NodeState.CONFIGURATION_WRITTEN;
-
// log exiting
- this.logger.exiting(this.getClass().getName(), "writeConfiguration");
+ this.logger
+ .exiting(this.getClass().getName(), "writeConfigurationFile");
}
public String getName() {
@@ -868,4 +930,17 @@
public List<String> getConfiguration() {
return new ArrayList<String>(this.configuration);
}
+
+ public void replaceDirectoryServers(Set<String> dirServerString)
+ throws TorProcessException {
+ List<String> tempConfigurationList = new ArrayList<String>();
+ for (String line : this.configuration) {
+ if (!line.startsWith("DirServer")) {
+ tempConfigurationList.add(line);
+ }
+ }
+ tempConfigurationList.addAll(dirServerString);
+ this.configuration = tempConfigurationList;
+ this.writeConfigurationFile(configFile, 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-23 12:37:10 UTC (rev 11592)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -1,15 +1,13 @@
package de.uniba.wiai.lspi.puppetor.impl;
import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
-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.ArrayList;
+import java.util.List;
import java.util.logging.Level;
import java.util.regex.Pattern;
@@ -99,9 +97,12 @@
* @throws IllegalArgumentException
* If at least one of the parameters is <code>null</code> or
* has an invalid value.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
*/
RouterNodeImpl(NetworkImpl network, String nodeName, int controlPort,
- int socksPort, int orPort, int dirPort, String serverIpAddress) {
+ int socksPort, int orPort, int dirPort, String serverIpAddress)
+ throws RemoteException {
// create superclass instance; parameter checking is done in super
// constructor
@@ -229,27 +230,14 @@
// would not accept that this router node has a private IP
// address, but connects to the public directory servers; just a
// workaround...
- Set<String> copyOfConfig = new HashSet<String>(this.configuration);
+ List<String> copyOfConfig = new ArrayList<String>(this.configuration);
// TODO when working dir exists, but Tor did not manage to write
// a fingerprint file, we get a NullPointerException...
String fakeDirServerString = "DirServer " + this.nodeName
+ " 127.0.0.1:" + this.dirPort
+ " 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000";
copyOfConfig.add(fakeDirServerString);
- try {
- BufferedWriter bw = new BufferedWriter(new FileWriter(
- this.tempConfigFile));
- for (String c : copyOfConfig) {
- bw.write(c + "\n");
- }
- bw.close();
- } catch (IOException e) {
- TorProcessException ex = new TorProcessException(
- "Could not write temporary config file!", e);
- this.logger.throwing(this.getClass().getName(),
- "determineFingerprint", ex);
- throw ex;
- }
+ writeConfigurationFile(this.tempConfigFile, copyOfConfig);
// start process with option --list-fingerprint
// TODO make this more configurable
Added: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithDir.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithDir.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithDir.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -0,0 +1,183 @@
+/*
+ *
+ * WARNING! This class is untested, yet! Don't rely on it!
+ *
+ */
+
+package de.uniba.wiai.lspi.puppetor.rmi;
+
+import java.rmi.Naming;
+import java.rmi.RMISecurityManager;
+import java.rmi.RemoteException;
+
+import de.uniba.wiai.lspi.puppetor.DirectoryNode;
+import de.uniba.wiai.lspi.puppetor.Event;
+import de.uniba.wiai.lspi.puppetor.EventListener;
+import de.uniba.wiai.lspi.puppetor.EventManager;
+import de.uniba.wiai.lspi.puppetor.Network;
+import de.uniba.wiai.lspi.puppetor.NetworkFactory;
+import de.uniba.wiai.lspi.puppetor.RouterNode;
+import de.uniba.wiai.lspi.puppetor.TorProcessException;
+
+/**
+ * @author pgeyer, jjungkunst, sschilling
+ */
+public class MergingNetworkWithDir {
+
+ private Network network = null;
+
+ public MergingNetworkWithDir(String dirServerIpAddress)
+ throws TorProcessException, RemoteException {
+ network = NetworkFactory.createNetwork("with", 8000);
+
+ DirectoryNode dir1 = network
+ .createDirectory("dir1", dirServerIpAddress);
+ DirectoryNode dir2 = network
+ .createDirectory("dir2", dirServerIpAddress);
+ dir1.replaceConfiguration("DirListenAddress " + dirServerIpAddress);
+ dir2.replaceConfiguration("DirListenAddress " + dirServerIpAddress);
+
+ RouterNode node1 = network.createRouter("node1", dirServerIpAddress);
+ RouterNode node2 = network.createRouter("node2", dirServerIpAddress);
+ RouterNode node3 = network.createRouter("node3", dirServerIpAddress);
+ RouterNode node4 = network.createRouter("node4", dirServerIpAddress);
+ RouterNode node5 = network.createRouter("node5", dirServerIpAddress);
+ RouterNode node6 = network.createRouter("node6", dirServerIpAddress);
+
+ dir1.addConfiguration("HidServDirectoryV2 1");
+ dir2.addConfiguration("HidServDirectoryV2 1");
+ dir1.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ dir2.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+
+ node1.addConfiguration("HidServDirectoryV2 1");
+ node2.addConfiguration("HidServDirectoryV2 1");
+ node3.addConfiguration("HidServDirectoryV2 1");
+ node4.addConfiguration("HidServDirectoryV2 1");
+ node5.addConfiguration("HidServDirectoryV2 1");
+ node6.addConfiguration("HidServDirectoryV2 1");
+ node1.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node2.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node3.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node4.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node5.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node6.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node1.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node2.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node3.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node4.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node5.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node6.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+
+ node1.addConfiguration("PublishHidServDescriptors 0");
+ node1.addConfiguration("PublishV2HidServDescriptors 1");
+ node1.addConfiguration("FetchHidServDescriptors 0");
+ node1.addConfiguration("FetchV2HidServDescriptors 1");
+ node2.addConfiguration("PublishHidServDescriptors 0");
+ node2.addConfiguration("PublishV2HidServDescriptors 1");
+ node2.addConfiguration("FetchHidServDescriptors 0");
+ node2.addConfiguration("FetchV2HidServDescriptors 1");
+ node3.addConfiguration("PublishHidServDescriptors 0");
+ node3.addConfiguration("PublishV2HidServDescriptors 1");
+ node3.addConfiguration("FetchHidServDescriptors 0");
+ node3.addConfiguration("FetchV2HidServDescriptors 1");
+ node4.addConfiguration("FetchHidServDescriptors 0");
+ node4.addConfiguration("FetchV2HidServDescriptors 1");
+ node5.addConfiguration("FetchHidServDescriptors 0");
+ node5.addConfiguration("FetchV2HidServDescriptors 1");
+ node6.addConfiguration("FetchHidServDescriptors 0");
+ node6.addConfiguration("FetchV2HidServDescriptors 1");
+ node4.addConfiguration("PublishHidServDescriptors 0");
+ node4.addConfiguration("PublishV2HidServDescriptors 1");
+ node5.addConfiguration("PublishHidServDescriptors 0");
+ node5.addConfiguration("PublishV2HidServDescriptors 1");
+ node6.addConfiguration("PublishHidServDescriptors 0");
+ node6.addConfiguration("PublishV2HidServDescriptors 1");
+
+ try {
+ EventManager manager = network.getEventManager();
+ EventListener listener = new EventListener() {
+ public void handleEvent(Event event) {
+ System.out.println(event.getMessage());
+ }
+ };
+ manager.addEventListener(listener);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ startupNetwork();
+ }
+
+ public void startupNetwork() {
+
+ try {
+ network.configureAsPrivateNetwork();
+ System.out.println("Network written ...");
+ network.writeConfigurations();
+ System.out.println("Config written ...");
+ if (!network.startNodes(5000)) {
+ System.out.println("Failed to start the nodes!");
+ return;
+ }
+ System.out.println("Nodes started ...");
+
+ if (!network.hupUntilUp(30, 5000)) {
+ // System.out.println("Failed to build circuits!");
+ return;
+ }
+ System.out.println("Successfully built circuits!");
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Network getNetwork() {
+ return this.network;
+ }
+
+ public void shutdownNetwork() {
+ try {
+ this.network.shutdownNodes();
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Nodes stopped ...");
+ }
+
+ private static int hours = 25;
+
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
+
+ if (args.length == 2) {
+ System.out.println("Usage: java "
+ + MergingNetworkWithOutDir.class.getCanonicalName()
+ + " [hostAndOrPort] [bindingName]");
+ System.exit(1);
+ }
+
+ MergingNetworkWithDir mergingWith = new MergingNetworkWithDir(args[0]);
+
+ System.setSecurityManager(new RMISecurityManager());
+
+ try {
+ Naming.rebind("//" + args[1] + "/" + args[2], mergingWith
+ .getNetwork());
+ System.out.println("Bound With, registered to: " + args[2]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out
+ .println("Binding Exception. Is the rmiregistry running?");
+ }
+
+ try {
+ Thread.sleep(hours * 60 * 60 * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Added: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java 2007-09-23 15:48:14 UTC (rev 11593)
@@ -0,0 +1,167 @@
+/*
+ *
+ * WARNING! This class is untested, yet! Don't rely on it!
+ *
+ */
+
+package de.uniba.wiai.lspi.puppetor.rmi;
+
+import java.rmi.Naming;
+import java.rmi.RMISecurityManager;
+import java.rmi.RemoteException;
+
+import de.uniba.wiai.lspi.puppetor.Network;
+import de.uniba.wiai.lspi.puppetor.NetworkFactory;
+import de.uniba.wiai.lspi.puppetor.RouterNode;
+import de.uniba.wiai.lspi.puppetor.TorProcessException;
+import de.uniba.wiai.lspi.puppetor.diststorage.DistributedStorage;
+
+/**
+ * @author pgeyer, jjungkunst, sschilling
+ */
+public class MergingNetworkWithOutDir {
+
+ private Network network = null;
+
+ public MergingNetworkWithOutDir(String dirServerIpAddress)
+ throws TorProcessException, RemoteException {
+ network = NetworkFactory.createNetwork("without");
+
+ RouterNode node1 = network.createRouter("node10", dirServerIpAddress);
+ RouterNode node2 = network.createRouter("node20", dirServerIpAddress);
+ RouterNode node3 = network.createRouter("node30", dirServerIpAddress);
+ RouterNode node4 = network.createRouter("node40", dirServerIpAddress);
+ RouterNode node5 = network.createRouter("node50", dirServerIpAddress);
+ RouterNode node6 = network.createRouter("node60", dirServerIpAddress);
+
+ node1.addConfiguration("HidServDirectoryV2 1");
+ node2.addConfiguration("HidServDirectoryV2 1");
+ node3.addConfiguration("HidServDirectoryV2 1");
+ node4.addConfiguration("HidServDirectoryV2 1");
+ node5.addConfiguration("HidServDirectoryV2 1");
+ node6.addConfiguration("HidServDirectoryV2 1");
+ node1.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node2.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node3.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node4.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node5.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node6.addConfiguration("ConsiderAllRoutersAsHidServDirectories 1");
+ node1.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node2.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node3.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node4.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node5.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+ node6.addConfiguration("MinUptimeHidServDirectoryV2 0 minutes");
+
+ node1.addConfiguration("PublishHidServDescriptors 0");
+ node1.addConfiguration("PublishV2HidServDescriptors 1");
+ node1.addConfiguration("FetchHidServDescriptors 0");
+ node1.addConfiguration("FetchV2HidServDescriptors 1");
+ node2.addConfiguration("PublishHidServDescriptors 0");
+ node2.addConfiguration("PublishV2HidServDescriptors 1");
+ node2.addConfiguration("FetchHidServDescriptors 0");
+ node2.addConfiguration("FetchV2HidServDescriptors 1");
+ node3.addConfiguration("PublishHidServDescriptors 0");
+ node3.addConfiguration("PublishV2HidServDescriptors 1");
+ node3.addConfiguration("FetchHidServDescriptors 0");
+ node3.addConfiguration("FetchV2HidServDescriptors 1");
+ node4.addConfiguration("FetchHidServDescriptors 0");
+ node4.addConfiguration("FetchV2HidServDescriptors 1");
+ node5.addConfiguration("FetchHidServDescriptors 0");
+ node5.addConfiguration("FetchV2HidServDescriptors 1");
+ node6.addConfiguration("FetchHidServDescriptors 0");
+ node6.addConfiguration("FetchV2HidServDescriptors 1");
+ node4.addConfiguration("PublishHidServDescriptors 0");
+ node4.addConfiguration("PublishV2HidServDescriptors 1");
+ node5.addConfiguration("PublishHidServDescriptors 0");
+ node5.addConfiguration("PublishV2HidServDescriptors 1");
+ node6.addConfiguration("PublishHidServDescriptors 0");
+ node6.addConfiguration("PublishV2HidServDescriptors 1");
+
+ configureNetwork();
+ }
+
+ public void configureNetwork() {
+
+ try {
+ network.configureAsPrivateNetwork();
+ System.out.println("Network written ...");
+ network.writeConfigurations();
+ System.out.println("Config written ...");
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void startupNetwork() {
+
+ try {
+ if (!network.startNodes(5000)) {
+ System.out.println("Failed to start the nodes!");
+ return;
+ }
+ System.out.println("Nodes started ...");
+
+ if (!network.hupUntilUp(30, 5000)) {
+ // System.out.println("Failed to build circuits!");
+ return;
+ }
+ System.out.println("Successfully built circuits!");
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Network getNetwork() {
+ return this.network;
+ }
+
+ public void shutdownNetwork() {
+ try {
+ this.network.shutdownNodes();
+ } catch (TorProcessException e) {
+ e.printStackTrace();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Nodes stopped ...");
+ }
+
+ private static int hours = 25;
+
+ public static void main(String[] args) throws TorProcessException,
+ RemoteException {
+
+ if (args.length == 2) {
+ System.out.println("Usage: java "
+ + MergingNetworkWithOutDir.class.getCanonicalName()
+ + " [hostAndOrPort] [bindingName]");
+ System.exit(1);
+ }
+
+ MergingNetworkWithOutDir without = new MergingNetworkWithOutDir(args[0]);
+
+ System.setSecurityManager(new RMISecurityManager());
+
+ try {
+ Naming.rebind("//" + args[1] + "/" + args[2], without.getNetwork());
+ System.out.println("Bound Without, registered to: " + args[2]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out
+ .println("Binding Exception. Is the rmiregistry running?");
+ }
+
+ try {
+ Thread.sleep(60000 * 60 * hours);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ without.shutdownNetwork();
+ }
+}
\ No newline at end of file
More information about the tor-commits
mailing list