OLD | NEW |
| (Empty) |
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories. | |
2 # See LICENSE for details. | |
3 | |
4 | |
5 """The Finger User Information Protocol (RFC 1288)""" | |
6 | |
7 from twisted.protocols import basic | |
8 import string | |
9 | |
10 class Finger(basic.LineReceiver): | |
11 | |
12 def lineReceived(self, line): | |
13 parts = string.split(line) | |
14 if not parts: | |
15 parts = [''] | |
16 if len(parts) == 1: | |
17 slash_w = 0 | |
18 else: | |
19 slash_w = 1 | |
20 user = parts[-1] | |
21 if '@' in user: | |
22 host_place = string.rfind(user, '@') | |
23 user = user[:host_place] | |
24 host = user[host_place+1:] | |
25 return self.forwardQuery(slash_w, user, host) | |
26 if user: | |
27 return self.getUser(slash_w, user) | |
28 else: | |
29 return self.getDomain(slash_w) | |
30 | |
31 def _refuseMessage(self, message): | |
32 self.transport.write(message+"\n") | |
33 self.transport.loseConnection() | |
34 | |
35 def forwardQuery(self, slash_w, user, host): | |
36 self._refuseMessage('Finger forwarding service denied') | |
37 | |
38 def getDomain(self, slash_w): | |
39 self._refuseMessage('Finger online list denied') | |
40 | |
41 def getUser(self, slash_w, user): | |
42 self.transport.write('Login: '+user+'\n') | |
43 self._refuseMessage('No such user') | |
OLD | NEW |