scandum / mth

MTH (Mud Telopt Handler) server side TELNET implementation
22 stars 6 forks source link

Windows Telnet Echo Issue #2

Open msocorcim opened 1 year ago

msocorcim commented 1 year ago

On my ROM with MTH 1.5, a Windows Telnet Session (tested with Win 10 and 11) has improper echos. I tested this with BasedMUD with the same results. This doesn't affect PuTTY telnet, the Linux netkit console telnet client, or any of several mud clients tested. Our user was able to use PuTTY, so this is no big deal, but it would be nice being able to identify a Windows telnet session and to limit option negotiations to those the client can process gracefully.

Below, I'm typing the name Msocorcim.

Do you want ANSI? (Y/n) yy Ansi enabled!

THIS IS A MUD BASED ON.....

                            ROM Version 2.4 beta

           Original DikuMUD by Hans Staerfeldt, Katja Nyboe,
           Tom Madsen, Michael Seifert, and Sebastian Hammer
           Based on MERC 2.1 code by Hatchet, Furey, and Kahn
           ROM 2.4 copyright (c) 1993-1998 Russ Taylor

By what name do you wish to be known? MMsoMsocoMsocorcMsocorcim

scandum commented 1 year ago

Looks like the problem is in telopt.c with the code starting with:

if (HAS_BIT(d->mth->comm_flags, COMM_FLAG_REMOTEECHO))

Try replacing that code block with:

        if (HAS_BIT(d->mth->comm_flags, COMM_FLAG_REMOTEECHO))
        {
                pto = out + outlen;

                skip = strlen((char *) pto);

                for (cnt = 0 ; cnt < skip ; cnt++)
                {
                        switch (pto[cnt])
                        {
                                case   8:
                                case 127:
                                        pto[cnt] = '\b';
                                        write_to_descriptor(d->descriptor, "\b \b", 3);
                                        break;

                                case '\n':
                                        write_to_descriptor(d->descriptor, "\r\n", 2);
                                        break;

                                default:
                                        if (HAS_BIT(d->mth->comm_flags, COMM_FLAG_PASSWORD))
                                        {
                                                write_to_descriptor(d->descriptor, "*", 1);
                                        }
                                        else
                                        {
                                                write_to_descriptor(d->descriptor, (char *) (pto + cnt), 1);
                                        }
                                        break;
                        }
                }
        }
msocorcim commented 1 year ago

Thanks! That works well with the Windows Telnet. (replaced "d->descriptor" with "d" for ROM)