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

[tor-commits] [ooni-probe/master] * Adding back in a few changes that got lost in an octopus battle.



commit 471312f6e754a7b004761acced8ab462bad803e3
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Nov 15 23:52:04 2012 +0000

    * Adding back in a few changes that got lost in an octopus battle.
---
 ooni/utils/net.py |   59 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/ooni/utils/net.py b/ooni/utils/net.py
index 0cbc095..4fdff49 100644
--- a/ooni/utils/net.py
+++ b/ooni/utils/net.py
@@ -19,16 +19,30 @@ from scapy.all import utils
 
 from ooni.utils import log, txscapy
 
-#if platformm.system() == 'Windows':
+#if sys.platform.system() == 'Windows':
 #    import _winreg as winreg
 
-PLATFORMS = {'LINUX': platform.startswith("linux"),
-             'OPENBSD': platform.startswith("openbsd"),
-             'FREEBSD': platform.startswith("freebsd"),
-             'NETBSD': platform.startswith("netbsd"),
-             'DARWIN': platform.startswith("darwin"),
-             'SOLARIS': platform.startswith("sunos"),
-             'WINDOWS': platform.startswith("win32")}
+PLATFORMS = {'LINUX': sys.platform.startswith("linux"),
+             'OPENBSD': sys.platform.startswith("openbsd"),
+             'FREEBSD': sys.platform.startswith("freebsd"),
+             'NETBSD': sys.platform.startswith("netbsd"),
+             'DARWIN': sys.platform.startswith("darwin"),
+             'SOLARIS': sys.platform.startswith("sunos"),
+             'WINDOWS': sys.platform.startswith("win32")}
+
+userAgents = [
+    ("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6", "Firefox 2.0, Windows XP"),
+    ("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)", "Internet Explorer 7, Windows Vista"),
+    ("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)", "Internet Explorer 7, Windows XP"),
+    ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)", "Internet Explorer 6, Windows XP"),
+    ("Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.1; .NET CLR 1.1.4322)", "Internet Explorer 5, Windows XP"),
+    ("Opera/9.20 (Windows NT 6.0; U; en)", "Opera 9.2, Windows Vista"),
+    ("Opera/9.00 (Windows NT 5.1; U; en)", "Opera 9.0, Windows XP"),
+    ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50", "Opera 8.5, Windows XP"),
+    ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.0", "Opera 8.0, Windows XP"),
+    ("Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.02 [en]", "Opera 7.02, Windows XP"),
+    ("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20060127 Netscape/8.1", "Netscape 8.1, Windows XP")
+    ]
 
 
 class UnsupportedPlatform(Exception):
@@ -40,6 +54,35 @@ class IfaceError(Exception):
 class PermissionsError(SystemExit):
     """This test requires admin or root privileges to run. Exiting..."""
 
+
+class StringProducer(object):
+    implements(IBodyProducer)
+
+    def __init__(self, body):
+        self.body = body
+        self.length = len(body)
+
+    def startProducing(self, consumer):
+        consumer.write(self.body)
+        return defer.succeed(None)
+
+    def pauseProducing(self):
+        pass
+
+    def stopProducing(self):
+        pass
+
+class BodyReceiver(protocol.Protocol):
+    def __init__(self, finished):
+        self.finished = finished
+        self.data = ""
+
+    def dataReceived(self, bytes):
+        self.data += bytes
+
+    def connectionLost(self, reason):
+        self.finished.callback(self.data)
+
 def capturePackets(pcap_filename):
     from scapy.all import sniff
     global stop_packet_capture



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