telnetlib icon indicating copy to clipboard operation
telnetlib copied to clipboard

disable echo

Open voidest1 opened this issue 4 years ago • 5 comments

This project is perfect to me, thanks a lot. I created a server by telnetlib. I want disable client echo the password input, but didn't work. Finally I found the solution, client.enableRemote(1) can hide type from client. But I want recover to normal echo, I called client.disableRemote(1) was catch the exception. Who can help me?

voidest1 avatar Oct 15 '21 07:10 voidest1

I tried any ways, finally it is working. disable echo: client.writer.writeDo(1) enable echo: client.writer.writeWont(1) I don't know why but it is worked.

voidest1 avatar Oct 15 '21 07:10 voidest1

Hello, I'm glad that you figured something out on your end, but this still sounds like something that needs looked at. Would it be possible for you to share a cut down version of your code that shows the weird behavior?

cadpnq avatar Oct 18 '21 14:10 cadpnq

sure.:-) The following is the code for hide client's type, the comments is old that. ` hideInput(){

  (async()=>{
      // await this.client.enableRemote(1);
      this.client.writer.writeDo(1);
      this.passInput = true;
  })();
}

`

the next is the code for recover to normal echo. ` netClient.on('data', (msg)=>{

            if(self.passInput) {
                self.passInput = false;
                (async()=>{
                       //await self.client.disableRemote(1); //here raise an exception
                })();
                self.client.writer.writeWont(1);
            }
            if(self.onMessage){
                self.onMessage(msg.toString());
            }
        });

`

voidest1 avatar Oct 19 '21 03:10 voidest1

I want something similar, I want to detect when echo is disabled, is this possible? I need to look for IAC + WILL + 1. I noticed client.options.keys will contain 1, but not if it was enabled or disabled.

eirikb avatar Jan 10 '22 16:01 eirikb

I think I found a solution, something like this:

const { ECHO } = telnetlib.options;

const c = telnetlib.createConnection(
  {
    host: "aardwolf.org",
    port: 23,
    remoteOptions: [ECHO],
  },
  () => {
    c.on("enable", (option) => {
      if (option === ECHO) {
        // Enable password
      }
    });
    c.on("disable", (option) => {
      if (option === ECHO) {
        // Disable password
      }
    });
  }
);

eirikb avatar Jan 10 '22 19:01 eirikb