~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/conch/ssh/service.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-01-16 19:56:10 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060116195610-ykmxbia4mnnod9o2
Tags: 2.1.0-0ubuntu2
debian/copyright: Include copyright for python 2.3; some 2.3 files
are included in the upstream tarball, but not in the binary packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2
 
# See LICENSE for details.
3
 
 
4
 
5
 
 
6
 
"""The parent class for all the SSH services.  Currently implemented services are: ssh-userauth and ssh-connection.
7
 
 
8
 
This module is unstable.
9
 
 
10
 
Maintainer: U{Paul Swartz<mailto:z3p@twistedmatrix.com>}
11
 
"""
12
 
 
13
 
 
14
 
from twisted.python import log
15
 
 
16
 
class SSHService(log.Logger):
17
 
    name = None # this is the ssh name for the service
18
 
    protocolMessages = {} # these map #'s -> protocol names
19
 
    transport = None # gets set later
20
 
 
21
 
    def serviceStarted(self):
22
 
        """
23
 
        called when the service is active on the transport.
24
 
        """
25
 
 
26
 
    def serviceStopped(self):
27
 
        """
28
 
        called when the service is stopped, either by the connection ending
29
 
        or by another service being started
30
 
        """
31
 
 
32
 
    def logPrefix(self):
33
 
        return "SSHService %s on %s" % (self.name, self.transport.transport.logPrefix())
34
 
 
35
 
    def packetReceived(self, messageType, packet):
36
 
        """
37
 
        called when we receieve a packet on the transport
38
 
        """
39
 
        #print self.protocolMessages
40
 
        f = getattr(self,'ssh_%s' % self.protocolMessages[messageType][4:], None)
41
 
        if f:
42
 
            f(packet)            
43
 
        else:                     
44
 
            log.msg("couldn't handle", messageType)
45
 
            log.msg(repr(packet[1:]))
46
 
            self.transport.sendUnimplemented()
47