[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stegotorus/master] Protocol/steg module naming adjustments.



commit 912453ceba76cd2a05b6ba1169761063eda4c370
Author: Zack Weinberg <zackw@xxxxxxx>
Date:   Mon Jan 30 17:01:53 2012 -0800

    Protocol/steg module naming adjustments.
    
    x_null -> null (protocol)
    dummy -> null (steg)
    dummy_rr -> null_rr (steg)
---
 Makefile.am                   |    8 +-
 scripts/start-client.csh      |    3 +-
 scripts/start-server.csh      |    2 +-
 src/protocol/chop.cc          |    2 +-
 src/protocol/null.cc          |  243 +++++++++++++++++++++++++++++++++++++++++
 src/protocol/x_null.cc        |  243 -----------------------------------------
 src/steg/dummy.cc             |   95 ----------------
 src/steg/dummy_rr.cc          |  113 -------------------
 src/steg/null.cc              |   95 ++++++++++++++++
 src/steg/null_rr.cc           |  113 +++++++++++++++++++
 src/test/test_socks.py        |    2 +-
 src/test/test_tl.py           |   46 +++++++-
 src/test/unittest_config.cc   |   32 +++---
 src/test/unittest_transfer.cc |   16 ++--
 14 files changed, 522 insertions(+), 491 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 32f422b..b8e44b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,7 @@ bin_PROGRAMS     = stegotorus
 
 PROTOCOLS = \
 	src/protocol/chop.cc \
-	src/protocol/x_null.cc
+	src/protocol/null.cc
 
 STEGANOGRAPHERS = \
 	src/steg/cookies.cc \
@@ -24,12 +24,12 @@ STEGANOGRAPHERS = \
 	src/steg/embed.cc \
 	src/steg/http.cc \
 	src/steg/jsSteg.cc \
+	src/steg/null.cc \
+	src/steg/null_rr.cc \
 	src/steg/payloads.cc \
 	src/steg/pdfSteg.cc \
 	src/steg/swfSteg.cc \
-	src/steg/zpack.cc \
-	src/steg/dummy.cc \
-	src/steg/dummy_rr.cc
+	src/steg/zpack.cc
 
 libstegotorus_a_SOURCES = \
 	src/connections.cc \
diff --git a/scripts/start-client.csh b/scripts/start-client.csh
index 9919eae..3e3dece 100644
--- a/scripts/start-client.csh
+++ b/scripts/start-client.csh
@@ -5,6 +5,5 @@ setenv EVENT_NOKQUEUE yes
 #./stegotorus --log-min-severity=debug chop socks 127.0.0.1:1080 127.0.0.1:8080 http 127.0.0.1:8081 http
 # ./stegotorus --log-min-severity=warn chop socks 127.0.0.1:1080 127.0.0.1:8080 http 127.0.0.1:8081 http
 #./stegotorus --log-min-severity=error chop socks 127.0.0.1:1080 127.0.0.1:8080 http 127.0.0.1:8081 http
-./stegotorus --log-min-severity=error chop socks 127.0.0.1:1080 127.0.0.1:3333 dummy
-# 127.0.0.1:3333 dummy
+./stegotorus --log-min-severity=error chop socks 127.0.0.1:1080 127.0.0.1:3333 null # 127.0.0.1:3333 null
 
diff --git a/scripts/start-server.csh b/scripts/start-server.csh
index 2dfcd44..98f710a 100644
--- a/scripts/start-server.csh
+++ b/scripts/start-server.csh
@@ -3,5 +3,5 @@ setenv EVENT_NOKQUEUE yes
 # ./stegotorus --log-min-severity=debug chop server 87.73.82.145:8080 127.0.0.1:8080 127.0.0.1:8081 http
 # ./stegotorus --log-min-severity=warn chop server 87.73.82.145:8080 127.0.0.1:8080 127.0.0.1:8081 http
 #./stegotorus --log-min-severity=error chop server 87.73.82.145:8080 127.0.0.1:8080 127.0.0.1:8081 http
-./stegotorus --log-min-severity=error chop server 87.73.82.145:8080 127.0.0.1:3333 dummy
+./stegotorus --log-min-severity=error chop server 87.73.82.145:8080 127.0.0.1:3333 null
 
diff --git a/src/protocol/chop.cc b/src/protocol/chop.cc
index 71437eb..338caa0 100644
--- a/src/protocol/chop.cc
+++ b/src/protocol/chop.cc
@@ -4,7 +4,7 @@
    The chopper is the core StegoTorus protocol implementation.
    For its design, see doc/chopper.tex.  Note that it is still
    being implemented, and many things that are *intended* to change
