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

[or-cvs] r18260: {torctl} Handle missing addresses in stream events (can happen on SOC (torctl/trunk/python/TorCtl)



Author: mikeperry
Date: 2009-01-23 18:34:36 -0500 (Fri, 23 Jan 2009)
New Revision: 18260

Modified:
   torctl/trunk/python/TorCtl/PathSupport.py
   torctl/trunk/python/TorCtl/TorCtl.py
Log:
Handle missing addresses in stream events (can happen on
SOCKS-related errors).



Modified: torctl/trunk/python/TorCtl/PathSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/PathSupport.py	2009-01-23 23:33:41 UTC (rev 18259)
+++ torctl/trunk/python/TorCtl/PathSupport.py	2009-01-23 23:34:36 UTC (rev 18260)
@@ -53,7 +53,8 @@
 __all__ = ["NodeRestrictionList", "PathRestrictionList",
 "PercentileRestriction", "OSRestriction", "ConserveExitsRestriction",
 "FlagsRestriction", "MinBWRestriction", "VersionIncludeRestriction",
-"VersionExcludeRestriction", "ExitPolicyRestriction", "NodeRestriction",
+"VersionExcludeRestriction", "VersionRangeRestriction", 
+"ExitPolicyRestriction", "NodeRestriction",
 "PathRestriction", "OrNodeRestriction", "MetaNodeRestriction",
 "AtLeastNNodeRestriction", "NotNodeRestriction", "Subnet16Restriction",
 "UniqueRestriction", "NodeGenerator", "UniformGenerator",

Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py	2009-01-23 23:33:41 UTC (rev 18259)
+++ torctl/trunk/python/TorCtl/TorCtl.py	2009-01-23 23:34:36 UTC (rev 18260)
@@ -877,11 +877,13 @@
       event = CircuitEvent(evtype, ident, status, path, purpose, 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+)?(\s+PURPOSE=\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()
       ident,circ = map(int, (ident,circ))
+      if not target: # This can happen on SOCKS_PROTOCOL failures
+        target = "(none)"
       if reason: reason = reason[8:]
       if remote: remote = remote[15:]
       if source: source = source[8:]