From e6388729308c457b4569912864e9791871c54aa6 Mon Sep 17 00:00:00 2001 From: David Blacka Date: Sat, 21 Jun 2008 12:14:20 -0400 Subject: [PATCH] inet_pton compat stuff basically working --- TODO | 32 ++++++++++++++++++++++++++++++++ rwhoisd/Cidr.py | 3 +-- rwhoisd/RwhoisServer.py | 4 +--- rwhoisd/v6addr.py | 9 +++++---- 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 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. + diff --git a/rwhoisd/Cidr.py b/rwhoisd/Cidr.py index 30eee88..88d46d3 100644 --- a/rwhoisd/Cidr.py +++ b/rwhoisd/Cidr.py @@ -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.""" diff --git a/rwhoisd/RwhoisServer.py b/rwhoisd/RwhoisServer.py index e46a7d5..2729f85 100644 --- a/rwhoisd/RwhoisServer.py +++ b/rwhoisd/RwhoisServer.py @@ -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 diff --git a/rwhoisd/v6addr.py b/rwhoisd/v6addr.py index 8917f79..d42d63b 100644 --- a/rwhoisd/v6addr.py +++ b/rwhoisd/v6addr.py @@ -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") -- 2.36.6