Commit 50f9a519 authored by Amos Latteier's avatar Amos Latteier

Added informational logging to Medusa! No longer does medusa report problems and information

with print statements. This is accomplished by adding a log_info method to asyncore.dispatcher.
I've sent the patches to Sam, and he indicates that he will accept them.
parent 5177144c
# -*- Mode: Python; tab-width: 4 -*-
# $Id: asyncore.py,v 1.4 1999/05/27 21:57:23 amos Exp $
# $Id: asyncore.py,v 1.5 1999/07/20 16:53:49 amos Exp $
# Author: Sam Rushing <rushing@nightmare.com>
# ======================================================================
......@@ -143,14 +143,12 @@ class dispatcher:
return '<__repr__ (self) failed for object at %x (addr=%s)>' % (id(self),ar)
def add_channel (self):
if __debug__:
self.log ('adding channel %s' % self)
self.log_info ('adding channel %s' % self)
socket_map [self] = 1
def del_channel (self):
if socket_map.has_key (self):
if __debug__:
self.log ('closing channel %d:%s' % (self.fileno(), self))
self.log_info ('closing channel %d:%s' % (self.fileno(), self))
del socket_map [self]
def create_socket (self, family, type):
......@@ -267,8 +265,16 @@ class dispatcher:
def __getattr__ (self, attr):
return getattr (self.socket, attr)
# log and log_info maybe overriden to provide more sophisitcated
# logging and warning methods. In general, log is for 'hit' logging
# and 'log_info' is for informational, warning and error logging.
def log (self, message):
print 'log:', message
def log_info (self, message, type='info'):
if __debug__ or type != 'info':
print '%s: %s' %(type, message)
def handle_read_event (self):
if self.accepting:
......@@ -303,39 +309,34 @@ class dispatcher:
except:
self_repr = '<__repr__ (self) failed for object at %0x>' % id(self)
print (
self.log_info (
'uncaptured python exception, closing channel %s (%s:%s %s)' % (
self_repr,
t,
v,
tbinfo
)
),
'error'
)
self.close()
def handle_expt (self):
if __debug__:
self.log ('unhandled exception')
self.log_info ('unhandled exception', 'warning')
def handle_read (self):
if __debug__:
self.log ('unhandled read event')
self.log_info ('unhandled read event', 'waring')
def handle_write (self):
if __debug__:
self.log ('unhandled write event')
self.log_info ('unhandled write event', 'warning')
def handle_connect (self):
if __debug__:
self.log ('unhandled connect event')
self.log_info ('unhandled connect event', 'warning')
def handle_accept (self):
if __debug__:
self.log ('unhandled accept event')
self.log_info ('unhandled accept event', 'warning')
def handle_close (self):
if __debug__:
self.log ('unhandled close event')
self.log_info ('unhandled close event', 'warning')
self.close()
# ---------------------------------------------------------------------------
......@@ -361,7 +362,7 @@ class dispatcher_with_send (dispatcher):
def send (self, data):
if self.debug:
self.log ('sending %s' % repr(data))
self.log_info ('sending %s' % repr(data))
self.out_buffer = self.out_buffer + data
self.initiate_send()
......
......@@ -8,7 +8,7 @@
# If you are interested in using this software in a commercial context,
# or in purchasing support, please contact the author.
RCS_ID = '$Id: ftp_server.py,v 1.5 1999/05/26 02:08:30 amos Exp $'
RCS_ID = '$Id: ftp_server.py,v 1.6 1999/07/20 16:53:49 amos Exp $'
# An extensible, configurable, asynchronous FTP server.
#
......@@ -481,7 +481,7 @@ class ftp_channel (asynchat.async_chat):
else:
file = line[1]
if not self.filesystem.isfile (file):
print 'checking %s' % file
self.log_info ('checking %s' % file)
self.respond ('550 No such file')
else:
try:
......@@ -603,7 +603,7 @@ class ftp_channel (asynchat.async_chat):
self.respond ('230 %s' % message)
self.filesystem = fs
self.authorized = 1
self.log ('Successful login: Filesystem=%s' % repr(fs))
self.log_info('Successful login: Filesystem=%s' % repr(fs))
else:
self.respond ('530 %s' % message)
......@@ -732,11 +732,11 @@ class ftp_server (asyncore.dispatcher):
else:
self.logger = logger.unresolving_logger (logger_object)
print 'FTP server started at %s\n\tAuthorizer:%s\n\tHostname: %s\n\tPort: %d' % (
self.log_info('FTP server started at %s\n\tAuthorizer:%s\n\tHostname: %s\n\tPort: %d' % (
time.ctime(time.time()),
repr (self.authorizer),
self.hostname,
self.port
self.port)
)
def writable (self):
......@@ -751,7 +751,7 @@ class ftp_server (asyncore.dispatcher):
def handle_accept (self):
conn, addr = self.accept()
self.total_sessions.increment()
print 'Incoming connection from %s:%d' % (addr[0], addr[1])
self.log_info('Incoming connection from %s:%d' % (addr[0], addr[1]))
self.ftp_channel_class (self, conn, addr)
# return a producer describing the state of the server
......@@ -873,7 +873,7 @@ class xmit_channel (asynchat.async_chat):
def handle_error (self):
# usually this is to catch an unexpected disconnect.
self.log ('unexpected disconnect on data xmit channel')
self.log_info ('unexpected disconnect on data xmit channel', 'error')
try:
self.close()
except:
......@@ -929,7 +929,7 @@ class recv_channel (asyncore.dispatcher):
try:
self.fd.write (block)
except IOError:
print 'got exception writing block...'
self.log_info ('got exception writing block...', 'error')
def handle_close (self):
s = self.channel.server
......@@ -1060,7 +1060,7 @@ if os.name == 'posix':
try:
asyncore.loop()
except KeyboardInterrupt:
print 'FTP server shutting down. (received SIGINT)'
self.log_info('FTP server shutting down. (received SIGINT)', 'warning')
# close everything down on SIGINT.
# of course this should be a cleaner shutdown.
sm = socket.socket_map
......
......@@ -9,7 +9,7 @@
# interested in using this software in a commercial context, or in
# purchasing support, please contact the author.
RCS_ID = '$Id: http_server.py,v 1.7 1999/05/26 02:08:30 amos Exp $'
RCS_ID = '$Id: http_server.py,v 1.8 1999/07/20 16:53:49 amos Exp $'
# python modules
import os
......@@ -142,16 +142,18 @@ class http_request:
if self.collector:
self.collector.collect_incoming_data (data)
else:
sys.stderr.write (
'warning: dropping %d bytes of incoming request data\n' % len(data)
self.log_info(
'Dropping %d bytes of incoming request data' % len(data),
'warning'
)
def found_terminator (self):
if self.collector:
self.collector.found_terminator()
else:
sys.stderr.write (
'warning: unexpected end-of-record for incoming request\n'
self.log_info (
'Unexpected end-of-record for incoming request',
'warning'
)
def push (self, thing):
......@@ -461,8 +463,9 @@ class http_channel (asynchat.async_chat):
except:
self.server.exceptions.increment()
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
# Log this to a better place.
print 'Server Error: %s, %s: file: %s line: %s' % (t,v,file,line)
self.log_info(
'Server Error: %s, %s: file: %s line: %s' % (t,v,file,line),
'error')
try:
r.error (500)
except:
......@@ -521,12 +524,12 @@ class http_server (asyncore.dispatcher):
host, port = self.socket.getsockname()
if not ip:
print 'Warning: computing default hostname'
self.log_info('Computing default hostname', 'warning')
ip = socket.gethostbyname (socket.gethostname())
try:
self.server_name = socket.gethostbyaddr (ip)[0]
except socket.error:
print 'Warning: cannot do reverse lookup'
self.log_info('Cannot do reverse lookup', 'warning')
self.server_name = ip # use the IP address as the "hostname"
self.server_port = port
......@@ -544,7 +547,7 @@ class http_server (asyncore.dispatcher):
else:
self.logger = logger.unresolving_logger (logger_object)
sys.stdout.write (
self.log_info (
'Medusa (V%s) started at %s'
'\n\tHostname: %s'
'\n\tPort:%d'
......@@ -577,7 +580,7 @@ class http_server (asyncore.dispatcher):
# accept. socketmodule.c:makesockaddr complains that the
# address family is unknown. We don't want the whole server
# to shut down because of this.
sys.stderr.write ('warning: server accept() threw an exception\n')
self.log_info('Server accept() threw an exception', 'warning')
return
self.channel_class (self, conn, addr)
......
......@@ -19,7 +19,7 @@ def max_server_sockets():
sl.append (s)
except:
break
num = len(sl) - 1
num = len(sl)
for s in sl:
s.close()
del sl
......@@ -39,7 +39,7 @@ def max_client_sockets():
sl.append ((s,conn))
except:
break
num = len(sl) - 1
num = len(sl)
for s,c in sl:
s.close()
c.close()
......
......@@ -5,7 +5,7 @@
# python REPL channel.
#
RCS_ID = '$Id: monitor.py,v 1.2 1999/05/27 17:25:55 amos Exp $'
RCS_ID = '$Id: monitor.py,v 1.3 1999/07/20 16:53:50 amos Exp $'
import md5
import socket
......@@ -93,7 +93,7 @@ class monitor_channel (asynchat.async_chat):
result = eval (co, self.local_env)
method = 'eval'
if result is not None:
print repr(result)
self.log_info(repr(result))
self.local_env['_'] = result
except SyntaxError:
try:
......@@ -120,15 +120,15 @@ class monitor_channel (asynchat.async_chat):
method = 'exception'
self.multi_line = []
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
print t, v, tbinfo
self.log_info('%s %s %s' %(t, v, tbinfo), 'warning')
finally:
sys.stdout = oldout
sys.stderr = olderr
print '%s:%s (%s)> %s' % (
self.log_info('%s:%s (%s)> %s' % (
self.number,
self.line_counter,
method,
repr(line)
repr(line))
)
self.push_with_producer (p)
self.prompt()
......@@ -161,7 +161,7 @@ class monitor_server (asyncore.dispatcher):
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind ((hostname, port))
print '%s started on port %d' % (self.SERVER_IDENT, port)
self.log_info('%s started on port %d' % (self.SERVER_IDENT, port))
self.listen (5)
self.closed = 0
self.failed_auths = 0
......@@ -173,7 +173,7 @@ class monitor_server (asyncore.dispatcher):
def handle_accept (self):
conn, addr = self.accept()
print 'Incoming monitor connection from %s:%d' % addr
self.log_info('Incoming monitor connection from %s:%d' % addr)
self.channel_class (self, conn, addr)
self.total_sessions.increment()
......@@ -216,7 +216,7 @@ class secure_monitor_channel (monitor_channel):
def found_terminator (self):
if not self.authorized:
if hex_digest ('%s%s' % (self.timestamp, self.server.password)) != self.data:
self.log ('%s: failed authorization' % self)
self.log_info ('%s: failed authorization' % self, 'warning')
self.server.failed_auths = self.server.failed_auths + 1
self.close()
else:
......
......@@ -4,7 +4,7 @@
# Author: Sam Rushing <rushing@nightmare.com>
#
RCS_ID = '$Id: resolver.py,v 1.3 1999/05/26 02:08:30 amos Exp $'
RCS_ID = '$Id: resolver.py,v 1.4 1999/07/20 16:53:50 amos Exp $'
# Fast, low-overhead asynchronous name resolver. uses 'pre-cooked'
......@@ -212,12 +212,14 @@ class resolver (asyncore.dispatcher):
pass
def handle_close (self):
print 'closing!'
self.log_info('closing!')
self.close()
def handle_error (self): # don't close the connection on error
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
print 'Problem with DNS lookup (%s:%s %s)' % (t, v, tbinfo)
self.log_info(
'Problem with DNS lookup (%s:%s %s)' % (t, v, tbinfo),
'error')
def get_id (self):
return (self.id.as_long() % (1<<16))
......@@ -233,7 +235,7 @@ class resolver (asyncore.dispatcher):
callback (host, 0, None) # timeout val is (0,None)
except:
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
print t,v,tbinfo
self.log_info('%s %s %s' % (t,v,tbinfo), 'error')
def resolve (self, host, callback):
self.reap() # first, get rid of old guys
......@@ -271,7 +273,7 @@ class resolver (asyncore.dispatcher):
callback (host, ttl, answer)
except:
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
print t,v,tbinfo
self.log_info('%s %s %s' % ( t,v,tbinfo), 'error')
class rbl (resolver):
......@@ -289,8 +291,7 @@ class rbl (resolver):
def check_reply (self, r):
# we only need to check RCODE.
rcode = (ord(r[3])&0xf)
print 'MAPS RBL; RCODE =%02x' % rcode
print repr(r)
self.log_info('MAPS RBL; RCODE =%02x\n %s' % (rcode, repr(r)))
return 0, rcode # (ttl, answer)
......
# -*- Mode: Python; tab-width: 4 -*-
VERSION_STRING = "$Id: select_trigger.py,v 1.4 1999/06/15 18:50:16 amos Exp $"
VERSION_STRING = "$Id: select_trigger.py,v 1.5 1999/07/20 16:53:50 amos Exp $"
import asyncore
import asynchat
......@@ -82,7 +82,9 @@ if os.name == 'posix':
thunk()
except:
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo)
self.log_info(
'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo),
'error')
self.thunks = []
finally:
self.lock.release()
......@@ -145,7 +147,9 @@ else:
thunk()
except:
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo)
self.log_info(
'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo),
'error')
self.thunks = []
finally:
self.lock.release()
......
# -*- Mode: Python; tab-width: 4 -*-
# $Id: asyncore.py,v 1.4 1999/05/27 21:57:23 amos Exp $
# $Id: asyncore.py,v 1.5 1999/07/20 16:53:49 amos Exp $
# Author: Sam Rushing <rushing@nightmare.com>
# ======================================================================
......@@ -143,14 +143,12 @@ class dispatcher:
return '<__repr__ (self) failed for object at %x (addr=%s)>' % (id(self),ar)
def add_channel (self):
if __debug__:
self.log ('adding channel %s' % self)
self.log_info ('adding channel %s' % self)
socket_map [self] = 1
def del_channel (self):
if socket_map.has_key (self):
if __debug__:
self.log ('closing channel %d:%s' % (self.fileno(), self))
self.log_info ('closing channel %d:%s' % (self.fileno(), self))
del socket_map [self]
def create_socket (self, family, type):
......@@ -267,8 +265,16 @@ class dispatcher:
def __getattr__ (self, attr):
return getattr (self.socket, attr)
# log and log_info maybe overriden to provide more sophisitcated
# logging and warning methods. In general, log is for 'hit' logging
# and 'log_info' is for informational, warning and error logging.
def log (self, message):
print 'log:', message
def log_info (self, message, type='info'):
if __debug__ or type != 'info':
print '%s: %s' %(type, message)
def handle_read_event (self):
if self.accepting:
......@@ -303,39 +309,34 @@ class dispatcher:
except:
self_repr = '<__repr__ (self) failed for object at %0x>' % id(self)
print (
self.log_info (
'uncaptured python exception, closing channel %s (%s:%s %s)' % (
self_repr,
t,
v,
tbinfo
)
),
'error'
)
self.close()
def handle_expt (self):
if __debug__:
self.log ('unhandled exception')
self.log_info ('unhandled exception', 'warning')
def handle_read (self):
if __debug__:
self.log ('unhandled read event')
self.log_info ('unhandled read event', 'waring')
def handle_write (self):
if __debug__:
self.log ('unhandled write event')
self.log_info ('unhandled write event', 'warning')
def handle_connect (self):
if __debug__:
self.log ('unhandled connect event')
self.log_info ('unhandled connect event', 'warning')
def handle_accept (self):
if __debug__:
self.log ('unhandled accept event')
self.log_info ('unhandled accept event', 'warning')
def handle_close (self):
if __debug__:
self.log ('unhandled close event')
self.log_info ('unhandled close event', 'warning')
self.close()
# ---------------------------------------------------------------------------
......@@ -361,7 +362,7 @@ class dispatcher_with_send (dispatcher):
def send (self, data):
if self.debug:
self.log ('sending %s' % repr(data))
self.log_info ('sending %s' % repr(data))
self.out_buffer = self.out_buffer + data
self.initiate_send()
......
......@@ -8,7 +8,7 @@
# If you are interested in using this software in a commercial context,
# or in purchasing support, please contact the author.
RCS_ID = '$Id: ftp_server.py,v 1.5 1999/05/26 02:08:30 amos Exp $'
RCS_ID = '$Id: ftp_server.py,v 1.6 1999/07/20 16:53:49 amos Exp $'
# An extensible, configurable, asynchronous FTP server.
#
......@@ -481,7 +481,7 @@ class ftp_channel (asynchat.async_chat):
else:
file = line[1]
if not self.filesystem.isfile (file):
print 'checking %s' % file
self.log_info ('checking %s' % file)
self.respond ('550 No such file')
else:
try:
......@@ -603,7 +603,7 @@ class ftp_channel (asynchat.async_chat):
self.respond ('230 %s' % message)
self.filesystem = fs
self.authorized = 1
self.log ('Successful login: Filesystem=%s' % repr(fs))
self.log_info('Successful login: Filesystem=%s' % repr(fs))
else:
self.respond ('530 %s' % message)
......@@ -732,11 +732,11 @@ class ftp_server (asyncore.dispatcher):
else:
self.logger = logger.unresolving_logger (logger_object)
print 'FTP server started at %s\n\tAuthorizer:%s\n\tHostname: %s\n\tPort: %d' % (
self.log_info('FTP server started at %s\n\tAuthorizer:%s\n\tHostname: %s\n\tPort: %d' % (
time.ctime(time.time()),
repr (self.authorizer),
self.hostname,
self.port
self.port)
)
def writable (self):
......@@ -751,7 +751,7 @@ class ftp_server (asyncore.dispatcher):
def handle_accept (self):
conn, addr = self.accept()
self.total_sessions.increment()
print 'Incoming connection from %s:%d' % (addr[0], addr[1])
self.log_info('Incoming connection from %s:%d' % (addr[0], addr[1]))
self.ftp_channel_class (self, conn, addr)
# return a producer describing the state of the server
......@@ -873,7 +873,7 @@ class xmit_channel (asynchat.async_chat):
def handle_error (self):
# usually this is to catch an unexpected disconnect.
self.log ('unexpected disconnect on data xmit channel')
self.log_info ('unexpected disconnect on data xmit channel', 'error')
try:
self.close()
except:
......@@ -929,7 +929,7 @@ class recv_channel (asyncore.dispatcher):
try:
self.fd.write (block)
except IOError:
print 'got exception writing block...'
self.log_info ('got exception writing block...', 'error')
def handle_close (self):
s = self.channel.server
......@@ -1060,7 +1060,7 @@ if os.name == 'posix':
try:
asyncore.loop()
except KeyboardInterrupt:
print 'FTP server shutting down. (received SIGINT)'
self.log_info('FTP server shutting down. (received SIGINT)', 'warning')
# close everything down on SIGINT.
# of course this should be a cleaner shutdown.
sm = socket.socket_map
......
......@@ -9,7 +9,7 @@
# interested in using this software in a commercial context, or in
# purchasing support, please contact the author.
RCS_ID = '$Id: http_server.py,v 1.7 1999/05/26 02:08:30 amos Exp $'
RCS_ID = '$Id: http_server.py,v 1.8 1999/07/20 16:53:49 amos Exp $'
# python modules
import os
......@@ -142,16 +142,18 @@ class http_request:
if self.collector:
self.collector.collect_incoming_data (data)
else:
sys.stderr.write (
'warning: dropping %d bytes of incoming request data\n' % len(data)
self.log_info(
'Dropping %d bytes of incoming request data' % len(data),
'warning'
)
def found_terminator (self):
if self.collector:
self.collector.found_terminator()
else:
sys.stderr.write (
'warning: unexpected end-of-record for incoming request\n'
self.log_info (
'Unexpected end-of-record for incoming request',
'warning'
)
def push (self, thing):
......@@ -461,8 +463,9 @@ class http_channel (asynchat.async_chat):
except:
self.server.exceptions.increment()
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
# Log this to a better place.
print 'Server Error: %s, %s: file: %s line: %s' % (t,v,file,line)
self.log_info(
'Server Error: %s, %s: file: %s line: %s' % (t,v,file,line),
'error')
try:
r.error (500)
except:
......@@ -521,12 +524,12 @@ class http_server (asyncore.dispatcher):
host, port = self.socket.getsockname()
if not ip:
print 'Warning: computing default hostname'
self.log_info('Computing default hostname', 'warning')
ip = socket.gethostbyname (socket.gethostname())
try:
self.server_name = socket.gethostbyaddr (ip)[0]
except socket.error:
print 'Warning: cannot do reverse lookup'
self.log_info('Cannot do reverse lookup', 'warning')
self.server_name = ip # use the IP address as the "hostname"
self.server_port = port
......@@ -544,7 +547,7 @@ class http_server (asyncore.dispatcher):
else:
self.logger = logger.unresolving_logger (logger_object)
sys.stdout.write (
self.log_info (
'Medusa (V%s) started at %s'
'\n\tHostname: %s'
'\n\tPort:%d'
......@@ -577,7 +580,7 @@ class http_server (asyncore.dispatcher):
# accept. socketmodule.c:makesockaddr complains that the
# address family is unknown. We don't want the whole server
# to shut down because of this.
sys.stderr.write ('warning: server accept() threw an exception\n')
self.log_info('Server accept() threw an exception', 'warning')
return
self.channel_class (self, conn, addr)
......
......@@ -19,7 +19,7 @@ def max_server_sockets():
sl.append (s)
except:
break
num = len(sl) - 1
num = len(sl)
for s in sl:
s.close()
del sl
......@@ -39,7 +39,7 @@ def max_client_sockets():
sl.append ((s,conn))
except:
break
num = len(sl) - 1
num = len(sl)
for s,c in sl:
s.close()
c.close()
......
......@@ -5,7 +5,7 @@
# python REPL channel.
#
RCS_ID = '$Id: monitor.py,v 1.2 1999/05/27 17:25:55 amos Exp $'
RCS_ID = '$Id: monitor.py,v 1.3 1999/07/20 16:53:50 amos Exp $'
import md5
import socket
......@@ -93,7 +93,7 @@ class monitor_channel (asynchat.async_chat):
result = eval (co, self.local_env)
method = 'eval'
if result is not None:
print repr(result)
self.log_info(repr(result))
self.local_env['_'] = result
except SyntaxError:
try:
......@@ -120,15 +120,15 @@ class monitor_channel (asynchat.async_chat):
method = 'exception'
self.multi_line = []
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
print t, v, tbinfo
self.log_info('%s %s %s' %(t, v, tbinfo), 'warning')
finally:
sys.stdout = oldout
sys.stderr = olderr
print '%s:%s (%s)> %s' % (
self.log_info('%s:%s (%s)> %s' % (
self.number,
self.line_counter,
method,
repr(line)
repr(line))
)
self.push_with_producer (p)
self.prompt()
......@@ -161,7 +161,7 @@ class monitor_server (asyncore.dispatcher):
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind ((hostname, port))
print '%s started on port %d' % (self.SERVER_IDENT, port)
self.log_info('%s started on port %d' % (self.SERVER_IDENT, port))
self.listen (5)
self.closed = 0
self.failed_auths = 0
......@@ -173,7 +173,7 @@ class monitor_server (asyncore.dispatcher):
def handle_accept (self):
conn, addr = self.accept()
print 'Incoming monitor connection from %s:%d' % addr
self.log_info('Incoming monitor connection from %s:%d' % addr)
self.channel_class (self, conn, addr)
self.total_sessions.increment()
......@@ -216,7 +216,7 @@ class secure_monitor_channel (monitor_channel):
def found_terminator (self):
if not self.authorized:
if hex_digest ('%s%s' % (self.timestamp, self.server.password)) != self.data:
self.log ('%s: failed authorization' % self)
self.log_info ('%s: failed authorization' % self, 'warning')
self.server.failed_auths = self.server.failed_auths + 1
self.close()
else:
......
......@@ -4,7 +4,7 @@
# Author: Sam Rushing <rushing@nightmare.com>
#
RCS_ID = '$Id: resolver.py,v 1.3 1999/05/26 02:08:30 amos Exp $'
RCS_ID = '$Id: resolver.py,v 1.4 1999/07/20 16:53:50 amos Exp $'
# Fast, low-overhead asynchronous name resolver. uses 'pre-cooked'
......@@ -212,12 +212,14 @@ class resolver (asyncore.dispatcher):
pass
def handle_close (self):
print 'closing!'
self.log_info('closing!')
self.close()
def handle_error (self): # don't close the connection on error
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
print 'Problem with DNS lookup (%s:%s %s)' % (t, v, tbinfo)
self.log_info(
'Problem with DNS lookup (%s:%s %s)' % (t, v, tbinfo),
'error')
def get_id (self):
return (self.id.as_long() % (1<<16))
......@@ -233,7 +235,7 @@ class resolver (asyncore.dispatcher):
callback (host, 0, None) # timeout val is (0,None)
except:
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
print t,v,tbinfo
self.log_info('%s %s %s' % (t,v,tbinfo), 'error')
def resolve (self, host, callback):
self.reap() # first, get rid of old guys
......@@ -271,7 +273,7 @@ class resolver (asyncore.dispatcher):
callback (host, ttl, answer)
except:
(file,fun,line), t, v, tbinfo = asyncore.compact_traceback()
print t,v,tbinfo
self.log_info('%s %s %s' % ( t,v,tbinfo), 'error')
class rbl (resolver):
......@@ -289,8 +291,7 @@ class rbl (resolver):
def check_reply (self, r):
# we only need to check RCODE.
rcode = (ord(r[3])&0xf)
print 'MAPS RBL; RCODE =%02x' % rcode
print repr(r)
self.log_info('MAPS RBL; RCODE =%02x\n %s' % (rcode, repr(r)))
return 0, rcode # (ttl, answer)
......
# -*- Mode: Python; tab-width: 4 -*-
VERSION_STRING = "$Id: select_trigger.py,v 1.4 1999/06/15 18:50:16 amos Exp $"
VERSION_STRING = "$Id: select_trigger.py,v 1.5 1999/07/20 16:53:50 amos Exp $"
import asyncore
import asynchat
......@@ -82,7 +82,9 @@ if os.name == 'posix':
thunk()
except:
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo)
self.log_info(
'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo),
'error')
self.thunks = []
finally:
self.lock.release()
......@@ -145,7 +147,9 @@ else:
thunk()
except:
(file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
print 'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo)
self.log_info(
'exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo),
'error')
self.thunks = []
finally:
self.lock.release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment