Added robustness changes and manhole stuff.

This commit is contained in:
Jeremy Fincher 2003-04-18 08:24:25 +00:00
parent 1178536288
commit 4cb24f7aa4
1 changed files with 31 additions and 1 deletions

View File

@ -6,10 +6,12 @@ import time
import conf import conf
import debug import debug
import ircdb
import drivers import drivers
import ircmsgs import ircmsgs
from twisted.internet import reactor from twisted.internet import reactor
from twisted.manhole.telnet import Shell, ShellFactory
from twisted.protocols.basic import LineReceiver from twisted.protocols.basic import LineReceiver
from twisted.internet.protocol import ReconnectingClientFactory from twisted.internet.protocol import ReconnectingClientFactory
@ -43,7 +45,13 @@ class SupyIrcProtocol(LineReceiver):
while msg: while msg:
self.transport.write(str(msg)) self.transport.write(str(msg))
msg = self.factory.irc.takeMsg() msg = self.factory.irc.takeMsg()
reactor.callLater(1, self.checkIrcForMsgs) self.mostRecentCall = reactor.callLater(1, self.checkIrcForMsgs)
def connectionLost(self):
self.mostRecentCall.cancel()
def die(self):
self.transport.loseConnection()
class SupyReconnectingFactory(ReconnectingClientFactory): class SupyReconnectingFactory(ReconnectingClientFactory):
maxDelay = 600 maxDelay = 600
@ -53,6 +61,28 @@ class SupyReconnectingFactory(ReconnectingClientFactory):
reactor.connectTCP(server, port, self) reactor.connectTCP(server, port, self)
class MyShell(Shell):
def checkUserAndPass(self, username, password):
debug.printf(repr(username))
debug.printf(repr(password))
try:
u = ircdb.users.getUser(username)
debug.printf(u)
if u.checkPassword(password) and u.checkCapability('owner'):
debug.printf('returning True')
return True
else:
return False
except KeyError:
return False
class MyShellFactory(ShellFactory):
protocol = MyShell
if conf.telnetEnable and __name__ != '__main__':
reactor.listenTCP(conf.telnetPort, MyShellFactory())
try: try:
ignore(poller) ignore(poller)
except NameError: except NameError: