inet_pton compat stuff basically working
authorDavid Blacka <david@blacka.com>
Sat, 21 Jun 2008 16:14:20 +0000 (12:14 -0400)
committerDavid Blacka <david@blacka.com>
Sat, 21 Jun 2008 16:14:20 +0000 (12:14 -0400)
TODO [new file with mode: 0644]
rwhoisd/Cidr.py
rwhoisd/RwhoisServer.py
rwhoisd/v6addr.py

diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..6a4c862
--- /dev/null
+++ b/TODO
@@ -0,0 +1,32 @@
+This is just a simple list of tasks that could be done for
+python-rwhoisd.
+
+
+* Get it working on Windows.
+
+  One of the (few) reasons folks might want to use this RWhois server
+  is that they want to run the server on Windows and think that this
+  one might be easier to get working that the C version.
+
+** Get it to run with the standard command line Window's python.
+
+** Make it a bit more friendly to run.
+
+* Create proper unit tests.
+
+  The code has some relatively decent unit tests embedded in the
+  modules, but these should be separated out and be converted to use
+  unittest.
+
+* Create a BSDDB index.
+
+  This server can't handle a lot of data.  It loads everything into
+  memory and isn't particularly efficient about it.  It is written in
+  python, after all.
+
+  Anyway, the basic way that the in-memory indexes maps fairly well to
+  a bsddb btree indexes.  Differences (besides just actual
+  implementation) is that it is probably easier to just use strings
+  for ordering, which means that IPv6 CIDR indexes would have to be in
+  separate btrees from the v4 indexes.
+
index 30eee88..88d46d3 100644 (file)
@@ -18,6 +18,7 @@
 # USA
 
 import socket, types, copy, bisect, struct
+import v6addr
 
 def new(address, netlen = -1):
     """Construct either a CidrV4 or CidrV6 object."""
@@ -39,8 +40,6 @@ def new(address, netlen = -1):
 class Cidr:
     """A class representing a generic CIDRized network value."""
 
-
-
     def _initialize(self, address, netlen):
         """This a common constructor that is used by the subclasses."""
 
index e46a7d5..2729f85 100644 (file)
@@ -1,8 +1,6 @@
 # This file is part of python-rwhoisd
 #
-# Copyright (C) 2003, David E. Blacka
-#
-# $Id: RwhoisServer.py,v 1.3 2003/04/28 16:45:11 davidb Exp $
+# Copyright (C) 2003, 2008 David E. Blacka
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
index 8917f79..d42d63b 100644 (file)
@@ -21,7 +21,7 @@ import socket, re, struct
 
 # a simplified regex that just makes sure that the IPv6 address string
 # isn't obviously invalid.
-v6char_re = re.compile(r'[0-9a-f:]+(:\d+\.\d+\.\d+\.\d+)?', re.I)
+v6char_re = re.compile(r'^[0-9a-f:]+(:(\d{1,3}\.){3}\d{1,3})?$', re.I)
 
 def v6str_to_addr(addrstr):
     """Convert IPv6 addresses into its packed numerical value."""
@@ -155,7 +155,7 @@ if __name__ == "__main__":
             a = v6str_to_addr(addr)
             b = v6addr_to_str(a)
         except socket.error, e:
-            print e
+            print "addr was invalid!:", e
         else:
             print "%s => %s" % (addr, b)
 
@@ -168,7 +168,7 @@ if __name__ == "__main__":
     try_good_addr("1:2:3::7:8")
     try_good_addr("2001:3c09:102::23:af")
     try_good_addr("::ffff:1.2.3.4")
-    try_good_addr("1:2:3:4:5:6:7:4.3.2.1")
+    try_good_addr("1:2:3:4:5:6:4.3.2.1")
 
     def try_bad_addr(addr):
         try:
@@ -176,7 +176,7 @@ if __name__ == "__main__":
         except socket.error, e:
             print e
         else:
-            print "addr was valid!", addr
+            print "addr was valid! %s => %s" % (addr, v6addr_to_str(a))
 
     # things that shouldn't parse
     try_bad_addr(":")
@@ -185,3 +185,4 @@ if __name__ == "__main__":
     try_bad_addr("::3::")
     try_bad_addr("::1.2.3")
     try_bad_addr("12345::1")
+    try_bad_addr("1:2:3:4:5:6:7:4.3.2.1")