🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1004

Re: Telnet Server just a note and a proposal

#1004
From: Remy Lebeau (TeamB)
Date: Fri, 22 Jun 2007 17:33
87 lines
3738 bytes
"Colin B Maharaj" <noreply@myhost.com> wrote in message
news:467b99a3$1@newsgroups.borland.com...

> What I did was this in the onconnect.....

Echoing is a negotiated property.  But you are ignoring the negotiated
reply to know whether the echoing was actually turned off or not.

Use the OnNegotiate event instead of the OnConnect event directly.
OnNegotiate is triggered automatically after the OnConnect event
handler exits.  That would be a better place to send your WONT
request.

The only caveat is that TIdTelnetServer always echoes back login
characters unconditionally.  To get around that, you won't be able to
use the OnAuthentication event at all.  In the OnNegotiate event, you
can send your own login prompts and then read back the replies,
echoing only if needed.

For example (untested):

    void __fastcall TForm1::IdTelnetServer1Negotiate(TIdPeerThread
*AThread)
    {
        unsigned char s[3];
        bool ClientIsEchoing = true;

        s[0] = 0xFF; // IAC
        s[1] = 0xFE; // DONT
        s[2] = 0x01; // ECHO

        AThread->Connection->WriteBuffer(s, 3);

        AThread->Connection->ReadBuffer(s, 3);
        if( (s[0] == 0xFF) && (s[2] == 0x01) )
        {
            switch( s[1] )
            {
                case 0xFC: // WONT
                    // echoing is disabled
                    ClientIsEchoing = false;
                    break;
                case 0xFB: // WILL
                    // echoing is still enabled
                    ClientIsEchoing = true;
                    break;
                default
                    // unexpected reply ...
                    break;
        }
        else
            // unexpected reply ...

        AThread->Connection->WriteLn("Connected to Server. You have 3
Login Attempts...\r\n");

        for(int i = 0; i < IdTelnetServer1->LoginAttempts; ++i)
        {
            AThread->Connection->Write("Username: ");
            ((TIdTelnetPeerThread*)AThread)->TelnetData->Username =
AThread->Connection->InputLn("", !ClientIsEchoing);

            AThread->Connection->Write("Password: ");
            ((TIdTelnetPeerThread*)AThread)->TelnetData->Password =
AThread->Connection->InputLn("*", !ClientIsEchoing);

            AThread->Connection->WriteLn();

            if( username/password is ok )
                return;

            AThread->Connection->WriteLn("Not logged in!");
        }

        throw EIdException("Max logins");
    }

> BTW: I use Indy 9.0.50 on BCB6 Ent. And I do not have Indy 10
> maybe one of you folks can test to see if it has the same issue.

TIdTelnetServer in Indy 10 works the exact same way that it does in
Indy 9.


Gambit
Gambit
Technical Details
Message-ID: <467c07fb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <467b99a3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,27acd896331d1920
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <467b99a3$1@newsgroups.borland.com>
Subject: Re: Telnet Server just a note and a proposal
Date: Fri, 22 Jun 2007 10:33:00 -0700
Lines: 89
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.82.252.126
Message-ID: <467c07fb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1182533627 75.82.252.126 (22 Jun 2007 10:33:47 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail