[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Progress towards making daphn3 a test helper backend
commit f6518458a187a97e59539e42a5f4df8db1ba89a6
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Mon Nov 12 09:49:51 2012 +0100
Progress towards making daphn3 a test helper backend
---
oonib/config.py | 1 -
oonib/oonibackend.py | 2 +-
oonib/testhelpers/tcp_helpers.py | 31 ++++++-------------------------
3 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/oonib/config.py b/oonib/config.py
index b34a8ae..cf2e362 100644
--- a/oonib/config.py
+++ b/oonib/config.py
@@ -29,7 +29,6 @@ helpers.tcp_echo.port = 57002
helpers.daphn3 = Storage()
helpers.daphn3.yaml_file = "/path/to/data/oonib/daphn3.yaml"
helpers.daphn3.pcap_file = "/path/to/data/server.pcap"
-
helpers.daphn3.port = 57003
helpers.dns = Storage()
diff --git a/oonib/oonibackend.py b/oonib/oonibackend.py
index 4dced2a..937f223 100644
--- a/oonib/oonibackend.py
+++ b/oonib/oonibackend.py
@@ -53,7 +53,7 @@ if config.helpers.dns.udp_port:
# XXX this needs to be ported
# Start the OONI daphn3 backend
-if config.main.daphn3_port:
+if config.helpers.daphn3.port:
daphn3_helper = internet.TCPServer(int(config.helpers.daphn3.port),
tcp_helpers.Daphn3Server())
daphn3_helper.setServiceParent(serviceCollection)
diff --git a/oonib/testhelpers/tcp_helpers.py b/oonib/testhelpers/tcp_helpers.py
index 551e880..4287a59 100644
--- a/oonib/testhelpers/tcp_helpers.py
+++ b/oonib/testhelpers/tcp_helpers.py
@@ -4,7 +4,7 @@ from twisted.internet.error import ConnectionDone
from oonib import config
-from ooni.kit.daphn3 import Mutator, Daphn3Protocol
+from ooni.kit.daphn3 import Daphn3Protocol
from ooni.kit.daphn3 import read_pcap, read_yaml
class TCPEchoProtocol(Protocol):
@@ -17,6 +17,9 @@ class TCPEchoHelper(Factory):
"""
protocol = TCPEchoProtocol
+daphn3Steps = [{'client': '\x00\x00\x00'},
+ {'server': '\x00\x00\x00'}]
+
class Daphn3Server(ServerFactory):
"""
This is the main class that deals with the daphn3 server side component.
@@ -27,31 +30,9 @@ class Daphn3Server(ServerFactory):
probability of such thing is not that likely.
"""
protocol = Daphn3Protocol
- mutations = {}
def buildProtocol(self, addr):
- p = self.protocol()
+ p = self.protocol(steps=daphn3Steps,
+ role="server")
p.factory = self
-
- if config.daphn3.yaml_file:
- steps = read_yaml(config.daphn3.yaml_file)
- elif config.daphn3.pcap_file:
- steps = read_pcap(config.daphn3.pcap_file)
- else:
- print "Error! No PCAP, nor YAML file provided."
- steps = None
-
- p.factory.steps = steps
-
- if addr.host not in self.mutations:
- self.mutations[addr.host] = Mutator(p.steps)
- else:
- print "Moving on to next mutation"
- if not self.mutations[addr.host].next():
- self.mutations.pop(addr.host)
- try:
- p.mutator = self.mutations[addr.host]
- p.current_state = p.mutator.state()
- except:
- pass
return p
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits