[Twisted-Python] Telnet server: localecho "ON" for linux client but not for windows client

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

I haven't worked with the telnet protocol since the 1.x series honestly and I remember having to add a good bit of code to support all the control functions in order to get things working as nicely as I wanted. That aside, echo (or lack thereof) did work fine, but "will" will not force a client to do anything. I believe you need to use "do"/"dont" to get the effect you desire. -- James Tanis Technical Coordinator Computer Science Department Monsignor Donovan Catholic High School On Nov 16, 2009, at 9:14 AM, filoufake-python@yahoo.fr wrote:

I looked at your code a bit more, read below.
According to the documentation: the default telnet_User method returns 'Password' to go into Password mode, and the default telnet_Password method returns 'Command' to go into Command mode." The problem, I'm guessing, is your reimplementing the telnet_Command method wherein you don't appropriately handle turning echo back on. My suggestion would be to look in Twisted's code to find the "default" command method, there should be something obvious there which performs the function that you need.

I haven't worked with the telnet protocol since the 1.x series honestly and I remember having to add a good bit of code to support all the control functions in order to get things working as nicely as I wanted. That aside, echo (or lack thereof) did work fine, but "will" will not force a client to do anything. I believe you need to use "do"/"dont" to get the effect you desire. -- James Tanis Technical Coordinator Computer Science Department Monsignor Donovan Catholic High School On Nov 16, 2009, at 9:14 AM, filoufake-python@yahoo.fr wrote:

I looked at your code a bit more, read below.
According to the documentation: the default telnet_User method returns 'Password' to go into Password mode, and the default telnet_Password method returns 'Command' to go into Command mode." The problem, I'm guessing, is your reimplementing the telnet_Command method wherein you don't appropriately handle turning echo back on. My suggestion would be to look in Twisted's code to find the "default" command method, there should be something obvious there which performs the function that you need.
participants (2)
-
filoufake-python@yahoo.fr
-
James Tanis