[tor-commits] [stegotorus/master] updated dummy steg module
zwol at torproject.org
zwol at torproject.org
Fri Jul 20 23:17:06 UTC 2012
commit 05fae9597a560dd64686c03b88bcdffb3efce242
Author: Vinod Yegneswaran <vinod at csl.sri.com>
Date: Wed Jan 11 01:26:14 2012 +0000
updated dummy steg module
git-svn-id: svn+ssh://spartan.csl.sri.com/svn/private/DEFIANCE@213 a58ff0ac-194c-e011-a152-003048836090
---
src/steg/dummy.cc | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/src/steg/dummy.cc b/src/steg/dummy.cc
index 230dbab..5823a69 100644
--- a/src/steg/dummy.cc
+++ b/src/steg/dummy.cc
@@ -44,6 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace {
struct dummy : steg_t
{
+ bool have_transmitted : 1;
+ bool have_received : 1;
STEG_DECLARE_METHODS(dummy);
};
}
@@ -56,6 +58,7 @@ STEG_DEFINE_MODULE(dummy,
dummy::dummy(bool is_clientside)
+ : have_transmitted(false), have_received(false)
{
this->is_clientside = is_clientside;
}
@@ -69,21 +72,16 @@ dummy::~dummy()
bool
dummy::detect(conn_t *conn)
{
- struct config_t* cfg = conn->cfg;
- struct evutil_addrinfo *addrs = cfg->get_listen_addrs(0);
-
-
+ struct evutil_addrinfo *addrs = conn->cfg->get_listen_addrs(0);
if (!addrs) {
- log_warn("no listen addrs\n");
+ log_debug("no listen addrs\n");
return 0;
}
struct sockaddr_in* sin = (struct sockaddr_in*) addrs->ai_addr;
- if (sin->sin_port == htons(DUMMY_PORT)) {
-
+ if (sin->sin_port == htons(DUMMY_PORT))
return 1;
- }
return 0;
@@ -92,7 +90,17 @@ dummy::detect(conn_t *conn)
size_t
dummy::transmit_room(conn_t *)
{
- return 1024;
+
+ if (have_transmitted)
+ return 0;
+
+ if (is_clientside)
+ return SIZE_MAX;
+
+ if (!have_received)
+ return 0;
+
+ return SIZE_MAX;
}
@@ -106,12 +114,17 @@ dummy::transmit(struct evbuffer *source, conn_t *conn)
{
struct evbuffer *dest = conn_get_outbound(conn);
- // fprintf(stderr, "transmitting %d\n", (int) evbuffer_get_length(source));
+ fprintf(stderr, "transmitting %d\n", (int) evbuffer_get_length(source));;
+
if (evbuffer_add_buffer(dest, source)) {
fprintf(stderr, "failed to transfer buffer\n");
}
+
+
+ conn_cease_transmission(conn);
+ this->have_transmitted = 1;
return 0;
}
@@ -126,11 +139,18 @@ dummy::receive(conn_t *conn, struct evbuffer *dest)
{
struct evbuffer *source = conn_get_inbound(conn);
- // fprintf(stderr, "receiving %d\n", (int) evbuffer_get_length(source));
+
+ fprintf(stderr, "receiving %d\n", (int) evbuffer_get_length(source));
if (evbuffer_add_buffer(dest, source)) {
fprintf(stderr, "failed to transfer buffer\n");
}
+
+
+
+
+ this->have_received = 1;
+ conn_transmit_soon(conn, 100);
return 0;
}
More information about the tor-commits
mailing list