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

[or-cvs] r8466: Make exitlist only output each result line once. (in tor/trunk: . contrib doc)



Author: nickm
Date: 2006-09-22 16:20:35 -0400 (Fri, 22 Sep 2006)
New Revision: 8466

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/contrib/exitlist
   tor/trunk/doc/TODO
Log:
 r8911@Kushana:  nickm | 2006-09-22 12:24:52 -0400
 Make exitlist only output each result line once.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/branches/eventdns [r8911] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-09-22 20:20:26 UTC (rev 8465)
+++ tor/trunk/ChangeLog	2006-09-22 20:20:35 UTC (rev 8466)
@@ -32,6 +32,8 @@
       malloc(0) returns a pointer.
     - Fix a debug log message in eventdns to say "X resolved to Y"
       instead of "X resolved to X".
+    - Prevent the 'exitlist' script from printing the same result more
+      than once.
 
   o Documentation
     - Documented (and renamed) ServerDNSSearchDomains and

Modified: tor/trunk/contrib/exitlist
===================================================================
--- tor/trunk/contrib/exitlist	2006-09-22 20:20:26 UTC (rev 8465)
+++ tor/trunk/contrib/exitlist	2006-09-22 20:20:35 UTC (rev 8466)
@@ -200,6 +200,13 @@
         self.ip = ip
         self.policy = policy
 
+def uniq_sort(lst):
+    d = {}
+    for item in lst: d[item] = 1
+    lst = d.keys()
+    lst.sort()
+    return lst
+
 def run():
     servers = []
     policy = []
@@ -237,12 +244,13 @@
     else:
         printlist = accepters
 
+    ents = []
     if VERBOSE:
-        for s in printlist:
-            print "%s\t%s"%(s.ip,s.name)
+        ents = uniq_sort([ "%s\t%s"%(s.ip,s.name) for s in printlist ])
     else:
-        for s in printlist:
-            print s.ip
+        ents = uniq_sort([ s.ip for s in printlist ])
+    for e in ents:
+        print e
 
 def _test():
     import doctest, exitparse

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2006-09-22 20:20:26 UTC (rev 8465)
+++ tor/trunk/doc/TODO	2006-09-22 20:20:35 UTC (rev 8466)
@@ -165,7 +165,7 @@
 M   - rewrite how libevent does select() on win32 so it's not so very slow.
       - Add overlapped IO
 
-N - Exitlist should avoid outputting the same IP address twice.
+  o Exitlist should avoid outputting the same IP address twice.
 
 Nd- Have a mode that doesn't write to disk much, so we can run Tor on
     flash memory (e.g. Linksys routers or USB keys).