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

[or-cvs] r16353: Son of a.. sometimes DNS requests can have an extra space be (torctl/trunk/python/TorCtl)



Author: mikeperry
Date: 2008-08-01 22:26:42 -0400 (Fri, 01 Aug 2008)
New Revision: 16353

Modified:
   torctl/trunk/python/TorCtl/TorCtl.py
Log:

Son of a.. sometimes DNS requests can have an extra space
before the PURPOSE.. This is definitely a Tor control port
bug, but we should be compatible.



Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py	2008-08-02 01:55:57 UTC (rev 16352)
+++ torctl/trunk/python/TorCtl/TorCtl.py	2008-08-02 02:26:42 UTC (rev 16353)
@@ -845,7 +845,7 @@
       event = CircuitEvent(evtype, ident, status, path, reason, remote)
     elif evtype == "STREAM":
       #plog("DEBUG", "STREAM: "+body)
-      m = re.match(r"(\S+)\s+(\S+)\s+(\S+)\s+(\S+):(\d+)(\sREASON=\S+)?(\sREMOTE_REASON=\S+)?(\sSOURCE=\S+)?(\sSOURCE_ADDR=\S+)?(\sPURPOSE=\S+)?", body)
+      m = re.match(r"(\S+)\s+(\S+)\s+(\S+)\s+(\S+):(\d+)(\sREASON=\S+)?(\sREMOTE_REASON=\S+)?(\sSOURCE=\S+)?(\sSOURCE_ADDR=\S+)?(\s+PURPOSE=\S+)?", body)
       if not m:
         raise ProtocolError("STREAM event misformatted.")
       ident,status,circ,target_host,target_port,reason,remote,source,source_addr,purpose = m.groups()
@@ -854,7 +854,9 @@
       if remote: remote = remote[15:]
       if source: source = source[8:]
       if source_addr: source_addr = source_addr[13:]
-      if purpose: purpose = purpose[9:]
+      if purpose:
+        purpose = purpose.lstrip()
+        purpose = purpose[8:]
       event = StreamEvent(evtype, ident, status, circ, target_host,
                int(target_port), reason, remote, source, source_addr, purpose)
     elif evtype == "ORCONN":