[Twisted-Python] Telnet server: localecho "ON" for linux client but not for windows client
filoufake-python at yahoo.fr
filoufake-python at yahoo.fr
Mon Nov 16 07:14:49 MST 2009
Hello,
Some month ago, exarkun helped me in the development of a very simplified
telnet server.
I observed that when I connect from a windows client, the LOCALECHO
is set to "OFF" after the authentication. I cannot set it "ON"
afterwards. Everything typed in the client console is hidden.
When I use a linux client, the "ECHO" is OFF just for typing the
password and then ON again.
Does someone has an idea how to do with the windows client?
I tried to set the ECHO ON using self.transport.will(ECHO) but that
doesn't work.
Here is the code:
############################################################
import sys
from zope.interface import implements
from twisted.internet import protocol
from twisted.python import log
from twisted.cred import error
from twisted.cred import portal
from twisted.cred import checkers
from twisted.cred import credentials
from twisted.conch.telnet import AuthenticatingTelnetProtocol
from twisted.conch.telnet import StatefulTelnetProtocol
from twisted.conch.telnet import ITelnetProtocol
from twisted.conch.telnet import TelnetTransport
from twisted.conch.telnet import ECHO
class Realm:
implements(portal.IRealm)
def requestAvatar(self, avatarId, mind, *interfaces):
if ITelnetProtocol in interfaces:
av = MyTelnet()
av.transport.will(ECHO)
av.state = 'Command'
return ITelnetProtocol, av, lambda:None
raise NotImplementedError("Not supported by this realm")
class MyTelnet(StatefulTelnetProtocol):
def telnet_Command(self, line):
print "line received via telnet", line
self.sendLine('coucou man, you send me %s' % line)
def main():
r = Realm()
p = portal.Portal(r)
c = checkers.InMemoryUsernamePasswordDatabaseDontUse()
c.addUser("AA", "aa")
p.registerChecker(c)
p.registerChecker(checkers.AllowAnonymousAccess())
f = protocol.ServerFactory()
f.protocol = lambda: TelnetTransport(AuthenticatingTelnetProtocol, p)
log.startLogging(sys.stdout)
from twisted.internet import reactor
reactor.listenTCP(4738, f)
reactor.run()
if __name__ == '__main__':
main()
############################################################
Best Regards,
Philippe
More information about the Twisted-Python
mailing list