1 # Read username, output from factory interfacing to OS, drop connections
3 from twisted.internet import protocol, reactor, defer, utils
4 from twisted.protocols import basic
6 class FingerProtocol(basic.LineReceiver):
7 def lineReceived(self, user):
8 d = self.factory.getUser(user)
11 return 'Internal error in server'
14 def writeResponse(message):
15 self.transport.write(message + '\r\n')
16 self.transport.loseConnection()
17 d.addCallback(writeResponse)
19 class FingerFactory(protocol.ServerFactory):
20 protocol = FingerProtocol
22 def getUser(self, user):
23 return utils.getProcessOutput("finger", [user])
25 reactor.listenTCP(1079, FingerFactory())