-#! /usr/bin/python
+# This file is part of python-rwhoisd
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
import sys, socket, SocketServer
def handle(self):
- print repr(self.request)
self.quit_flag = False
# output a banner
# we can skip blank lines.
if not line:
continue
-
- if line.startswith("-"):
- self.handle_directive(session, line)
- else:
- self.handle_query(session, line)
- if not session.holdconnect:
- self.quit_flag = True
+
+ try:
+ if line.startswith("-"):
+ self.handle_directive(session, line)
+ else:
+ self.handle_query(session, line)
+ if not session.holdconnect:
+ self.quit_flag = True
+ except Rwhois.RwhoisError, e:
+ self.handle_error(session, e)
self.wfile.flush()
print "%s query %s" % (self.client_address, line)
query_processor.process_query(session, line)
+ def handle_error(self, session, error):
+ code = error[0]
+ msg = error[1]
+ session.wfile.write(Rwhois.error_message((code, msg)))
def usage(pname):
print """\