OLD | NEW |
| (Empty) |
1 # -*- test-case-name: twisted.conch.test.test_conch -*- | |
2 from interfaces import IConchUser | |
3 from error import ConchError | |
4 from ssh.connection import OPEN_UNKNOWN_CHANNEL_TYPE | |
5 from twisted.python import log | |
6 from zope import interface | |
7 | |
8 class ConchUser: | |
9 interface.implements(IConchUser) | |
10 | |
11 def __init__(self): | |
12 self.channelLookup = {} | |
13 self.subsystemLookup = {} | |
14 | |
15 def lookupChannel(self, channelType, windowSize, maxPacket, data): | |
16 klass = self.channelLookup.get(channelType, None) | |
17 if not klass: | |
18 raise ConchError(OPEN_UNKNOWN_CHANNEL_TYPE, "unknown channel") | |
19 else: | |
20 return klass(remoteWindow = windowSize, | |
21 remoteMaxPacket = maxPacket, | |
22 data=data, avatar=self) | |
23 | |
24 def lookupSubsystem(self, subsystem, data): | |
25 log.msg(repr(self.subsystemLookup)) | |
26 klass = self.subsystemLookup.get(subsystem, None) | |
27 if not klass: | |
28 return False | |
29 return klass(data, avatar=self) | |
30 | |
31 def gotGlobalRequest(self, requestType, data): | |
32 # XXX should this use method dispatch? | |
33 requestType = requestType.replace('-','_') | |
34 f = getattr(self, "global_%s" % requestType, None) | |
35 if not f: | |
36 return 0 | |
37 return f(data) | |
OLD | NEW |