[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r11736: refactored a lot of things to make old and new parts (RMI, n (in puppetor/trunk/src/de/uniba/wiai/lspi/puppetor: . examples groovy impl)
Author: kloesing
Date: 2007-10-01 17:59:35 -0400 (Mon, 01 Oct 2007)
New Revision: 11736
Added:
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenService.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenServiceEventType.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/PuppeTorException.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/LongRunningNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/MergingProxiesWithLongRunningNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/MergingRoutersWithLongRunningNetwork.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/HiddenServiceImpl.java
Removed:
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/AliceEventType.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/BobEventType.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MiscEventType.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkState.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/TorProcessException.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/diststorage/
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/
Modified:
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientEventType.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventType.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/NodeEventType.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeState.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/ServerApplication.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ServerEventType.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/groovy/RmiPuppetzShell.java
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ClientApplicationImpl.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/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
puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java
Log:
refactored a lot of things to make old and new parts (RMI, network merging, Groovy shell) better fit together
Deleted: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/AliceEventType.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/AliceEventType.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/AliceEventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2007, Karsten Loesing
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * * Neither the names of the copyright owners nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.uniba.wiai.lspi.puppetor;
-
-public class AliceEventType implements EventType{
-
- /**
- * Alice has received an onion request; this event is parsed from a log
- * statement in connection_ap_handshake_rewrite_and_attach().
- */
- public static final AliceEventType ALICE_ONION_REQUEST_RECEIVED = new AliceEventType();
-
- /**
- * Alice sends a fetch request for a hidden service descriptor to a
- * directory server; this event is parsed from a log statement in
- * rend_client_refetch_renddesc().
- */
- public static final AliceEventType ALICE_SENDING_FETCH_DESC = new AliceEventType();
-
- /**
- * Alice receives a reply to a previous fetch request for a hidden service
- * descriptors from a directory server; this event is parsed from a log
- * statement in connection_dir_client_reached_eof().
- */
- public static final AliceEventType ALICE_DESC_FETCHED_RECEIVED = new AliceEventType();
-
- /**
- * Alice has built a circuit to a rendezvous point and sends an
- * ESTABLISH_RENDEZVOUS cell; this event is parsed from a log statement in
- * rend_client_send_establish_rendezvous().
- */
- public static final AliceEventType ALICE_BUILT_REND_CIRC_SENDING_ESTABLISH_RENDEZVOUS = new AliceEventType();
-
- /**
- * Alice receives a RENDEZVOUS_ESTABLISHED cell from a rendezvous point;
- * this event is parsed from a log statement in
- * rend_client_rendezvous_acked().
- */
- public static final AliceEventType ALICE_RENDEZVOUS_ESTABLISHED_RECEIVED = new AliceEventType();
-
- /**
- * Alice has built a circuit to an introduction point (which does not
- * automatically lead to sending an INTRODUCE1 cell, because the rendezvous
- * circuit might not be ready); this event is parsed from a log statement in
- * rend_client_introcirc_has_opened().
- */
- public static final AliceEventType ALICE_BUILT_INTRO_CIRC = new AliceEventType();
-
- /**
- * Alice sends an INTRODUCE1 cell to an introduction point; this event is
- * parsed from a log statement in rend_client_send_introduction().
- */
- public static final AliceEventType ALICE_SENDING_INTRODUCE1 = new AliceEventType();
-
- /**
- * Alice has received an INTRODUCE_ACK cell as an acknowledgement to the
- * previous INTRODUCE1 cell; this event is parsed from a log statement in
- * rend_client_introduction_acked().
- */
- public static final AliceEventType ALICE_INTRODUCE_ACK_RECEIVED = new AliceEventType();
-
- /**
- * Alice has received a RENDEZVOUS2 cell and can now open an application
- * connection to the client; this event is parsed from a log statement in
- * rend_client_receive_rendezvous().
- */
- public static final AliceEventType ALICE_RENDEZVOUS2_RECEIVED_APP_CONN_OPENED = new AliceEventType();
-}
\ No newline at end of file
Deleted: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/BobEventType.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/BobEventType.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/BobEventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2007, Karsten Loesing
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * * Neither the names of the copyright owners nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.uniba.wiai.lspi.puppetor;
-
-public class BobEventType implements EventType{
-
- /**
- * Bob has built a circuit to an introduction point and sends an
- * ESTABLISH_INTRO cell; this event is parsed from a log statement in
- * rend_service_intro_has_opened().
- */
- public static final BobEventType BOB_BUILT_INTRO_CIRC_SENDING_ESTABLISH_INTRO = new BobEventType();
-
- /**
- * Bob has received an INTRO_ESTABLISHED cell, i.e. a node has confirmed to
- * work as introduction point; this event is parsed from a log statement in
- * rend_service_intro_established().
- */
- public static final BobEventType BOB_INTRO_ESTABLISHED_RECEIVED = new BobEventType();
-
- /**
- * Bob posts a hidden service descriptor to the directory servers (or to
- * hidden service directories in a modified Tor); this event is parsed from
- * a log statement in upload_service_descriptor().
- */
- public static final BobEventType BOB_SENDING_PUBLISH_DESC = new BobEventType();
-
- /**
- * Bob received a response from a directory server (or from a hidden service
- * directory in a modified Tor) to a previous publish request; this event is
- * parsed from a log statement in connection_dir_client_reached_eof().
- */
- public static final BobEventType BOB_DESC_PUBLISHED_RECEIVED = new BobEventType();
-
- /**
- * Bob has received an INTRODUCE2 cell, i.e. a node wants to establish a
- * connection, and will now try to establish a circuit to the client's
- * rendezvous point; this event is parsed from a log statement in
- * rend_service_introduce().
- */
- public static final BobEventType BOB_INTRODUCE2_RECEIVED = new BobEventType();
-
- /**
- * Bob has built a circuit to a rendezvous point and sends an RENDEZVOUS1
- * cell; this event is parsed from a log statement in
- * rend_service_rendezvous_has_opened().
- */
- public static final BobEventType BOB_BUILT_REND_CIRC_SENDING_RENDEZVOUS1 = new BobEventType();
-
- /**
- * Bob opens a connection to the actual hidden server; this event is parsed
- * from a log statement in connection_exit_begin_conn().
- */
- public static final BobEventType BOB_APP_CONN_OPENED = new BobEventType();
-
-}
\ No newline at end of file
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -46,21 +46,22 @@
* <p>
* Performs one or more HTTP requests to a previously provided address and
* port. All requests are performed by a thread in the background, so that
- * this method may return immediately. That thread will try for
+ * this method returns immediately. That thread will try for
* <code>retries</code> times to make the request with a timeout of
- * <code>timeoutForEachRetry</code> millis each. If an attempt is not
- * successful, the thread nevertheless waits for the timeout to expire. If
- * <code>stopOnSuccess</code> is set to <code>true</code>, the thread
- * will quit performing requests after the first successful request.
+ * <code>timeoutForEachRetry</code> milliseconds each. If an attempt is not
+ * successful, the thread nevertheless waits for the timeout to expire
+ * before performing the next attempt. If <code>stopOnSuccess</code> is
+ * set to <code>true</code>, the thread will quit performing requests
+ * immediately after the first successful request.
* </p>
*
* <p>
- * For each sent request the application fires an
- * <event>EventType.APPLICATION_SENDING_REQUEST</code> event. On receiving
- * a reply it fires an event of type <code>EventType.APPLICATION_REPLY_RECEIVED</code>,
- * if a request is not successful or times out, an <code>EventType.APPLICATION_GAVE_UP_REQUEST</code>
+ * For each sent request the application fires a
+ * <event>ClientEventType.CLIENT_SENDING_REQUEST</code> event. On receiving
+ * a reply it fires an event of type <code>ClientEventType.CLIENT_REPLY_RECEIVED</code>,
+ * if a request is not successful or times out, a <code>ClientEventType.CLIENT_GAVE_UP_REQUEST</code>
* event is fired. After all requests have been performed (either
- * successfully, or not) an event of type <code>EventType.APPLICATION_REQUESTS_PERFORMED</code>
+ * successfully, or not) an event of type <code>ClientEventType.CLIENT_REQUESTS_PERFORMED</code>
* is fired.
* </p>
*
@@ -82,7 +83,7 @@
* Thrown if an invalid value is given for either of the
* parameters.
*/
- public abstract void performRequest(int retries, long timeoutForEachRetry,
+ public abstract void startRequests(int retries, long timeoutForEachRetry,
boolean stopOnSuccess);
/**
@@ -92,7 +93,6 @@
* Thrown if no requests have been started before.
*/
public abstract void stopRequest();
-
/**
* Returns the name of this client.
@@ -100,4 +100,27 @@
* @return The name of this client.
*/
public abstract String getClientApplicationName();
+
+ /**
+ * Returns the SOCKS port of the local Tor node to which requests are sent.
+ *
+ * @return The SOCKS port of the local Tor node to which requests are sent.
+ */
+ public abstract int getSocksPort();
+
+ /**
+ * Returns the target name for the requests sent by this client; can be
+ * either a server name/address or an onion address.
+ *
+ * @return The target name for the requests sent by this client.
+ */
+ public abstract String getTargetName();
+
+ /**
+ * Returns the target port for the requests sent by this client; can be
+ * either a server port or a virtual port of a hidden service.
+ *
+ * @return The target port for the requests sent by this client.
+ */
+ public abstract int getTargetPort();
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientEventType.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientEventType.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientEventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -31,32 +31,59 @@
*/
package de.uniba.wiai.lspi.puppetor;
-public class ClientEventType implements EventType{
-
+/**
+ * Event types that can be fired by a client application running as thread in
+ * the background.
+ */
+public class ClientEventType implements EventType {
+
/**
+ * String identifying the type of the event type.
+ */
+ String typeString;
+
+ /**
+ * Creates a new event type with the given type string.
+ *
+ * @param typeString
+ * String identifying the type of the event type.
+ */
+ public ClientEventType(String typeString) {
+ this.typeString = typeString;
+ }
+
+ public String getTypeName() {
+ return this.typeString;
+ }
+
+ /**
* The client application is sending a request; this event is fired
* internally and not parsed from a log statement from Tor.
*/
- public static final ClientEventType CLIENT_SENDING_REQUEST = new ClientEventType();
+ public static final ClientEventType CLIENT_SENDING_REQUEST = new ClientEventType(
+ "CLIENT_SENDING_REQUEST");
/**
* The client application has received a reply to a previously sent request;
* this event is fired internally and not parsed from a log statement from
* Tor.
*/
- public static final ClientEventType CLIENT_REPLY_RECEIVED = new ClientEventType();
+ public static final ClientEventType CLIENT_REPLY_RECEIVED = new ClientEventType(
+ "CLIENT_REPLY_RECEIVED");
/**
* The client application has given up waiting for the reply to a previously
* sent request; this event is fired internally and not parsed from a log
* statement from Tor.
*/
- public static final ClientEventType CLIENT_GAVE_UP_REQUEST = new ClientEventType();
+ public static final ClientEventType CLIENT_GAVE_UP_REQUEST = new ClientEventType(
+ "CLIENT_GAVE_UP_REQUEST");
/**
* The client application has completed a series of requests, whether they
* were successful or not; this event is fired internally and not parsed
* from a log statement from Tor.
*/
- public static final ClientEventType CLIENT_REQUESTS_PERFORMED = new ClientEventType();
+ public static final ClientEventType CLIENT_REQUESTS_PERFORMED = new ClientEventType(
+ "CLIENT_REQUESTS_PERFORMED");
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/DirectoryNode.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -52,56 +52,31 @@
*
* @return <code>DirServer</code> string to configure a node to use this
* node as directory server.
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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, RemoteException;
+ public abstract String getDirServerString() throws PuppeTorException,
+ RemoteException;
/**
- * Writes the given (possibly empty) 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.
+ * Adds the given (possibly empty) set of onion router fingerprints to the
+ * set of approved routers to confirm to directory clients, that the given
+ * routers can be trusted. Changes are only stored locally and not written
+ * to the <code>approved-routers</code> file to disk which will be done
+ * when writing the configuration of this node.
*
* @param approvedRouters
- * The set of approved routers to be written. 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, an empty
- * <code>approved-routers</code> file will be written.
- * @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, 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.
+ * Thrown if <code>null</code> is passed as parameter.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
public void addApprovedRouters(Set<String> approvedRouters)
- throws TorProcessException, RemoteException;
+ throws RemoteException;
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -36,12 +36,12 @@
/**
* An <code>Event</code> is created for every state change of an asynchronous
* system component, e.g. a Tor process or a client/server application running
- * as thread in the background. In contrast to <code>NodeState</code> or
- * <code>NetworkState</code> an <code>Event</code> cannot be a pre- or
- * postconditions for a method invocation. There is no prescribed order in which
- * events are fired by a certain process or application. Some events can be
- * fired only once, others possibly multiple times. All management operations
- * for events are contained in the <code>EventManager</code>.
+ * as thread in the background. In contrast to <code>NodeState</code> an
+ * <code>Event</code> cannot be a pre- or postconditions for a method
+ * invocation. There is no prescribed order in which events are fired by a
+ * certain process or application. Some events can be fired only once, others
+ * possibly multiple times. All management operations for events are contained
+ * in the <code>EventManager</code>.
*
* @author kloesing
*/
@@ -56,7 +56,7 @@
public abstract String getSource();
/**
- * Returns the type of this event.
+ * Returns the event type.
*
* @return The event type.
*/
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -40,7 +40,7 @@
* asynchronous events by Tor processes and client or server applications
* running as threads in the background. A test application can either register
* event listeners to be notified asynchronously about events when they occur,
- * or synchronize with an event by being blocked until the certain event occurs.
+ * or synchronize with an event by being blocked until a certain event occurs.
*
* @author kloesing
*/
@@ -54,7 +54,7 @@
* signalized in a later invocation on the event listener, but not in both.
* This prevents race conditions by eliminating the gap between registration
* of an event handler and asking if an event has been fired before
- * registering. This method can be invoked in any node or network state.
+ * registering.
*
* @param source
* The name of the source of events that the listener is
@@ -72,7 +72,7 @@
* empty list is returned instead of <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
- * parameters or if <code>source</code> is not known.
+ * parameters or if the <code>source</code> is unknown.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
@@ -81,16 +81,14 @@
/**
* Registers the given <code>listener</code> as event listener for future
- * events originating from any source. This method can be invoked in any
- * node or network state.
+ * events originating from any source.
*
* @param listener
* The listener that wants to be notified about events from the
* given <code>source</code>. If the <code>listener</code>
- * is already registered for the same <code>source</code>,
- * nothing happens, i.e. the <code>listener</code> will not
- * receive multiple invocations for the same event. May not be
- * <code>null</code>.
+ * is already registered for all sources, nothing happens, i.e.
+ * the <code>listener</code> will not receive multiple
+ * invocations for the same event. May not be <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for the parameter.
* @throws RemoteException
@@ -107,11 +105,11 @@
* The source of the events that the invoking thread is
* interested in. May not be <code>null</code> and must be the
* name of a previously created node, client, or server.
- * @throws IllegalArgumentException
- * Thrown if <code>null</code> is passed as parameter or if
- * <code>source</code> is unknown.
* @return List of all previously observed events from the given
* <code>source</code>.
+ * @throws IllegalArgumentException
+ * Thrown if <code>null</code> is passed as parameter or if
+ * the <code>source</code> is unknown.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
@@ -119,16 +117,16 @@
throws RemoteException;
/**
- * Returns whether the given <code>event</code> has been observed from the
- * given <code>source</code> before, or not.
+ * Returns whether the given <code>eventType</code> has been observed from
+ * the given <code>source</code> before, or not.
*
* @param source
* The source of the event that the invoking thread is interested
* in. May not be <code>null</code> and must be the name of a
* previously created node, client, or server.
- * @param event
- * The event that the invoking thread is interested int. May not
- * be <code>null</code>.
+ * @param eventType
+ * The event type that the invoking thread is interested in. May
+ * not be <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
* parameters or if <code>source</code> is unknown.
@@ -137,19 +135,14 @@
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract boolean hasEventOccured(String source, EventType event)
+ public abstract boolean hasEventOccured(String source, EventType eventType)
throws RemoteException;
/**
* Removes the given <code>listener</code> as event listener from all
* previously registered sources. If this listener is not registered for any
- * source, nothing happens. This method can be invoked in any node or
- * network state.
+ * source, nothing happens.
*
- * TODO should we include the source as parameter, too, to have even more
- * control over removing listeners from sources? Or should we overload the
- * method?
- *
* @param listener
* The listener that shall be removed from the list of registered
* listeners. May not be <code>null</code>.
@@ -162,125 +155,130 @@
throws RemoteException;
/**
- * Checks if the given <code>event</code> has been observed from the given
- * <code>source</code> before; if not, blocks the invoking thread until
- * the next event is fired from that source. Note that this method does not
- * restrict waiting to a timeout, so that it could potentially block
- * forever! This method can be invoked in any node or network state.
+ * Checks if the given <code>eventType</code> has been observed from the
+ * given <code>source</code> before; if not, blocks the invoking thread
+ * until the next event of this type is fired from that source. Note that
+ * this method does not restrict waiting to a timeout, so that it could
+ * potentially block forever!
*
* @param source
* The source of the event that the invoking thread is willing to
* wait for. May not be <code>null</code> and must be the name
* of a previously created node, client, or server.
- * @param event
- * The event that the invoking thread is willing to wait for from
- * the given <code>source</code>. May not be <code>null</code>.
+ * @param eventType
+ * The event type that the invoking thread is willing to wait for
+ * from the given <code>source</code>. May not be
+ * <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
- * parameters or if <code>source</code> is unknown.
+ * parameters or if the <code>source</code> is unknown.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract void waitForAnyOccurence(String source, EventType event)
+ public abstract void waitForAnyOccurence(String source, EventType eventType)
throws RemoteException;
/**
- * Checks if the given <code>event</code> has been observed from the given
- * <code>source</code> before; if not, blocks the invoking thread until
- * the next event is fired from that source or the given timeout of
- * <code>maximumTimeToWaitInMillis</code> millis has expired. This method
- * can be invoked in any node or network state.
+ * Checks if the given <code>eventType</code> has been observed from the
+ * given <code>source</code> before; if not, blocks the invoking thread
+ * until the next event of this type is fired from that source or the given
+ * timeout of <code>maximumTimeToWaitInMillis</code> milliseconds has
+ * expired.
*
* @param source
* The source of the event that the invoking thread is willing to
* wait for. May not be <code>null</code> and must be the name
* of a previously created node, client, or server.
- * @param event
- * The event that the invoking thread is willing to wait for from
- * the given <code>source</code>. May not be <code>null</code>.
+ * @param eventType
+ * The event type that the invoking thread is willing to wait for
+ * from the given <code>source</code>. May not be
+ * <code>null</code>.
* @param maximumTimeToWaitInMillis
* The maximum time to wait in milliseconds. A positive value or
* zero restricts waiting to this time. If this value is
* negative, we will wait potentially forever.
* @return <code>true</code> if an event of the given type has been fired
- * by the source within the given timeout, <code>false</code>
- * otherwise.
+ * by the <code>source</code> within the given timeout,
+ * <code>false</code> otherwise.
* @throws IllegalArgumentException
* Thrown if an invalid value is passed for either of the
- * parameters or if <code>source</code> is unknown.
+ * parameters or if the <code>source</code> is unknown.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract boolean waitForAnyOccurence(String source, EventType event,
- long maximumTimeToWaitInMillis) throws RemoteException;
+ public abstract boolean waitForAnyOccurence(String source,
+ EventType eventType, long maximumTimeToWaitInMillis)
+ throws RemoteException;
/**
* Blocks the invoking thread until the next <code>event</code> is fired
* from the given <code>source</code>. This method only waits for the
* next occurence of an event, regardless of previous occurrences. Note that
* this method does not restrict waiting to a timeout, so that it could
- * potentially block forever! This method can be invoked in any node or
- * network state.
+ * potentially block forever!
*
* @param source
* The source of the event that the invoking thread is willing to
* wait for. May not be <code>null</code> and must be the name
* of a previously created node, client, or server.
- * @param event
- * The event that the invoking thread is willing to wait for from
- * the given <code>source</code>. May not be <code>null</code>.
+ * @param eventType
+ * The event type that the invoking thread is willing to wait for
+ * from the given <code>source</code>. May not be
+ * <code>null</code>.
* @throws IllegalArgumentException
* Thrown if <code>null</code> is passed for either of the
- * parameters or if <code>source</code> is unknown.
+ * parameters or if the <code>source</code> is unknown.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract void waitForNextOccurence(String source, EventType event)
+ public abstract void waitForNextOccurence(String source, EventType eventType)
throws RemoteException;
/**
* Blocks the invoking thread until the next <code>event</code> is fired
* from the given <code>source</code> or the given timeout of
- * <code>maximumTimeToWaitInMillis</code> millis has expired. This method
+ * <code>maximumTimeToWaitInMillis</code> milliseconds has expired. This method
* only waits for the next occurence of an event, regardless of previous
- * occurrences. This method can be invoked in any node or network state.
+ * occurrences.
*
* @param source
* The source of the event that the invoking thread is willing to
* wait for. May not be <code>null</code> and must be the name
* of a previously created node, client, or server.
- * @param event
- * The event that the invoking thread is willing to wait for from
- * the given <code>source</code>. May not be <code>null</code>.
+ * @param eventType
+ * The event type that the invoking thread is willing to wait for
+ * from the given <code>source</code>. May not be
+ * <code>null</code>.
* @param maximumTimeToWaitInMillis
* The maximum time to wait in milliseconds. A positive value or
* zero restricts waiting to this time. If this value is
* negative, we will wait potentially forever.
* @return <code>true</code> if an event of the given type has been fired
- * by the source within the given timeout, <code>false</code>
- * otherwise.
+ * by the <code>source</code> within the given timeout,
+ * <code>false</code> otherwise.
* @throws IllegalArgumentException
* Thrown if an invalid value is passed for either of the
- * parameters or if <code>source</code> is unknown.
+ * parameters or if the <code>source</code> is unknown.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
public abstract boolean waitForNextOccurence(String source,
- EventType event, long maximumTimeToWaitInMillis)
+ EventType eventType, long maximumTimeToWaitInMillis)
throws RemoteException;
/**
* Registers a new event type by passing a pattern string that can be
* applied to a regular expression when parsing Tor log statements. This is
* useful for log statements that are only included in modified Tor
- * versions.
+ * versions. Therefore, the event type may be an instance of a self-defined
+ * class that implements <code>EventType</code>.
*
* @param patternString
* The pattern string that will be used for parsing Tor log
* statements; the syntax corresponds to java.util.regex.Pattern.
* @param eventType
- * The event type that will be fired when a log statement was
- * parsed that includes the given pattern.
+ * The event type of the event 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.
*/
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventType.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventType.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -40,4 +40,11 @@
*/
public interface EventType {
+ /**
+ * Returns a string representation of the event type name for display
+ * purposes.
+ *
+ * @return String representation of the event type name.
+ */
+ public abstract String getTypeName();
}
Added: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenService.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenService.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenService.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -0,0 +1,56 @@
+package de.uniba.wiai.lspi.puppetor;
+
+/**
+ * A <code>HiddenService</code> instance contains all configurations of a
+ * hidden service that is registered at a node.
+ *
+ * @author kloesing
+ */
+public interface HiddenService {
+
+ /**
+ * Determines the onion address for a previously added hidden service with
+ * name <code>serviceName</code>. Requires that the node has been
+ * started, i.e. is in state <code>NodeState.RUNNING</code>, and is
+ * configured to provide this hidden service.
+ *
+ * @return The onion address string consisting of 16 base32 chars plus
+ * ".onion" for hidden service versions 0 and 1 or 16 base32 chars
+ * plus "." plus 24 base32 chars plus ".onion" for hidden service
+ * version 2.
+ * @throws IllegalArgumentException
+ * Thrown if <code>null</code> or a zero-length string is
+ * passed as parameter.
+ * @throws IllegalStateException
+ * Thrown if the node at which this hidden service is configured
+ * is not in state <code>NodeState.RUNNING</code>.
+ * @throws PuppeTorException
+ * Thrown if the onion address of this hidden service could not
+ * be read, which is also the case when the node's configuration
+ * has not been written and the node has not been HUP'ed after
+ * configuring the hidden service.
+ */
+ public abstract String determineOnionAddress() throws PuppeTorException;
+
+ /**
+ * Returns the name of the hidden service.
+ *
+ * @return The name of the hidden service.
+ */
+ public String getServiceName();
+
+ /**
+ * Returns the port on which the service listens for requests.
+ *
+ * @return The port on which the service listens for requests.
+ */
+ public int getServicePort();
+
+ /**
+ * Returns the virtual port that this hidden service runs on as it is
+ * announced to clients.
+ *
+ * @return The virtual port of this hidden service.
+ */
+ public int getVirtualPort();
+}
Copied: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenServiceEventType.java (from rev 11669, puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/AliceEventType.java)
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenServiceEventType.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/HiddenServiceEventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2007, Karsten Loesing
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the names of the copyright owners nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package de.uniba.wiai.lspi.puppetor;
+
+/**
+ * Event types that can be fired by all Tor processes performing hidden-service
+ * operations.
+ */
+public class HiddenServiceEventType implements EventType {
+
+ /**
+ * String identifying the type of the event type.
+ */
+ String typeString;
+
+ /**
+ * Creates a new event type with the given type string.
+ *
+ * @param typeString
+ * String identifying the type of the event type.
+ */
+ public HiddenServiceEventType(String typeString) {
+ this.typeString = typeString;
+ }
+
+ public String getTypeName() {
+ return this.typeString;
+ }
+
+ /**
+ * Alice has received an onion request; this event is parsed from a log
+ * statement in connection_ap_handshake_rewrite_and_attach().
+ */
+ public static final HiddenServiceEventType ALICE_ONION_REQUEST_RECEIVED = new HiddenServiceEventType(
+ "ALICE_ONION_REQUEST_RECEIVED");
+
+ /**
+ * Alice sends a fetch request for a hidden service descriptor to a
+ * directory server; this event is parsed from a log statement in
+ * rend_client_refetch_renddesc().
+ */
+ public static final HiddenServiceEventType ALICE_SENDING_FETCH_DESC = new HiddenServiceEventType(
+ "ALICE_SENDING_FETCH_DESC");
+
+ /**
+ * Alice receives a reply to a previous fetch request for a hidden service
+ * descriptors from a directory server; this event is parsed from a log
+ * statement in connection_dir_client_reached_eof().
+ */
+ public static final HiddenServiceEventType ALICE_DESC_FETCHED_RECEIVED = new HiddenServiceEventType(
+ "ALICE_DESC_FETCHED_RECEIVED");
+
+ /**
+ * Alice has built a circuit to a rendezvous point and sends an
+ * ESTABLISH_RENDEZVOUS cell; this event is parsed from a log statement in
+ * rend_client_send_establish_rendezvous().
+ */
+ public static final HiddenServiceEventType ALICE_BUILT_REND_CIRC_SENDING_ESTABLISH_RENDEZVOUS = new HiddenServiceEventType(
+ "ALICE_BUILT_REND_CIRC_SENDING_ESTABLISH_RENDEZVOUS");
+
+ /**
+ * Alice receives a RENDEZVOUS_ESTABLISHED cell from a rendezvous point;
+ * this event is parsed from a log statement in
+ * rend_client_rendezvous_acked().
+ */
+ public static final HiddenServiceEventType ALICE_RENDEZVOUS_ESTABLISHED_RECEIVED = new HiddenServiceEventType(
+ "ALICE_RENDEZVOUS_ESTABLISHED_RECEIVED");
+
+ /**
+ * Alice has built a circuit to an introduction point (which does not
+ * automatically lead to sending an INTRODUCE1 cell, because the rendezvous
+ * circuit might not be ready); this event is parsed from a log statement in
+ * rend_client_introcirc_has_opened().
+ */
+ public static final HiddenServiceEventType ALICE_BUILT_INTRO_CIRC = new HiddenServiceEventType(
+ "ALICE_BUILT_INTRO_CIRC");
+
+ /**
+ * Alice sends an INTRODUCE1 cell to an introduction point; this event is
+ * parsed from a log statement in rend_client_send_introduction().
+ */
+ public static final HiddenServiceEventType ALICE_SENDING_INTRODUCE1 = new HiddenServiceEventType(
+ "ALICE_SENDING_INTRODUCE1");
+
+ /**
+ * Alice has received an INTRODUCE_ACK cell as an acknowledgement to a
+ * previously sent INTRODUCE1 cell; this event is parsed from a log
+ * statement in rend_client_introduction_acked().
+ */
+ public static final HiddenServiceEventType ALICE_INTRODUCE_ACK_RECEIVED = new HiddenServiceEventType(
+ "ALICE_INTRODUCE_ACK_RECEIVED");
+
+ /**
+ * Alice has received a RENDEZVOUS2 cell and can now open an application
+ * connection to the client; this event is parsed from a log statement in
+ * rend_client_receive_rendezvous().
+ */
+ public static final HiddenServiceEventType ALICE_RENDEZVOUS2_RECEIVED_APP_CONN_OPENED = new HiddenServiceEventType(
+ "ALICE_RENDEZVOUS2_RECEIVED_APP_CONN_OPENED");
+
+ /**
+ * Bob has built a circuit to an introduction point and sends an
+ * ESTABLISH_INTRO cell; this event is parsed from a log statement in
+ * rend_service_intro_has_opened().
+ */
+ public static final HiddenServiceEventType BOB_BUILT_INTRO_CIRC_SENDING_ESTABLISH_INTRO = new HiddenServiceEventType(
+ "BOB_BUILT_INTRO_CIRC_SENDING_ESTABLISH_INTRO");
+
+ /**
+ * Bob has received an INTRO_ESTABLISHED cell, i.e. a node has confirmed to
+ * work as introduction point; this event is parsed from a log statement in
+ * rend_service_intro_established().
+ */
+ public static final HiddenServiceEventType BOB_INTRO_ESTABLISHED_RECEIVED = new HiddenServiceEventType(
+ "BOB_INTRO_ESTABLISHED_RECEIVED");
+
+ /**
+ * Bob posts a hidden service descriptor to the directory servers; this
+ * event is parsed from a log statement in upload_service_descriptor().
+ */
+ public static final HiddenServiceEventType BOB_SENDING_PUBLISH_DESC = new HiddenServiceEventType(
+ "BOB_SENDING_PUBLISH_DESC");
+
+ /**
+ * Bob received a response from a directory server to a previous publish
+ * request; this event is parsed from a log statement in
+ * connection_dir_client_reached_eof().
+ */
+ public static final HiddenServiceEventType BOB_DESC_PUBLISHED_RECEIVED = new HiddenServiceEventType(
+ "BOB_DESC_PUBLISHED_RECEIVED");
+
+ /**
+ * Bob has received an INTRODUCE2 cell, i.e. a node wants to establish a
+ * connection, and will now try to establish a circuit to the client's
+ * rendezvous point; this event is parsed from a log statement in
+ * rend_service_introduce().
+ */
+ public static final HiddenServiceEventType BOB_INTRODUCE2_RECEIVED = new HiddenServiceEventType(
+ "BOB_INTRODUCE2_RECEIVED");
+
+ /**
+ * Bob has built a circuit to a rendezvous point and sends a RENDEZVOUS1
+ * cell; this event is parsed from a log statement in
+ * rend_service_rendezvous_has_opened().
+ */
+ public static final HiddenServiceEventType BOB_BUILT_REND_CIRC_SENDING_RENDEZVOUS1 = new HiddenServiceEventType(
+ "BOB_BUILT_REND_CIRC_SENDING_RENDEZVOUS1");
+
+ /**
+ * Bob opens a connection to the actual hidden server; this event is parsed
+ * from a log statement in connection_exit_begin_conn().
+ */
+ public static final HiddenServiceEventType BOB_APP_CONN_OPENED = new HiddenServiceEventType(
+ "BOB_APP_CONN_OPENED");
+
+ /**
+ * The directory server has received a descriptor post request; this event
+ * is parsed from a log statement in directory_handle_command_post().
+ */
+ public static final HiddenServiceEventType DIR_PUBLISH_DESC_RECEIVED = new HiddenServiceEventType(
+ "DIR_PUBLISH_DESC_RECEIVED");
+
+ /**
+ * The directory server has received a descriptor fetch request; this event
+ * is parsed from a log statement in directory_handle_command_get().
+ */
+ public static final HiddenServiceEventType DIR_FETCH_DESC_RECEIVED = new HiddenServiceEventType(
+ "DIR_FETCH_DESC_RECEIVED");
+
+ /**
+ * The node received an ESTABLISH_INTRO cell, i.e. was requested to work as
+ * introduction point, and replies with an INTRO_ESTABLISHED cell; this
+ * event is parsed from a log statement in rend_mid_establish_intro().
+ */
+ public static final HiddenServiceEventType IPO_RECEIVED_ESTABLISH_INTRO_SENDING_INTRO_ESTABLISHED = new HiddenServiceEventType(
+ "IPO_RECEIVED_ESTABLISH_INTRO_SENDING_INTRO_ESTABLISHED");
+
+ /**
+ * The introduction point received an INTRODUCE1 cell and reacts by sending
+ * an INTRODUCE2 cell to Bob and an INTRODUCE_ACK cell to Alice; this event
+ * is parsed from a log statement in rend_mid_introduce().
+ */
+ public static final HiddenServiceEventType IPO_RECEIVED_INTRODUCE1_SENDING_INTRODUCE2_AND_INTRODUCE_ACK = new HiddenServiceEventType(
+ "IPO_RECEIVED_INTRODUCE1_SENDING_INTRODUCE2_AND_INTRODUCE_ACK");
+
+ /**
+ * The node received an ESTABLISH_RENDEZVOUS cell, i.e. was requested to
+ * work as rendezvous point, and replies with a RENDEZVOUS_ESTABLISHED cell;
+ * this event is parsed from a log statement in
+ * rend_mid_establish_rendezvous().
+ */
+ public static final HiddenServiceEventType RPO_RECEIVED_ESTABLISH_RENDEZVOUS_SENDING_RENDEZVOUS_ESTABLISHED = new HiddenServiceEventType(
+ "RPO_RECEIVED_ESTABLISH_RENDEZVOUS_SENDING_RENDEZVOUS_ESTABLISHED");
+
+ /**
+ * The rendezvous point received a RENDEZVOUS1 cell and reacts by sending a
+ * RENDEZVOUS2 cell to Alice; this event is parsed from a log statement in
+ * rend_mid_rendezvous().
+ */
+ public static final HiddenServiceEventType RPO_RECEIVING_RENDEZVOUS1_SENDING_RENDEZVOUS2 = new HiddenServiceEventType(
+ "RPO_RECEIVING_RENDEZVOUS1_SENDING_RENDEZVOUS2");
+
+}
\ No newline at end of file
Deleted: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MiscEventType.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MiscEventType.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/MiscEventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2007, Karsten Loesing
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * * Neither the names of the copyright owners nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.uniba.wiai.lspi.puppetor;
-
-public class MiscEventType implements EventType {
-
- /**
- * The hidden service directory has stored a v2 descriptor; this event can
- * only be parsed from a log statement in a modified Tor!
- */
- public static final MiscEventType HSDIR_DESC_STORED = new MiscEventType();
-
- /**
- * The directory server has received a descriptor post request; this event
- * is parsed from a log statement in directory_handle_command_post().
- */
- public static final MiscEventType DIR_PUBLISH_DESC_RECEIVED = new MiscEventType();
-
- /**
- * The directory server has received a descriptor fetch request; this event
- * is parsed from a log statement in directory_handle_command_get().
- */
- public static final MiscEventType DIR_FETCH_DESC_RECEIVED = new MiscEventType();
-
- /**
- * The node received an ESTABLISH_INTRO cell, i.e. was requested to work as
- * introduction point, and replies with an INTRO_ESTABLISHED cell; this
- * event is parsed from a log statement in rend_mid_establish_intro().
- */
- public static final MiscEventType IPO_RECEIVED_ESTABLISH_INTRO_SENDING_INTRO_ESTABLISHED = new MiscEventType();
-
- /**
- * The introduction point received an INTRODUCE1 cell and reacts by sending
- * an INTRODUCE2 cell to Bob and an INTRODUCE_ACK cell to Alice; this event
- * is parsed from a log statement in rend_mid_introduce().
- */
- public static final MiscEventType IPO_RECEIVED_INTRODUCE1_SENDING_INTRODUCE2_AND_INTRODUCE_ACK = new MiscEventType();
-
- /**
- * The node received an ESTABLISH_RENDEZVOUS cell, i.e. was requested to
- * work as rendezvous point, and replies with an RENDEZVOUS_ESTABLISHED
- * cell; this event is parsed from a log statement in
- * rend_mid_establish_rendezvous().
- */
- public static final MiscEventType RPO_RECEIVED_ESTABLISH_RENDEZVOUS_SENDING_RENDEZVOUS_ESTABLISHED = new MiscEventType();
-
- /**
- * The rendezvous point received a RENDEZVOUS1 cell and reacts by sending a
- * RENDEZVOUS2 cell to Alice; this event is parsed from a log statement in
- * rend_mid_rendezvous().
- */
- public static final MiscEventType RPO_RECEIVING_RENDEZVOUS1_SENDING_RENDEZVOUS2 = new MiscEventType();
-}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -32,13 +32,9 @@
package de.uniba.wiai.lspi.puppetor;
import java.io.File;
-import java.net.MalformedURLException;
-import java.rmi.NotBoundException;
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
@@ -53,76 +49,119 @@
/**
* <p>
- * Configures the nodes in this network so that they can run in a private
- * network and don't require public directory servers or onion routers from
- * the Internet. This configuration should be done after configuring the
- * nodes and before writing configurations to disk. This operation can only
- * be invoked, if network status is
- * <code>NetworkState.CONFIGURING_NODES</code>.
+ * Configures this network as private Tor network by exchanging directory
+ * strings and router fingerprints between the nodes of this network.
+ * Afterwards, the nodes will be able to run a private Tor network,
+ * separated from public directory servers and onion routers.
* </p>
*
* <p>
- * The main requirement for this method lies in the fact that all nodes need
- * to be configured so that they accept our own directory nodes instead of
- * the pre-configured directory nodes from the public Tor network. This
- * configuration requires the fingerprints of all directory nodes. These
- * fingerprints are written to disk by the directory nodes as soon as they
- * are started. But the directories need to be configured before being
- * started, too, in order to prevent them from becoming part of the public
- * Tor network. And now we have the chicken or the egg dilemma.
+ * The configuration is done in two steps:
+ * <ol>
+ * <li>Directory strings of directory nodes are added to the configurations
+ * of all nodes in the other network.</li>
+ * <li>Router fingerprints of all router and directory nodes are added to
+ * the <code>approved-routers</code> files of the directory nodes.</li>
+ * </ol>
* </p>
*
* <p>
- * The non-trivial solution is to configure the directory nodes with a fake
- * directory configuration and start them using the
- * <code>--list-fingerprint</code> option. Hence they write a
- * <code>fingerprint</code> file to disk and shut down immediately. This
- * fingerprint can be read, and all nodes can be configured to use the
- * directory using this fingerprint.
+ * This operation may be invoked in any state of the contained nodes.
+ * However, a network that does not have directory nodes of its own but
+ * relies on directory nodes of a merged network <b>should not be started
+ * before being configured as private network!</b> Otherwise it would
+ * connect to the public Tor network before being merged with the other
+ * private Tor network. However, it may also be invoked at a later time,
+ * e.g. to admit new nodes.
* </p>
*
* <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 <code>approved-routers</code>
- * file in the working directory of the directory node.
+ * This operation does not write any configurations to disk and neither
+ * starts a nodes nor sends HUP signals to running nodes. These operations
+ * are left to the application, so that they have more control over the
+ * network behavior.
* </p>
*
* <p>
- * The complete task is encapsulated in this method for convenience.
- * However, all operations could also be performed directly on the nodes, if
- * required.
+ * Applications need to ensure that there are enough directory nodes (2) and
+ * router nodes (3) in the network to allow normal operation.
* </p>
*
- * TODO check if we have enough directory and router nodes to build a
- * private network? How many are required? 2 dirs and 3 routers?
+ * @throws PuppeTorException
+ * Thrown if an I/O problem occurs while determining the nodes'
+ * fingerprints.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public abstract void configureAsPrivateNetwork() throws PuppeTorException,
+ RemoteException;
+
+ /**
+ * <p>
+ * Merges this network with another private Tor network by exchanging
+ * directory strings and router fingerprints. Afterwards, the nodes in both
+ * networks will consider the two networks a single, larger private Tor
+ * network.
+ * </p>
*
- * @throws IllegalStateException
- * Thrown if network is not in state
- * <code>NetworkState.CONFIGURING_NODES</code>.
- * @throws TorProcessException
- * Thrown if an I/O problem occurs while starting nodes with the
- * <code>--list-fingerprint</code> option, reading files from
- * the nodes' working directories, or writing the
- * <code>approved-routers</code> files.
+ * <p>
+ * The configuration is done in two steps:
+ * <ol>
+ * <li>Directory strings of all directory nodes in this network are added
+ * to the configurations of all nodes in the other network and vice versa.</li>
+ * <li>Router fingerprints of all router and directory nodes in this
+ * network are added to the <code>approved-routers</code> files of all
+ * directory nodes in the other network and vice versa.</li>
+ * </ol>
+ * </p>
+ *
+ * <p>
+ * This operation may be invoked in any state of the contained nodes.
+ * However, a network that does not have directory nodes of its own but
+ * relies on directory nodes of a merged network <b>should not be started
+ * before merging!</b> Otherwise it would connect to the public Tor network
+ * before being merged with the other private Tor network. However, it may
+ * also be invoked at a later time, e.g. to admit new nodes.
+ * </p>
+ *
+ * <p>
+ * This operation does not write any configurations to disk and neither
+ * starts a nodes nor sends HUP signals to running nodes. These operations
+ * are left to the application, so that they have more control over the
+ * network behavior.
+ * </p>
+ *
+ * <p>
+ * Note that this operation is only effective if there are directory nodes
+ * in either of the two networks. Otherwise, no information will be
+ * exchanged between the two networks. Applications need to ensure that
+ * there are in total enough directory nodes (2) and router nodes (3) in
+ * both networks to allow normal operation.
+ * </p>
+ *
+ * @param remoteNetwork
+ * The remote network to merge this network with.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
+ * @throws PuppeTorException
+ * Thrown if an I/O problem occurs while reading directory
+ * strings or router fingerprints, while writing the new
*/
- public abstract void configureAsPrivateNetwork()
- throws TorProcessException, RemoteException;
+ public abstract void configureAsInterconnectedPrivateNetwork(
+ Network remoteNetwork) throws RemoteException, PuppeTorException;
/**
* Creates a new client application, but does not yet perform a request.
*
* @param clientApplicationName
* The name for this client application, which is used for
- * logging purposes only. May neither be <code>null</code> or a
- * zero-length string. The name needs to be unique in this
- * network.
+ * logging purposes and as event source. May neither be
+ * <code>null</code> or a zero-length string. The name needs to
+ * be unique in this network.
* @param targetAddress
* The target for requests sent by this client application. Can
- * be an IP address, a domain name, or an onion address. May
- * neither be <code>null</code> or a zero-length string.
+ * be a publicly available URL or an onion address. May neither
+ * be <code>null</code> or a zero-length string.
* @param targetPort
* The TCP port for requests sent by this client application. If
* the target address is an onion address, this port is the
@@ -146,19 +185,15 @@
/**
* Creates a new directory node 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. This operation can only be invoked,
- * if network status is <code>NetworkState.CONFIGURING_NODES</code>.
+ * 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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
* @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.
* @throws RemoteException
@@ -171,23 +206,19 @@
* 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>.
+ * 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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
* @throws RemoteException
@@ -199,15 +230,13 @@
/**
* 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
- * <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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
@@ -224,9 +253,6 @@
* for incoming directory requests. May not be negative or
* greater than 65535.
* @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.
@@ -240,15 +266,14 @@
/**
* 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>.
+ * 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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
@@ -269,9 +294,6 @@
* 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.
@@ -288,10 +310,11 @@
* disk or start the corresponding Tor process.
*
* @param nodeName
- * The name for this node, which is only used as name for the
- * working directory and for logging purposes. 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.
+ * The name for this node, which is used as name for the working
+ * directory, for logging purposes, and as event source. 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.
* @return Reference to the created proxy node.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
@@ -307,10 +330,11 @@
* Tor process.
*
* @param nodeName
- * The name for this node, which is only used as name for the
- * working directory and for logging purposes. 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.
+ * The name for this node, which is used as name for the working
+ * directory, for logging purposes, and as event source. 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.
@@ -335,10 +359,10 @@
*
* @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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
* @return Reference to the created router node.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as node name.
@@ -355,10 +379,10 @@
*
* @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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
@@ -393,10 +417,10 @@
*
* @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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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
@@ -417,10 +441,10 @@
*
* @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.
+ * directory, for logging purposes, as node nickname, and as
+ * event source. 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.
@@ -458,9 +482,9 @@
*
* @param serverApplicationName
* The name for this server application, which is used for
- * logging purposes only. May neither be <code>null</code> or a
- * zero-length string. The name needs to be unique in this
- * network.
+ * logging purposes and as event source. May neither be
+ * <code>null</code> or a zero-length string. The name needs to
+ * be unique in this network.
* @return Reference to the created server application.
* @throws IllegalArgumentException
* Thrown if an invalid value is given as server application
@@ -477,9 +501,9 @@
*
* @param serverApplicationName
* The name for this server application, which is used for
- * logging purposes only. May neither be <code>null</code> or a
- * zero-length string. The name needs to be unique in this
- * network.
+ * logging purposes and as event source. May neither be
+ * <code>null</code> or a zero-length string. The name needs to
+ * be unique in this network.
* @param serverPort
* The TCP port on which the server will wait for incoming
* requests. May not be negative or greater than 65535.
@@ -504,15 +528,6 @@
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() throws RemoteException;
-
- /**
* Returns (a copy of) the map containing the names of all directory nodes
* as keys and the corresponding directory nodes as values.
*
@@ -528,65 +543,46 @@
* (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;
+ public abstract 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 Map<String, ProxyNode> getAllProxyNodes()
throws RemoteException;
/**
- * Returns the <code>RouterNode</code> with name <code>nodeName</code>
- * or <code>null</code> if no such node exists.
+ * Returns (a copy of) the map containing the names of all nodes as keys and
+ * the corresponding proxy nodes as values.
*
- * @param nodeName
- * The node name to look up.
- * @return The <code>RouterNode</code> with name <code>nodeName</code>.
+ * @return Map containing all nodes.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract RouterNode getRouterNode(String nodeName)
- throws RemoteException;
+ public abstract Map<String, ProxyNode> getAllNodes() throws RemoteException;
/**
- * Returns the <code>DirectoryNode</code> with name <code>nodeName</code>
- * or <code>null</code> if no such node exists.
+ * Returns the node 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>.
+ * @return The node with name <code>nodeName</code>.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract DirectoryNode getDirectoryNode(String nodeName)
- throws RemoteException;
+ public abstract ProxyNode getNode(String nodeName) throws RemoteException;
/**
* <p>
@@ -596,37 +592,37 @@
* </p>
*
* <p>
- * First, the method waits for <code>hupInterval</code> millis for the
- * nodes to have successfully opened a circuit. If they do not succeed
+ * First, the method waits for <code>hupInterval</code> milliseconds for
+ * the nodes to have successfully opened a circuit. If they do not succeed
* within this time, a HUP signal is sent to all nodes and the method waits
- * for another <code>hupInterval</code> millis. In total, the method sends
- * at most <code>tries</code> HUP signals before giving up and returning
- * with <code>false</code>. Thus, the maximum waiting time is
+ * for another <code>hupInterval</code> milliseconds. In total, the method
+ * sends at most <code>tries</code> HUP signals before giving up and
+ * returning with <code>false</code>. Thus, the maximum waiting time is
* <code>(tries + 1)</code> times <code>hupInterval</code>. As soon as
* all nodes have successfully opened circuits, the method returns with
- * <code>true</code>. This operation can only be invoked, if network
- * status is <code>NetworkState.NODES_STARTED</code>.
+ * <code>true</code>. This operation can only be invoked, if all nodes in
+ * the network are in state <code>NodeState.RUNNING</code>.
* </p>
*
* @param tries
* The maximum number of HUP signals that are sent to the Tor
* processes. Negative values are not allowed. A value of zero
* means to wait only for the given time of
- * <code>hupInterval</code> millis without sending a HUP
+ * <code>hupInterval</code> milliseconds without sending a HUP
* signal. Typical values depend on the network being a public or
* private Tor network and range about 3 to 5 tries.
* @param hupInterval
- * The time in millis that the method will wait between sending
- * HUP signals. Negative values are not allowed. Typically,
- * values should not be smaller than 10 seconds to permit Tor to
- * stabilize.
+ * The time in milliseconds that the method will wait between
+ * sending HUP signals. Negative values are not allowed.
+ * Typically, values should not be smaller than 5 seconds to
+ * permit Tor to stabilize.
* @throws IllegalStateException
- * Thrown if network is not in state
- * <code>NetworkState.NODES_STARTED</code>.
+ * Thrown if at least one node is not in state
+ * <code>NodeState.RUNNING</code>.
* @throws IllegalArgumentException
* Thrown if a negative value is given for either
* <code>tries</code> or <code>hupInterval</code>.
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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.
@@ -634,35 +630,48 @@
* Thrown if an error occurs when accessed remotely.
*/
public abstract boolean hupUntilUp(int tries, long hupInterval)
- throws TorProcessException, RemoteException;
+ throws PuppeTorException, RemoteException;
/**
+ * Sends a HUP signal to all nodes in the network once. This operation can
+ * only be invoked, if all nodes in the network are in state
+ * <code>NodeState.RUNNING</code>.
+ *
+ * @throws IllegalStateException
+ * Thrown if at least one node is not in state
+ * <code>NodeState.RUNNING</code>.
+ * @throws PuppeTorException
+ * Thrown if an I/O problem occurs while sending HUP signals.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public abstract void hupAllNodes() throws PuppeTorException,
+ RemoteException;
+
+ /**
* Attempts to shut down all running nodes. The method blocks until all
* shutdown requests have been sent and either returns, or throws the first
* exception that has been observed when shutting down nodes. The method can
- * be assumed to return very quickly. This operation can only be invoked, if
- * network status is <code>NetworkState.NODES_STARTED</code>.
+ * be assumed to return very quickly. If there are no running nodes in this
+ * network, this operation has no effect.
*
- * @throws IllegalStateException
- * Thrown if network is not in state
- * <code>NetworkState.NODES_STARTED</code>.
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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 PuppeTorException,
RemoteException;
/**
* Attempts to start all nodes within a given timeout of
- * <code>maximumTimeToWaitInMillis</code> millis. The method returns as
- * soon as all nodes have started and opened their control port so that we
- * can connect to them. It returns a boolean that states whether the
+ * <code>maximumTimeToWaitInMillis</code> milliseconds. The method returns
+ * as soon as all nodes have started and opened their control port so that
+ * we can connect to them. It returns a boolean that states whether the
* operation was either successful or has timed out. This operation can only
- * be invoked, if network status is
- * <code>NetworkState.CONFIGURATIONS_WRITTEN</code>.
+ * be invoked, if all nodes in the network have written their configuration,
+ * i.e. are not in state <code>NodeState.CONFIGURING</code> anymore.
*
* @param maximumTimeToWaitInMillis
* The maximum time to wait in milliseconds. A positive value or
@@ -670,41 +679,39 @@
* allowed. Typical values are in the range of a few seconds.
* @return <code>true</code> if all nodes could be started successfully,
* <code>false</code> if a timeout has occured.
+ * @throws IllegalStateException
+ * Thrown if at least one node in the network is still in state
+ * <code>NodeState.CONFIGURING</code>.
* @throws IllegalArgumentException
* Thrown if a negative value is given for
* <code>maximumTimeToWaitInMillis</code>.
- * @throws IllegalStateException
- * Thrown if network is not in state
- * <code>NetworkState.CONFIGURATIONS_WRITTEN</code>.
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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, RemoteException;
+ throws PuppeTorException, RemoteException;
/**
* Writes the configurations for all nodes in the network to disk, including
* <code>torrc</code> and <code>approved-routers</code> files. This
* method is assumed to return very quickly. In case of a private network,
- * <code>configureAsPrivateNetwork</code> must be invoked in advance to
- * this method! If network status is
- * <code>NetworkState.CONFIGURING_NODES</code>, it will be changed to
- * <code>NetworkState.CONFIGURATIONS_WRITTEN</code>.
+ * <code>configureAsPrivateNetwork</code> should be invoked in advance to
+ * this method!
*
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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 PuppeTorException,
RemoteException;
/**
* Returns the working directory of this network configuration which is in
- * test-env/networkName/.
+ * <code>test-env/networkName/</code>.
*
* @return Working directory of this network.
* @throws RemoteException
@@ -713,100 +720,43 @@
public abstract File getWorkingDirectory() throws RemoteException;
/**
- * Returns whether all nodes in this network are up, or not.
+ * Adds a configuration string to the template of a node class, so that it
+ * will be added to future instances of this node class and its subclasses.
*
- * @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.
+ * @param nodeClass
+ * The class of nodes of which future instances will have the
+ * given configuration string.
+ * @param templateConfigurationString
+ * The configuration string.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract void addDirectoryStrings(List<String> dirServerStrings)
- throws RemoteException, TorProcessException;
+ public abstract void addTemplateConfiguration(
+ Class<? extends ProxyNode> nodeClass,
+ String templateConfigurationString) throws RemoteException;
/**
- * Appends the fingerprints of the given routers to the approved routers
- * file of all directory nodes of this network, thereby approving these
- * router nodes.
+ * Returns the name of this network.
*
- * 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.
+ * @return The name of this 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;
+ public abstract String getNetworkName() throws RemoteException;
/**
- * TODO Unconfirmed!
+ * Binds the network at the local <code>rmiregistry</code> to make it
+ * remotely available and returns whether binding was successful.
*
- * Enables to bind a network to the groovy shell.
- *
- * @param remoteHost
- * The IpAddress where the RMI registry is running.
- * @param bindingName
- * The name whereby the stub is bound.
- * @return Network Stub
- * @throws MalformedURLException
- * Thrown to indicate that a malformed URL has occurred. Either
- * no legal protocol could be found in a specification string or
- * the string could not be parsed.
+ * @return <code>true</code> if binding was successful, <code>false</code>
+ * otherwise.
+ * @throws PuppeTorException
+ * Thrown if an error occurs while binding to the
+ * <code>rmiregistry</code>.
* @throws RemoteException
- * Thrown if an error occurs when accessed remotely.
- * @throws NotBoundException
- * A NotBoundException is thrown if an attempt is made to lookup
- * or unbind in the registry a name that has no associated
- * binding.
+ * Thrown if an error occurs when accessed remotely (though this
+ * might never happen as the object is not bound, yet).
*/
- public abstract Network connectNetwork(String remoteHost, String bindingName)
- throws MalformedURLException, RemoteException, NotBoundException;
+ public abstract boolean bindAtRmiregistry() throws RemoteException;
- /**
- * TODO Unconfirmed!
- *
- * Merges two separate networks.
- *
- * @param remoteNetwork
- * The stub of the network to merge.
- * @throws RemoteException
- * Thrown if an error occurs when accessed remotely.
- */
- public abstract void mergeNetworks(Network remoteNetwork)
- throws RemoteException;
-
- /**
- * Adds a configuration string to the template of a node class, so that it
- * will be added to future instances of this node class.
- *
- * @param nodeClass
- * The class of nodes of which future instances will have the
- * given configuration string.
- * @param templateConfigurationString
- * The configuration string.
- * @throws RemoteException
- * Thrown if an error occurs when accessed remotely.
- */
- public abstract void addTemplateConfiguration(
- Class<? extends ProxyNode> nodeClass,
- String templateConfigurationString) throws RemoteException;
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkFactory.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -31,12 +31,15 @@
*/
package de.uniba.wiai.lspi.puppetor;
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import de.uniba.wiai.lspi.puppetor.impl.NetworkImpl;
/**
- * The <code>NetworkFactory</code> is an abstract factory that can create
+ * The <code>NetworkFactory</code> is a concrete factory that can create
* <code>Network</code> instances.
*
* TODO At the moment, this class uses the concrete class NetworkImpl to
@@ -53,7 +56,8 @@
/**
* Creates a new network that is required for a test run. The new network is
* initially unpopulated and creates its own working directory at
- * test-env/randomTestID/.
+ * test-env/randomTestID/. The network automatically assigns port numbers to
+ * newly created nodes starting at <code>7000</code>.
*
* @param networkName
* Name of this network configuration.
@@ -69,14 +73,18 @@
/**
* Creates a new network that is required for a test run. The new network is
* initially unpopulated and creates its own working directory at
- * test-env/randomTestID/.
+ * test-env/randomTestID/. The network automatically assigns port numbers to
+ * newly created nodes starting at <code>startPort</code>.
*
* @param networkName
* Name of this network configuration.
* @param startPort
* The initial value for automatically assigned port numbers of
* nodes created by this <code>Network</code>; must be a value
- * between 1024 and 65535.
+ * between <code>1024</code> and <code>65535</code>.
+ * Applications need to ensure that there are enough ports left
+ * to the maximum number port <code>65535</code> for all
+ * created nodes.
* @return A new network instance.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
@@ -85,4 +93,37 @@
throws RemoteException {
return new NetworkImpl(networkName, startPort);
}
+
+ /**
+ * Connects to a remote network and returns a reference on it.
+ *
+ * @param remoteHost
+ * The IP address and port of the remote <code>rmiregistry</code>.
+ * @param bindingName
+ * The name under which the other network is bound at the remote
+ * <code>rmiregistry</code>.
+ * @return Reference on the remote network.
+ * @throws PuppeTorException
+ * Thrown if an error occurs when looking up the remote network
+ * at the remote <code>rmiregistry</code>.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public static Network connectToNetwork(String remoteHost, String bindingName)
+ throws PuppeTorException, RemoteException {
+ Network remoteNetwork = null;
+ try {
+ remoteNetwork = (Network) Naming.lookup("rmi://" + remoteHost + "/"
+ + bindingName);
+ } catch (MalformedURLException e) {
+ PuppeTorException ex = new PuppeTorException(
+ "Cannot connect to remote network!", e);
+ throw ex;
+ } catch (NotBoundException e) {
+ PuppeTorException ex = new PuppeTorException(
+ "Cannot connect to remote network!", e);
+ throw ex;
+ }
+ return remoteNetwork;
+ }
}
Deleted: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkState.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkState.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NetworkState.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2007, Karsten Loesing
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * * Neither the names of the copyright owners nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.uniba.wiai.lspi.puppetor;
-
-/**
- * The <code>NetworkState</code> constitutes the single state of a network
- * that is the result of the <code>NodeState</code>s of all nodes in the
- * network. In contrast to <code>EventType</code> the network (and node)
- * states depend only on the methods that have been invoked on these objects,
- * and not on asynchronous state changes. Most operations of
- * <code>Network</code> require a certain <code>NetworkState</code> as
- * precondition and may ensure another <code>NetworkState</code> as
- * postcondition. There is a prescribed order of states.
- *
- * @author kloesing
- */
-public enum NetworkState {
-
- /**
- * The configurations of the nodes in the network have not been written to
- * disk and can be changed. This is the initial state of a
- * <code>Network</code>.
- */
- CONFIGURING_NODES,
-
- /**
- * The configurations of all nodes in the network have been written to disk
- * and cannot be changed anymore, but the Tor processes have not been
- * started, yet. This state could be useful to review the configurations
- * that have been written to disk.
- */
- CONFIGURATIONS_WRITTEN,
-
- /**
- * The nodes in the network have been started and are running.
- */
- NODES_STARTED,
-
- /**
- * The nodes in the network had been started and shut down.
- */
- NODES_SHUT_DOWN
-
-}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeEventType.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeEventType.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeEventType.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -31,36 +31,55 @@
*/
package de.uniba.wiai.lspi.puppetor;
-public class NodeEventType implements EventType{
+/**
+ * Event types that can be fired by all Tor processes.
+ */
+public class NodeEventType implements EventType {
/**
- * The node has reported that its routing table for v2 hidden services has
- * changed; this event can only be parsed from a log statement in a modified
- * Tor!
+ * String identifying the type of the event type.
*/
- public static final NodeEventType NODE_ROUTING_TABLE_CHANGED = new NodeEventType();
-
+ String typeString;
+
/**
+ * Creates a new event type with the given type string.
+ *
+ * @param typeString
+ * String identifying the type of the event type.
+ */
+ public NodeEventType(String typeString) {
+ this.typeString = typeString;
+ }
+
+ public String getTypeName() {
+ return this.typeString;
+ }
+
+ /**
* The node was started and we managed to connect to its control port; this
* event is fired internally and not parsed from a log statement from Tor.
*/
- public static final NodeEventType NODE_STARTED = new NodeEventType();
-
+ public static final NodeEventType NODE_STARTED = new NodeEventType(
+ "NODE_STARTED");
+
/**
* The node has opened its control port; this event is parsed from a log
* statement in connection_create_listener().
*/
- public static final NodeEventType NODE_CONTROL_PORT_OPENED = new NodeEventType();
-
+ public static final NodeEventType NODE_CONTROL_PORT_OPENED = new NodeEventType(
+ "NODE_CONTROL_PORT_OPENED");
+
/**
* The node which has successfully opened a circuit; this event is parsed
* from a log statement in circuit_send_next_onion_skin().
*/
- public static final NodeEventType NODE_CIRCUIT_OPENED = new NodeEventType();
-
+ public static final NodeEventType NODE_CIRCUIT_OPENED = new NodeEventType(
+ "NODE_CIRCUIT_OPENED");
+
/**
* The node was stopped; this event is fired internally and not parsed from
* a log statement from Tor.
*/
- public static final NodeEventType NODE_STOPPED = new NodeEventType();
+ public static final NodeEventType NODE_STOPPED = new NodeEventType(
+ "NODE_STOPPED");
}
\ No newline at end of file
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeState.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeState.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/NodeState.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -33,29 +33,27 @@
/**
* The <code>NodeState</code> constitutes the state of a single Tor node. In
- * contrast to <code>EventType</code> the node (and network) states depend
- * only on the methods that have been invoked on these objects, and not on
- * asynchronous state changes. Most operations of <code>ProxyNode</code> and
- * its subclasses require a certain <code>NodeState</code> as precondition and
- * may ensure another <code>NodeState</code> as postcondition. There is a
- * prescribed order of states.
+ * contrast to <code>EventType</code> the node states depend only on the
+ * methods that have been invoked on these objects, and not on asynchronous
+ * state changes. Most operations of <code>ProxyNode</code> and its subclasses
+ * require a certain <code>NodeState</code> as precondition and may ensure
+ * another <code>NodeState</code> as postcondition. There is a prescribed
+ * order of states.
*
* @author kloesing
*/
public enum NodeState {
/**
- * The configuration of this node has not been written to disk and can be
- * changed. This is the initial state of a <code>ProxyNode</code> or one
- * of its subclasses.
+ * The configuration of this node has not been written to disk. This is the
+ * initial state of a <code>ProxyNode</code> or one of its subclasses.
*/
CONFIGURING,
/**
- * The configuration of this node has been written to disk and cannot be
- * changed anymore, but the Tor process has not been started, yet. This
- * state could be useful to review the configuration that has been written
- * to disk.
+ * The configuration of this node has been written to disk, but the Tor
+ * process has not been started, yet. This state could be useful to review
+ * the configuration that has been written to disk.
*/
CONFIGURATION_WRITTEN,
@@ -65,7 +63,8 @@
RUNNING,
/**
- * The node had been started and shut down.
+ * The node had been started and shut down. It cannot be started at a later
+ * time anymore.
*/
SHUT_DOWN
}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -34,7 +34,6 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;
-import java.util.Set;
/**
* <p>
@@ -64,9 +63,9 @@
* <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>
- * <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>
+ * <li>change the constants <code>ESTIMATED_PROPAGATION_TIME</code> and
+ * <code>NETWORKSTATUS_CLIENT_DL_INTERVAL</code> in Tor to values smaller than
+ * your overall HUP time for starting the network.</li>
* </ul>
*
* @author kloesing
@@ -75,12 +74,7 @@
/**
* Adds the entries for a hidden service to the configuration of this node.
- * This method can only be invoked while the node is in state
- * <code>NodeState.CONFIGURING</code>.
*
- * TODO Should this operation also be possible while the process is running?
- * We could easily change the configuration via the controller.
- *
* @param serviceName
* Name of the hidden service that will be used as name for the
* hidden service directory. May neither be <code>null</code>
@@ -94,37 +88,60 @@
* The virtual TCP port that this hidden service runs on as it is
* announced to clients. May not be negative or greater than
* 65535.
- * @throws IllegalStateException
- * Thrown if node is not in state
- * <code>NodeState.CONFIGURING</code>.
+ * @return <code>HiddenService</code> object containing the configuration
+ * of the created hidden service.
* @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) throws RemoteException;
+ public abstract HiddenService addHiddenService(String serviceName,
+ int servicePort, int virtualPort) throws RemoteException;
/**
- * Adds the given set of DirServer configuration entries to the
- * configuration of this node. Note that as soon as one DirServer is
- * configured, the node does not connect to an outside directory server of
- * the public network any more!
+ * Adds the entries for a hidden service with virtual port 80 to the
+ * configuration of this node.
*
- * TODO allow invocation of this method only in correct state
+ * @param serviceName
+ * Name of the hidden service that will be used as name for the
+ * hidden service directory. May neither be <code>null</code>
+ * or a zero-length string.
+ * @param servicePort
+ * The TCP port on which the service will be available for
+ * requests. This can, but need not be different from the virtual
+ * port that is announced to clients. May not be negative or
+ * greater than 65535.
+ * @return <code>HiddenService</code> object containing the configuration
+ * of the created hidden service.
+ * @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 HiddenService addHiddenService(String serviceName,
+ int servicePort) throws RemoteException;
+
+ /**
+ * Adds the entries for a hidden service with an automatically assigned
+ * service port and virtual port 80 to the configuration of this node.
*
- * @param authorizedDirServerStrings
- * A set of DirServer configuration entries that each contain one
- * directory server that this node shall connect to. May not be
- * <code>null</code>, but may be an empty set.
+ * service port automatically assigned virtual port 80
+ *
+ * @param serviceName
+ * Name of the hidden service that will be used as name for the
+ * hidden service directory. May neither be <code>null</code>
+ * or a zero-length string.
+ * @return <code>HiddenService</code> object containing the configuration
+ * of the created hidden service.
* @throws IllegalArgumentException
- * Thrown if <code>null</code> is passed as parameter.
+ * Thrown if an invalid value is given for the parameter.
* @throws RemoteException
* Thrown if an error occurs when accessed remotely.
*/
- public abstract void configureDirServers(
- Set<String> authorizedDirServerStrings) throws RemoteException;
+ public abstract HiddenService addHiddenService(String serviceName)
+ throws RemoteException;
/**
* Adds the given configuration string, consisting of "<configuration key>
@@ -165,17 +182,14 @@
* <code>configurationString</code> by this new configuration string; if
* multiple occurrences of the given configuration key are found, only the
* first occurrence is replaced; if no configuration can be found, the
- * configuration string is added.
+ * configuration string is appended.
*
* @param configurationString
* The replacing configuration string.
* @throws IllegalArgumentException
- * Thrown if the given configurationString is either
+ * Thrown if the given configuration string 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.
*/
@@ -183,6 +197,22 @@
throws RemoteException;
/**
+ * Removes all configuration strings containing the given configuration key
+ * in "<configuration key> <configuration value>", regardless of their
+ * configuration value.
+ *
+ * @param configurationKey
+ * The configuration key to remove.
+ * @throws IllegalArgumentException
+ * Thrown if the given configuration key is either
+ * <code>null</code> or a zero-length key.
+ * @throws RemoteException
+ * Thrown if an error occurs when accessed remotely.
+ */
+ public abstract void deleteConfiguration(String configurationKey)
+ throws RemoteException;
+
+ /**
* Returns the name of this node.
*
* @return The name of this node.
@@ -201,48 +231,18 @@
public abstract NodeState getNodeState() throws RemoteException;
/**
- * Determines the onion address for a previously added hidden service with
- * name <code>serviceName</code>. Requires that the node has been
- * started, i.e. is in state <code>NodeState.RUNNING</code>.
- *
- * @param serviceName
- * Name of the hidden service that has been used before to add
- * the hidden service. May neither be <code>null</code> or a
- * zero-length string.
- * @param version
- * Hidden service version; can be either 0, 1, or 2. Note that
- * version 2 may not be implemented in the regular Tor sources!
- * @return The onion address string consisting of 16 base32 chars plus
- * ".onion" for hidden service versions 0 and 1 or 16 base32 chars
- * plus "." plus 24 base32 chars plus ".onion" for hidden service
- * version 2.
- * @throws IllegalArgumentException
- * Thrown if <code>null</code> or a zero-length string is
- * passed as parameter.
- * @throws TorProcessException
- * Thrown if either there does not exist a hidden service with
- * 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, RemoteException;
-
- /**
* Sends a HUP command to the process via its control port to restart it;
* can only be done if the node has already been started, i.e. is in state
* <code>NodeState.RUNNING</code>!
*
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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, RemoteException;
+ public abstract void hup() throws PuppeTorException, RemoteException;
/**
* Shuts down the Tor process corresponding to this node immediately. This
@@ -253,13 +253,13 @@
* @throws IllegalStateException
* Thrown if this node is not in state
* <code>NodeState.RUNNING</code>.
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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, RemoteException;
+ public abstract void shutdown() throws PuppeTorException, RemoteException;
/**
* Starts the Tor process for this node and connects to the control port as
@@ -269,12 +269,9 @@
* output is parsed to see when the control port is opened.</b>
*
* @param maximumTimeToWaitInMillis
- * Maximum time in millis we will wait for the Tor process to be
- * started and the control port being opened. If this value is
- * negative or zero, we will wait potentially forever. TODO
- * should we normalize behavior for negative timeouts to either
- * throw an exception or wait forever consistently for the whole
- * framework?
+ * Maximum time in milliseconds we will wait for the Tor process
+ * to be started and the control port being opened. If this value
+ * is negative or zero, we will wait potentially forever.
* @return <code>true</code> if the node could be started successfully,
* <code>false</code> otherwise.
* @throws IllegalStateException
@@ -282,14 +279,14 @@
* <code>NodeState.CONFIGURATION_WRITTEN</code>, i.e. if
* either configuration has not been written or the process has
* already been started.
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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, RemoteException;
+ throws PuppeTorException, RemoteException;
/**
* Writes the configuration of this node to the <code>torrc</code> file in
@@ -297,13 +294,13 @@
* <code>NodeState.CONFIGURATION_WRITTEN</code>, if it was in state
* <code>NodeState.CONFIGURING</code> before.
*
- * @throws TorProcessException
+ * @throws PuppeTorException
* 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 PuppeTorException,
RemoteException;
/**
Copied: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/PuppeTorException.java (from rev 11669, puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/TorProcessException.java)
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/PuppeTorException.java (rev 0)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/PuppeTorException.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2007, Karsten Loesing
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the names of the copyright owners nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package de.uniba.wiai.lspi.puppetor;
+
+/**
+ * The <code>PuppeTorException</code> comprises all kinds of checked
+ * exceptions that occur when interacting with the JVM-external Tor processes or
+ * with the local file system. Any occurence of this exception denotes either a
+ * configuration problem that can only be solved outside of the JVM, or an
+ * unexpected problem. In contrast to this, all kinds of programming errors of
+ * an application using this API (invoking a method with wrong parameter values,
+ * in wrong state, etc.) will instead cause appropriate runtime exceptions from
+ * the Java API.
+ *
+ * @author kloesing
+ */
+@SuppressWarnings("serial")
+public class PuppeTorException extends Exception {
+
+ /**
+ * Creates a <code>PuppeTorException</code> without detail message or
+ * cause.
+ */
+ public PuppeTorException() {
+ super();
+ }
+
+ /**
+ * Creates a <code>PuppeTorException</code> with the given detail
+ * <code>message</code> and <code>cause</code>.
+ *
+ * @param message
+ * The detail message of this exception.
+ * @param cause
+ * The cause for this exception.
+ */
+ public PuppeTorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates a <code>PuppeTorException</code> with the given detail
+ * <code>message</code>, but without a <code>cause</code>.
+ *
+ * @param message
+ * The detail message of this exception.
+ */
+ public PuppeTorException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a <code>PuppeTorException</code> with the given
+ * <code>cause</code>, but without a detail message.
+ *
+ * @param cause
+ * The cause for this exception.
+ */
+ public PuppeTorException(Throwable cause) {
+ super(cause);
+ }
+}
Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java 2007-10-01 16:25:45 UTC (rev 11735)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/RouterNode.java 2007-10-01 21:59:35 UTC (rev 11736)
@@ -45,64 +45,6 @@
public interface RouterNode extends ProxyNode {
/**
- * <p>
- * Determines the directory fingerprint of this node. If the Tor process has
- * not been started before, it is started and immediately stopped
- * afterwards, so that the Tor process creates a new onion key pair and
- * fingerprint for it. This is done using a temporary configuration file and
- * with the command-line option <code>--list-fingerprint</code>. Tor then
- * generates a new onion key and writes its fingerprint to the
- * <code>fingerprint</code> file in its working directory, but does not
- * start routing traffic.
- * </p>
- *
- * <p>
- * The temporary <code>torrc</code> file contains a fake entry as
- * DirServer, so that the node thinks that it is in a private network. The
- * reason for this is that some configuration entries might only work in a
- * private network, but the node cannot be configured with valid DirSe