-   from the toy "roundrobin" (aka "x_rr") protocol have not yet changed.  */
+   from the toy "roundrobin" protocol have not yet changed.  */
 
 #include "util.h"
 #include "connections.h"
diff --git a/src/protocol/null.cc b/src/protocol/null.cc
new file mode 100644
index 0000000..27a9320
--- /dev/null
+++ b/src/protocol/null.cc
@@ -0,0 +1,243 @@
+/* Copyright 2011 Nick Mathewson, George Kadianakis
+   See LICENSE for other credits and copying information
+*/
+
+#include "util.h"
+#include "connections.h"
+#include "protocol.h"
+
+#include <event2/buffer.h>
+
+namespace {
+  struct null_config_t : config_t {
+    struct evutil_addrinfo *listen_addr;
+    struct evutil_addrinfo *target_addr;
+
+    CONFIG_DECLARE_METHODS(null);
+  };
+
+  struct null_conn_t : conn_t {
+    CONN_DECLARE_METHODS(null);
+  };
+
+  struct null_circuit_t : circuit_t {
+    conn_t *downstream;
+
+    CIRCUIT_DECLARE_METHODS(null);
+  };
+}
+
+PROTO_DEFINE_MODULE(null);
+
+null_config_t::null_config_t()
+{
+}
+
+null_config_t::~null_config_t()
+{
+  if (this->listen_addr)
+    evutil_freeaddrinfo(this->listen_addr);
+  if (this->target_addr)
+    evutil_freeaddrinfo(this->target_addr);
+}
+
+bool
+null_config_t::init(int n_options, const char *const *options)
+{
+  const char* defport;
+
+  if (n_options < 1)
+    goto usage;
+
+  if (!strcmp(options[0], "client")) {
+    defport = "48988"; /* bf5c */
+    this->mode = LSN_SIMPLE_CLIENT;
+  } else if (!strcmp(options[0], "socks")) {
+    defport = "23548"; /* 5bf5 */
+    this->mode = LSN_SOCKS_CLIENT;
+  } else if (!strcmp(options[0], "server")) {
+    defport = "11253"; /* 2bf5 */
+    this->mode = LSN_SIMPLE_SERVER;
+  } else
+    goto usage;
+
+  if (n_options != (this->mode == LSN_SOCKS_CLIENT ? 2 : 3))
+    goto usage;
+
+  this->listen_addr = resolve_address_port(options[1], 1, 1, defport);
+  if (!this->listen_addr)
+    goto usage;
+
+  if (this->mode != LSN_SOCKS_CLIENT) {
+    this->target_addr = resolve_address_port(options[2], 1, 0, NULL);
+    if (!this->target_addr)
+      goto usage;
+  }
+
+  return true;
+
+ usage:
+  log_warn("null syntax:\n"
+           "\tnull <mode> <listen_address> [<target_address>]\n"
+           "\t\tmode ~ server|client|socks\n"
+           "\t\tlisten_address, target_address ~ host:port\n"
+           "\ttarget_address is required for server and client mode,\n"
+           "\tand forbidden for socks mode.\n"
+           "Examples:\n"
+           "\tstegotorus null socks 127.0.0.1:5000\n"
+           "\tstegotorus null client 127.0.0.1:5000 192.168.1.99:11253\n"
+           "\tstegotorus null server 192.168.1.99:11253 127.0.0.1:9005");
+  return false;
+}
+
+/** Retrieve the 'n'th set of listen addresses for this configuration. */
+struct evutil_addrinfo *
+null_config_t::get_listen_addrs(size_t n)
+{
+  if (n > 0)
+    return 0;
+  return this->listen_addr;
+}
+
+/* Retrieve the target address for this configuration. */
+struct evutil_addrinfo *
+null_config_t::get_target_addrs(size_t n)
+{
+  if (n > 0)
+    return 0;
+  return this->target_addr;
+}
+
+/* Create a circuit object. */
+circuit_t *
+null_config_t::circuit_create(size_t)
+{
+  circuit_t *ckt = new null_circuit_t;
+  ckt->cfg = this;
+  return ckt;
+}
+
+null_circuit_t::null_circuit_t()
+{
+}
+
+null_circuit_t::~null_circuit_t()
+{
+  if (downstream) {
+    /* break the circular reference before deallocating the
+       downstream connection */
+    downstream->circuit = NULL;
+    delete downstream;
+  }
+}
+
+/* Add a connection to this circuit. */
+void
+null_circuit_t::add_downstream(conn_t *conn)
+{
+  log_assert(!this->downstream);
+  this->downstream = conn;
+  log_debug(this, "added connection <%d.%d> to %s",
+            this->serial, conn->serial, conn->peername);
+}
+
+/* Drop a connection from this circuit.  If this happens in this
+   protocol, it is because of a network error, and the whole circuit
+   should be closed.  */
+void
+null_circuit_t::drop_downstream(conn_t *conn)
+{
+  log_assert(this->downstream == conn);
+  log_debug(this, "dropped connection <%d.%d> to %s",
+            this->serial, conn->serial, conn->peername);
+  this->downstream = NULL;
+  if (evbuffer_get_length(bufferevent_get_output(this->up_buffer)) > 0)
+    /* this may already have happened, but there's no harm in
+       doing it again */
+    circuit_do_flush(this);
+  else
+    circuit_close(this);
+}
+
+/* Send data from the upstream buffer. */
+int
+null_circuit_t::send()
+{
+  return evbuffer_add_buffer(conn_get_outbound(this->downstream),
+                             bufferevent_get_input(this->up_buffer));
+}
+
+/* Send an EOF on this circuit. */
+int
+null_circuit_t::send_eof()
+{
+  if (this->downstream)
+    conn_send_eof(this->downstream);
+  return 0;
+}
+
+/*
+  This is called everytime we get a connection for the null
+  protocol.
+*/
+
+conn_t *
+null_config_t::conn_create(size_t)
+{
+  null_conn_t *conn = new null_conn_t;
+  conn->cfg = this;
+  return conn;
+}
+
+null_conn_t::null_conn_t()
+{
+}
+
+null_conn_t::~null_conn_t()
+{
+}
+
+/** Null inbound-to-outbound connections are 1:1 */
+int
+null_conn_t::maybe_open_upstream()
+{
+  circuit_t *ckt = circuit_create(this->cfg, 0);
+  if (!ckt)
+    return -1;
+
+  circuit_add_downstream(ckt, this);
+  circuit_open_upstream(ckt);
+  return 0;
+}
+
+/** Null has no handshake */
+int
+null_conn_t::handshake()
+{
+  return 0;
+}
+
+/** Receive data from connection SOURCE */
+int
+null_conn_t::recv()
+{
+  log_assert(this->circuit);
+  return evbuffer_add_buffer(bufferevent_get_output(this->circuit->up_buffer),
+                             conn_get_inbound(this));
+}
+
+/** Receive EOF from connection SOURCE */
+int
+null_conn_t::recv_eof()
+{
+  if (this->circuit) {
+    if (evbuffer_get_length(conn_get_inbound(this)) > 0)
+      if (this->recv())
+        return -1;
+
+    circuit_recv_eof(this->circuit);
+  }
+  return 0;
+}
+
+CONN_STEG_STUBS(null);
diff --git a/src/protocol/x_null.cc b/src/protocol/x_null.cc
deleted file mode 100644
index 09c7e00..0000000
--- a/src/protocol/x_null.cc
+++ /dev/null
@@ -1,243 +0,0 @@
-/* Copyright 2011 Nick Mathewson, George Kadianakis
-   See LICENSE for other credits and copying information
-*/
-
-#include "util.h"
-#include "connections.h"
-#include "protocol.h"
-
-#include <event2/buffer.h>
-
-namespace {
-  struct x_null_config_t : config_t {
-    struct evutil_addrinfo *listen_addr;
-    struct evutil_addrinfo *target_addr;
-
-    CONFIG_DECLARE_METHODS(x_null);
-  };
-
-  struct x_null_conn_t : conn_t {
-    CONN_DECLARE_METHODS(x_null);
-  };
-
-  struct x_null_circuit_t : circuit_t {
-    conn_t *downstream;
-
-    CIRCUIT_DECLARE_METHODS(x_null);
-  };
-}
-
-PROTO_DEFINE_MODULE(x_null);
-
-x_null_config_t::x_null_config_t()
-{
-}
-
-x_null_config_t::~x_null_config_t()
-{
-  if (this->listen_addr)
-    evutil_freeaddrinfo(this->listen_addr);
-  if (this->target_addr)
-    evutil_freeaddrinfo(this->target_addr);
-}
-
-bool
-x_null_config_t::init(int n_options, const char *const *options)
-{
-  const char* defport;
-
-  if (n_options < 1)
-    goto usage;
-
-  if (!strcmp(options[0], "client")) {
-    defport = "48988"; /* bf5c */
-    this->mode = LSN_SIMPLE_CLIENT;
-  } else if (!strcmp(options[0], "socks")) {
-    defport = "23548"; /* 5bf5 */
-    this->mode = LSN_SOCKS_CLIENT;
-  } else if (!strcmp(options[0], "server")) {
-    defport = "11253"; /* 2bf5 */
-    this->mode = LSN_SIMPLE_SERVER;
-  } else
-    goto usage;
-
-  if (n_options != (this->mode == LSN_SOCKS_CLIENT ? 2 : 3))
-    goto usage;
-
-  this->listen_addr = resolve_address_port(options[1], 1, 1, defport);
-  if (!this->listen_addr)
-    goto usage;
-
-  if (this->mode != LSN_SOCKS_CLIENT) {
-    this->target_addr = resolve_address_port(options[2], 1, 0, NULL);
-    if (!this->target_addr)
-      goto usage;
-  }
-
-  return true;
-
- usage:
-  log_warn("x_null syntax:\n"
-           "\tx_null <mode> <listen_address> [<target_address>]\n"
-           "\t\tmode ~ server|client|socks\n"
-           "\t\tlisten_address, target_address ~ host:port\n"
-           "\ttarget_address is required for server and client mode,\n"
-           "\tand forbidden for socks mode.\n"
-           "Examples:\n"
-           "\tstegotorus x_null socks 127.0.0.1:5000\n"
-           "\tstegotorus x_null client 127.0.0.1:5000 192.168.1.99:11253\n"
-           "\tstegotorus x_null server 192.168.1.99:11253 127.0.0.1:9005");
-  return false;
-}
-
-/** Retrieve the 'n'th set of listen addresses for this configuration. */
-struct evutil_addrinfo *
-x_null_config_t::get_listen_addrs(size_t n)
-{
-  if (n > 0)
-    return 0;
-  return this->listen_addr;
-}
-
-/* Retrieve the target address for this configuration. */
-struct evutil_addrinfo *
-x_null_config_t::get_target_addrs(size_t n)
-{
-  if (n > 0)
-    return 0;
-  return this->target_addr;
-}
-
-/* Create a circuit object. */
-circuit_t *
-x_null_config_t::circuit_create(size_t)
-{
-  circuit_t *ckt = new x_null_circuit_t;
-  ckt->cfg = this;
-  return ckt;
-}
-
-x_null_circuit_t::x_null_circuit_t()
-{
-}
-
-x_null_circuit_t::~x_null_circuit_t()
-{
-  if (downstream) {
-    /* break the circular reference before deallocating the
-       downstream connection */
-    downstream->circuit = NULL;
-    delete downstream;
-  }
-}
-
-/* Add a connection to this circuit. */
-void
-x_null_circuit_t::add_downstream(conn_t *conn)
-{
-  log_assert(!this->downstream);
-  this->downstream = conn;
-  log_debug(this, "added connection <%d.%d> to %s",
-            this->serial, conn->serial, conn->peername);
-}
-
-/* Drop a connection from this circuit.  If this happens in this
-   protocol, it is because of a network error, and the whole circuit
-   should be closed.  */
-void
-x_null_circuit_t::drop_downstream(conn_t *conn)
-{
-  log_assert(this->downstream == conn);
-  log_debug(this, "dropped connection <%d.%d> to %s",
-            this->serial, conn->serial, conn->peername);
-  this->downstream = NULL;
-  if (evbuffer_get_length(bufferevent_get_output(this->up_buffer)) > 0)
-    /* this may already have happened, but there's no harm in
-       doing it again */
-    circuit_do_flush(this);
-  else
-    circuit_close(this);
-}
-
-/* Send data from the upstream buffer. */
-int
-x_null_circuit_t::send()
-{
-  return evbuffer_add_buffer(conn_get_outbound(this->downstream),
-                             bufferevent_get_input(this->up_buffer));
-}
-
-/* Send an EOF on this circuit. */
-int
-x_null_circuit_t::send_eof()
-{
-  if (this->downstream)
-    conn_send_eof(this->downstream);
-  return 0;
-}
-
-/*
-  This is called everytime we get a connection for the x_null
-  protocol.
-*/
-
-conn_t *
-x_null_config_t::conn_create(size_t)
-{
-  x_null_conn_t *conn = new x_null_conn_t;
-  conn->cfg = this;
-  return conn;
-}
-
-x_null_conn_t::x_null_conn_t()
-{
-}
-
-x_null_conn_t::~x_null_conn_t()
-{
-}
-
-/** Null inbound-to-outbound connections are 1:1 */
-int
-x_null_conn_t::maybe_open_upstream()
-{
-  circuit_t *ckt = circuit_create(this->cfg, 0);
-  if (!ckt)
-    return -1;
-
-  circuit_add_downstream(ckt, this);
-  circuit_open_upstream(ckt);
-  return 0;
-}
-
-/** Null has no handshake */
-int
-x_null_conn_t::handshake()
-{
-  return 0;
-}
-
-/** Receive data from connection SOURCE */
-int
-x_null_conn_t::recv()
-{
-  log_assert(this->circuit);
-  return evbuffer_add_buffer(bufferevent_get_output(this->circuit->up_buffer),
-                             conn_get_inbound(this));
-}
-
-/** Receive EOF from connection SOURCE */
-int
-x_null_conn_t::recv_eof()
-{
-  if (this->circuit) {
-    if (evbuffer_get_length(conn_get_inbound(this)) > 0)
-      if (this->recv())
-        return -1;
-
-    circuit_recv_eof(this->circuit);
-  }
-  return 0;
-}
-
-CONN_STEG_STUBS(x_null);
diff --git a/src/steg/dummy.cc b/src/steg/dummy.cc
deleted file mode 100644
index 7033042..0000000
--- a/src/steg/dummy.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-/*  Copyright (c) 2011, SRI International
-
-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.
-
-    Contributors: Zack Weinberg, Vinod Yegneswaran
-    See LICENSE for other credits and copying information
-*/
-
-#include "util.h"
-#include "connections.h"
-#include "protocol.h"
-#include "steg.h"
-#include <event2/buffer.h>
-
-namespace {
-struct dummy : steg_t
-{
-  STEG_DECLARE_METHODS(dummy);
-};
-}
-
-STEG_DEFINE_MODULE(dummy);
-
-dummy::dummy(bool is_clientside)
-  : steg_t(is_clientside)
-{
-}
-
-dummy::~dummy()
-{
-}
-
-size_t
-dummy::transmit_room(conn_t *)
-{
-  return SIZE_MAX;
-}
-
-int
-dummy::transmit(struct evbuffer *source, conn_t *conn)
-{
-  struct evbuffer *dest = conn_get_outbound(conn);
-
-  log_debug(conn, "transmitting %lu bytes",
-            (unsigned long)evbuffer_get_length(source));
-
-  if (evbuffer_add_buffer(dest, source)) {
-    log_warn(conn, "failed to transfer buffer");
-    return -1;
-  }
-
-  return 0;
-}
-
-int
-dummy::receive(conn_t *conn, struct evbuffer *dest)
-{
-  struct evbuffer *source = conn_get_inbound(conn);
-
-  log_debug(conn, "receiving %lu bytes",
-            (unsigned long)evbuffer_get_length(source));
-
-  if (evbuffer_add_buffer(dest, source)) {
-    log_warn(conn, "failed to transfer buffer");
-    return -1;
-  }
-
-  return 0;
-}
diff --git a/src/steg/dummy_rr.cc b/src/steg/dummy_rr.cc
deleted file mode 100644
index 705a42c..0000000
--- a/src/steg/dummy_rr.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-/*  Copyright (c) 2011, SRI International
-
-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.
-
-    Contributors: Zack Weinberg, Vinod Yegneswaran
-    See LICENSE for other credits and copying information
-*/
-
-#include "util.h"
-#include "connections.h"
-#include "protocol.h"
-#include "steg.h"
-#include <event2/buffer.h>
-
-namespace {
-struct dummy_rr : steg_t
-{
-  bool can_transmit : 1;
-  STEG_DECLARE_METHODS(dummy_rr);
-};
-}
-
-STEG_DEFINE_MODULE(dummy_rr);
-
-dummy_rr::dummy_rr(bool is_clientside)
-  : steg_t(is_clientside),
-    can_transmit(is_clientside)
-{
-}
-
-dummy_rr::~dummy_rr()
-{
-}
-
-size_t
-dummy_rr::transmit_room(conn_t *)
-{
-  return can_transmit ? SIZE_MAX : 0;
-}
-
-int
-dummy_rr::transmit(struct evbuffer *source, conn_t *conn)
-{
-  log_assert(can_transmit);
-
-  struct evbuffer *dest = conn_get_outbound(conn);
-
-  log_debug(conn, "transmitting %lu bytes",
-            (unsigned long)evbuffer_get_length(source));
-
-  if (evbuffer_add_buffer(dest, source)) {
-    log_warn(conn, "failed to transfer buffer");
-    return -1;
-  }
-
-  can_transmit = false;
-  if (is_clientside) {
-    conn_cease_transmission(conn);
-  } else {
-    conn_close_after_transmit(conn);
-  }
-
-  return 0;
-}
-
-int
-dummy_rr::receive(conn_t *conn, struct evbuffer *dest)
-{
-  struct evbuffer *source = conn_get_inbound(conn);
-
-  log_debug(conn, "receiving %lu bytes",
-            (unsigned long)evbuffer_get_length(source));
-
-  if (evbuffer_add_buffer(dest, source)) {
-    log_warn(conn, "failed to transfer buffer");
-    return -1;
-  }
-
-  if (is_clientside) {
-    conn_expect_close(conn);
-  } else {
-    can_transmit = true;
-    conn_transmit_soon(conn, 100);
-  }
-
-  return 0;
-}
diff --git a/src/steg/null.cc b/src/steg/null.cc
new file mode 100644
index 0000000..59faed0
--- /dev/null
+++ b/src/steg/null.cc
@@ -0,0 +1,95 @@
+/*  Copyright (c) 2011, SRI International
+
+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.
+
+    Contributors: Zack Weinberg, Vinod Yegneswaran
+    See LICENSE for other credits and copying information
+*/
+
+#include "util.h"
+#include "connections.h"
+#include "protocol.h"
+#include "steg.h"
+#include <event2/buffer.h>
+
+namespace {
+struct null : steg_t
+{
+  STEG_DECLARE_METHODS(null);
+};
+}
+
+STEG_DEFINE_MODULE(null);
+
+null::null(bool is_clientside)
+  : steg_t(is_clientside)
+{
+}
+
+null::~null()
+{
+}
+
+size_t
+null::transmit_room(conn_t *)
+{
+  return SIZE_MAX;
+}
+
+int
+null::transmit(struct evbuffer *source, conn_t *conn)
+{
+  struct evbuffer *dest = conn_get_outbound(conn);
+
+  log_debug(conn, "transmitting %lu bytes",
+            (unsigned long)evbuffer_get_length(source));
+
+  if (evbuffer_add_buffer(dest, source)) {
+    log_warn(conn, "failed to transfer buffer");
+    return -1;
+  }
+
+  return 0;
+}
+
+int
+null::receive(conn_t *conn, struct evbuffer *dest)
+{
+  struct evbuffer *source = conn_get_inbound(conn);
+
+  log_debug(conn, "receiving %lu bytes",
+            (unsigned long)evbuffer_get_length(source));
+
+  if (evbuffer_add_buffer(dest, source)) {
+    log_warn(conn, "failed to transfer buffer");
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/src/steg/null_rr.cc b/src/steg/null_rr.cc
new file mode 100644
index 0000000..de062a8
--- /dev/null
+++ b/src/steg/null_rr.cc
@@ -0,0 +1,113 @@
+/*  Copyright (c) 2011, SRI International
+
+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.
+
+    Contributors: Zack Weinberg, Vinod Yegneswaran
+    See LICENSE for other credits and copying information
+*/
+
+#include "util.h"
+#include "connections.h"
+#include "protocol.h"
+#include "steg.h"
+#include <event2/buffer.h>
+
+namespace {
+struct null_rr : steg_t
+{
+  bool can_transmit : 1;
+  STEG_DECLARE_METHODS(null_rr);
+};
+}
+
+STEG_DEFINE_MODULE(null_rr);
+
+null_rr::null_rr(bool is_clientside)
+  : steg_t(is_clientside),
+    can_transmit(is_clientside)
+{
+}
+
+null_rr::~null_rr()
+{
+}
+
+size_t
+null_rr::transmit_room(conn_t *)
+{
+  return can_transmit ? SIZE_MAX : 0;
+}
+
+int
+null_rr::transmit(struct evbuffer *source, conn_t *conn)
+{
+  log_assert(can_transmit);
+
+  struct evbuffer *dest = conn_get_outbound(conn);
+
+  log_debug(conn, "transmitting %lu bytes",
+            (unsigned long)evbuffer_get_length(source));
+
+  if (evbuffer_add_buffer(dest, source)) {
+    log_warn(conn, "failed to transfer buffer");
+    return -1;
+  }
+
+  can_transmit = false;
+  if (is_clientside) {
+    conn_cease_transmission(conn);
+  } else {
+    conn_close_after_transmit(conn);
+  }
+
+  return 0;
+}
+
+int
+null_rr::receive(conn_t *conn, struct evbuffer *dest)
+{
+  struct evbuffer *source = conn_get_inbound(conn);
+
+  log_debug(conn, "receiving %lu bytes",
+            (unsigned long)evbuffer_get_length(source));
+
+  if (evbuffer_add_buffer(dest, source)) {
+    log_warn(conn, "failed to transfer buffer");
+    return -1;
+  }
+
+  if (is_clientside) {
+    conn_expect_close(conn);
+  } else {
+    can_transmit = true;
+    conn_transmit_soon(conn, 100);
+  }
+
+  return 0;
+}
diff --git a/src/test/test_socks.py b/src/test/test_socks.py
index 47b0c65..d71da5e 100644
--- a/src/test/test_socks.py
+++ b/src/test/test_socks.py
@@ -10,7 +10,7 @@ class SocksTest(TestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.client = Stegotorus("x_null", "socks", "127.0.0.1:4999")
+        cls.client = Stegotorus("null", "socks", "127.0.0.1:4999")
 
     @classmethod
     def tearDownClass(cls):
diff --git a/src/test/test_tl.py b/src/test/test_tl.py
index dfa4128..39fb728 100644
--- a/src/test/test_tl.py
+++ b/src/test/test_tl.py
@@ -41,19 +41,51 @@ class TimelineTest(object):
         if errors != "":
             self.fail("\n" + errors)
 
-    def test_xnull(self):
-        self.doTest("x_null",
-           ("x_null", "server", "127.0.0.1:5000", "127.0.0.1:5001",
-            "x_null", "client", "127.0.0.1:4999", "127.0.0.1:5000"))
+    def test_null(self):
+        self.doTest("null",
+           ("null", "server", "127.0.0.1:5000", "127.0.0.1:5001",
+            "null", "client", "127.0.0.1:4999", "127.0.0.1:5000"))
 
-    def test_chop(self):
+    def test_chop_null(self):
         self.doTest("chop",
            ("chop", "server", "127.0.0.1:5001",
-            "127.0.0.1:5010","http","127.0.0.1:5011","http",
+            "127.0.0.1:5010","null",
             "chop", "client", "127.0.0.1:4999",
-            "127.0.0.1:5010","http","127.0.0.1:5011","http",
+            "127.0.0.1:5010","null",
             ))
 
+    def test_chop_null2(self):
+        self.doTest("chop",
+           ("chop", "server", "127.0.0.1:5001",
+            "127.0.0.1:5010","null","127.0.0.1:5011","null",
+            "chop", "client", "127.0.0.1:4999",
+            "127.0.0.1:5010","null","127.0.0.1:5011","null",
+            ))
+
+    def test_chop_null_rr(self):
+        self.doTest("chop",
+           ("chop", "server", "127.0.0.1:5001",
+            "127.0.0.1:5010","null_rr",
+            "chop", "client", "127.0.0.1:4999",
+            "127.0.0.1:5010","null_rr",
+            ))
+
+    def test_chop_null_rr2(self):
+        self.doTest("chop",
+           ("chop", "server", "127.0.0.1:5001",
+            "127.0.0.1:5010","null_rr","127.0.0.1:5011","null_rr",
+            "chop", "client", "127.0.0.1:4999",
+            "127.0.0.1:5010","null_rr","127.0.0.1:5011","null_rr",
+            ))
+
+#    def test_chop_http(self):
+#        self.doTest("chop",
+#           ("chop", "server", "127.0.0.1:5001",
+#            "127.0.0.1:5010","http","127.0.0.1:5011","http",
+#            "chop", "client", "127.0.0.1:4999",
+#            "127.0.0.1:5010","http","127.0.0.1:5011","http",
+#            ))
+
 # Synthesize TimelineTest+TestCase subclasses for every 'tl_*' file in
 # the test directory.
 def load_tests(loader, standard_tests, pattern):
diff --git a/src/test/unittest_config.cc b/src/test/unittest_config.cc
index 496b829..58571e9 100644
--- a/src/test/unittest_config.cc
+++ b/src/test/unittest_config.cc
@@ -54,25 +54,25 @@ cleanup_test_config(const struct testcase_t *, void *state)
 static const struct testcase_setup_t config_fixture =
   { setup_test_config, cleanup_test_config };
 
-static struct option_parsing_case oc_x_null[] = {
+static struct option_parsing_case oc_null[] = {
   /* wrong number of options */
-  { 0, 0, 1, {"x_null"} },
-  { 0, 0, 2, {"x_null", "client"} },
-  { 0, 0, 3, {"x_null", "client", "127.0.0.1:5552"} },
-  { 0, 0, 3, {"x_null", "server", "127.0.0.1:5552"} },
-  { 0, 0, 4, {"x_null", "socks", "127.0.0.1:5552", "192.168.1.99:11253"} },
+  { 0, 0, 1, {"null"} },
+  { 0, 0, 2, {"null", "client"} },
+  { 0, 0, 3, {"null", "client", "127.0.0.1:5552"} },
+  { 0, 0, 3, {"null", "server", "127.0.0.1:5552"} },
+  { 0, 0, 4, {"null", "socks", "127.0.0.1:5552", "192.168.1.99:11253"} },
   /* unrecognized mode */
-  { 0, 0, 3, {"x_null", "floodcontrol", "127.0.0.1:5552" } },
-  { 0, 0, 4, {"x_null", "--frobozz", "client", "127.0.0.1:5552"} },
-  { 0, 0, 4, {"x_null", "client", "--frobozz", "127.0.0.1:5552"} },
+  { 0, 0, 3, {"null", "floodcontrol", "127.0.0.1:5552" } },
+  { 0, 0, 4, {"null", "--frobozz", "client", "127.0.0.1:5552"} },
+  { 0, 0, 4, {"null", "client", "--frobozz", "127.0.0.1:5552"} },
   /* bad address */
-  { 0, 0, 3, {"x_null", "socks", "@:5552"} },
-  { 0, 0, 3, {"x_null", "socks", "127.0.0.1:notanumber"} },
+  { 0, 0, 3, {"null", "socks", "@:5552"} },
+  { 0, 0, 3, {"null", "socks", "127.0.0.1:notanumber"} },
   /* should succeed */
-  { 0, 1, 4, {"x_null", "client", "127.0.0.1:5552", "192.168.1.99:11253" } },
-  { 0, 1, 4, {"x_null", "client", "127.0.0.1", "192.168.1.99:11253" } },
-  { 0, 1, 4, {"x_null", "server", "127.0.0.1:5552", "192.168.1.99:11253" } },
-  { 0, 1, 3, {"x_null", "socks", "127.0.0.1:5552" } },
+  { 0, 1, 4, {"null", "client", "127.0.0.1:5552", "192.168.1.99:11253" } },
+  { 0, 1, 4, {"null", "client", "127.0.0.1", "192.168.1.99:11253" } },
+  { 0, 1, 4, {"null", "server", "127.0.0.1:5552", "192.168.1.99:11253" } },
+  { 0, 1, 3, {"null", "socks", "127.0.0.1:5552" } },
 
   { 0, 0, 0, {0} }
 };
@@ -81,6 +81,6 @@ static struct option_parsing_case oc_x_null[] = {
   { #name, test_config, 0, &config_fixture, oc_##name }
 
 struct testcase_t config_tests[] = {
-  T(x_null),
+  T(null),
   END_OF_TESTCASES
 };
diff --git a/src/test/unittest_transfer.cc b/src/test/unittest_transfer.cc
index 91f3dbd..520a1e4 100644
--- a/src/test/unittest_transfer.cc
+++ b/src/test/unittest_transfer.cc
@@ -69,8 +69,8 @@ test_transfer(void *state)
  end:;
 }
 
-#define enc1_x_null msg1
-#define enc2_x_null msg2
+#define enc1_null msg1
+#define enc2_null msg2
 
 #if 0 /* temporarily disabled - causes crashes */
 static const char enc1_s_x_http[] =
@@ -89,11 +89,11 @@ static const char enc2_s_x_http[] =
     "this is a 55-byte message passed from server to client!\x00";
 #endif
 
-static const char *const o_client_x_null[] =
-  {"x_null", "socks", "127.0.0.1:1800"};
+static const char *const o_client_null[] =
+  {"null", "socks", "127.0.0.1:1800"};
 
-static const char *const o_server_x_null[] =
-  {"x_null", "server", "127.0.0.1:1800", "127.0.0.1:1801"};
+static const char *const o_server_null[] =
+  {"null", "server", "127.0.0.1:1800", "127.0.0.1:1801"};
 
 #define TA(name)                                                \
   static const struct proto_test_args tr_##name##_args =        \
@@ -102,12 +102,12 @@ static const char *const o_server_x_null[] =
       SLEN(enc1_##name), SLEN(enc2_##name),                     \
       enc1_##name, enc2_##name }
 
-TA(x_null);
+TA(null);
 
 #define T(name) \
   { #name, test_transfer, 0, &proto_test_fixture, (void *)&tr_##name##_args }
 
 struct testcase_t transfer_tests[] = {
-  T(x_null),
+  T(null),
   END_OF_TESTCASES
 };



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits