Skip to content

Reemit 'end' event from socket when using MCCP both locally and remote#6

Open
eirikb wants to merge 1 commit intocadpnq:mainfrom
eirikb:feature/socket-end
Open

Reemit 'end' event from socket when using MCCP both locally and remote#6
eirikb wants to merge 1 commit intocadpnq:mainfrom
eirikb:feature/socket-end

Conversation

@eirikb
Copy link
Copy Markdown

@eirikb eirikb commented Jan 10, 2022

The event 'end' is never emitted when listening from a client, using MCCP on remote and local.
This is a bit hacky, but I didn't find any other solution.
Should have been done in MCCP.js, but didn't find any good way.
I don't really know what the real problem is, could be the stream is in the
middle of expecting to decompress when it receives an 'end', and it will be ignored?

Test code:

const telnetlib = require("telnetlib");

const { MCCP } = telnetlib.options;

const c = telnetlib
  .createConnection(
    {
      host: "aardwolf.org",
      port: 23,
      remoteOptions: [MCCP],
      localOptions: [MCCP],
    },
    () => {
      setTimeout(() => {
        c.write("olooorin\n");
        setTimeout(() => {
          c.write("wrongpasswordforcelinkclose\n");
        }, 1000);
      }, 1000);
    }
  )
  .on("end", () => {
    console.log("END!");
  });

The event 'end' is never emitted when listening from a client, using MCCP on remote and local.
This is a bit hacky, but I didn't find any other solution.
Should have been done in MCCP.js, but didn't find any good way.
I don't really know what the real problem is, could be the stream is in the
middle of expecting to decompress when it receives an 'end', and it will be ignored?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant