TelnetClient.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file TelnetClient.qm Telnet module definition
/* TelnetClient.qm Copyright 2012 - 2017 Qore Technologies s.r.o.
Original Author: Pavol Potancok
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// minimum required Qore version
// assume local var scope, do not use "$" for vars, members, and method calls
namespace TelnetClient {
// default telnet port
const DefaultTelnetPort = 23;
// default connection timeout
const DefaultConnTimeout = 15s;
// default poll timeout
const DefaultTimeout = 100ms;
// default terminal type
const DefaultTerminalType = "xterm";
// default terminal speed
const DefaultTerminalSpeed = 38400;
const IAC = 255;
const DONT = 254;
const DO = 253;
const WONT = 252;
const WILL = 251;
const SE = 240;
const NOP = 241;
const DM = 242;
const BRK = 243;
const IP = 244;
const AO = 245;
const AYT = 246;
const EC = 247;
const EL = 248;
const GA = 249;
const SB = 250;
const CmdMap = (
IAC : "IAC",
DONT : "DONT",
DO : "DO",
WONT : "WONT",
WILL: "WILL",
SE : "SubnegotiationEnd",
NOP : "NoOperation",
DM: "DataMark",
BRK : "Break",
IP : "Interruptprocess",
AO : "Abortoutput",
AYT : "AreYouThere",
EC : "EraseCharacter",
EL : "EraseLine",
GA : "GoAhead",
SB : "SubnegotiationBegin",
);
const SUPDUP_OPT = 21; // SUPDUP_OPT display protocol
const TOPT_BIN = 0;
const TOPT_ECHO = 1;
const TOPT_RECN = 2;
const TOPT_SUPP = 3;
const TOPT_APRX = 4;
const TOPT_STAT = 5;
const TOPT_TIM = 6;
const TOPT_REM = 7;
const TOPT_OLW = 8;
const TOPT_OPS = 9;
const TOPT_OCRD = 10;
const TOPT_OHT = 11;
const TOPT_OHTD = 12;
const TOPT_OFD = 13;
const TOPT_OVT = 14;
const TOPT_OVTD = 15;
const TOPT_OLD = 16;
const TOPT_EXT = 17;
const TOPT_LOGO = 18;
const TOPT_BYTE = 19;
const TOPT_DATA = 20;
const TOPT_SUP = 21;
const TOPT_SUPO = 22;
const TOPT_SNDL = 23;
const TOPT_TERM = 24;
const TOPT_EOR = 25;
const TOPT_TACACS = 26;
const TOPT_OM = 27;
const TOPT_TLN = 28;
const TOPT_3270 = 29;
const TOPT_X3 = 30;
const TOPT_NAWS = 31;
const TOPT_TS = 32;
const TOPT_RFC = 33;
const TOPT_LINE = 34;
const TOPT_XDL = 35;
const TOPT_ENVIR = 36;
const TOPT_AUTH = 37;
const TOPT_ENVIR_NEW = 39;
const TOPT_TN3270 = 40;
const TOPT_X_AUTH = 41;
const TOPT_CHARSET = 42;
const TOPT_RSP = 43;
const TOPT_COMPORT = 44;
const TOPT_SLE = 45;
const TOPT_STARTTLS = 46;
const TOPT_KERMIT = 47;
const TOPT_SEND_URL = 48;
const TOPT_EXTOP = 255;
const OptMap = (
TOPT_BIN : "BinaryTransmission",
TOPT_ECHO : "Echo|Is|Send",
TOPT_RECN : "Reconnection",
TOPT_SUPP : "SuppressGoAhead",
TOPT_APRX : "ApproxMessageSizeNegotiation",
TOPT_STAT : "Status",
TOPT_TIM : "TimingMark",
TOPT_REM : "RemoteControlledTransandEcho",
TOPT_OLW : "OutputLineWidth",
TOPT_OPS : "OutputPageSize",
TOPT_OCRD : "OutputCarriage-ReturnDisposition",
TOPT_OHT : "OutputHorizontalTabstops",
TOPT_OHTD : "OutputHorizontalTabDisposition",
TOPT_OFD : "OutputFormfeedDisposition",
TOPT_OVT : "OutputVerticalTabstops",
TOPT_OVTD : "OutputVerticalTabDisposition",
TOPT_OLD : "OutputLinefeedDisposition",
TOPT_EXT : "ExtendedASCII",
TOPT_LOGO : "Logout",
TOPT_BYTE : "ByteMacro",
TOPT_DATA : "DataEntryTerminal",
TOPT_SUP : "SUPDUP",
TOPT_SUPO : "SUPDUPOutput",
TOPT_SNDL : "SendLocation",
TOPT_TERM : "TerminalType",
TOPT_EOR : "EndofRecord",
TOPT_TACACS : "TACACSUserIdent",
TOPT_OM : "OutputMarking",
TOPT_TLN : "TerminalLocationNumber",
TOPT_3270 : "Telnet3270Regime",
TOPT_X3 : "X.3PAD",
TOPT_NAWS : "NegotiateAboutWindowSize",
TOPT_TS : "TerminalSpeed",
TOPT_RFC : "RemoteFlowControl",
TOPT_LINE : "Linemode",
TOPT_XDL : "XDisplayLocation",
TOPT_ENVIR : "TelnetEnvironmentOption",
TOPT_AUTH : "TelnetAuthenticationOption",
TOPT_ENVIR_NEW : "TelnetNewEnvironmentOption",
TOPT_TN3270 : "TN3270Enhancements",
TOPT_X_AUTH : "TelnetXAUTH",
TOPT_CHARSET : "TelnetCHARSET",
TOPT_RSP : "TelnetRemoteSerialPort",
TOPT_COMPORT : "TelnetComPortControl",
TOPT_SLE : "TelnetSuppressLocalEcho",
TOPT_STARTTLS : "TelnetStartTLS",
TOPT_KERMIT : "TelnetKERMIT",
TOPT_SEND_URL : "Send-URL",
TOPT_EXTOP : "Extended-Options-List",
);
class TelnetClient {
public:
private :
// the connection string
string connect;
// the socket for all communication with the server
Socket conn();
// to manage contention on the Socket
Mutex m();
// login user
*string user;
// logging closures
*code log_info;
*code log_debug;
// hash of features the telnet server has asked for
hash fh;
public:
// no public members
private:
public:
constructor(string host, softint port, *code log, *code dbglog);
constructor(string connect, *code log, *code dbglog);
destructor();
private:
log(string msg);
public:
private:
logDbg(string msg);
public:
connect(timeout timeout = DefaultConnTimeout);
bool isConnected();
setUser(*string n_user);
*string getUser();
disconnect();
sendData(softlist arr);
sendTextData(string str);
*string getAvailableData(timeout t = DefaultTimeout);
bool hasFeature(int fc);
windowSizeUpdated();
private:
*string getDisplay();
public:
private:
*string getTerminalType();
public:
private:
hash getEnvironment();
public:
private:
int getTerminalSpeed();
public:
private:
hash getWindowSize();
public:
nothing clearWarningQueue();
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms = 1s);
hash getUsageInfo();
clearStats();
string getTarget();
// don't override this method, fix/enhance it with a patch to the module
private:
final disconnectIntern();
public:
private:
checkConnIntern();
public:
// don't override this method, fix/enhance it with a patch to the module
private:
final sendDataIntern(softlist arr, bool double_aic = False);
public:
private:
sendTextDataIntern(string str);
public:
// don't override this method, fix/enhance it with a patch to the module
private:
final *string getAvailableDataIntern(timeout t = DefaultTimeout);
public:
// don't override this method, fix/enhance it with a patch to the module
private:
final updateWindowSizeIntern(hash wh);
public:
// don't override this method, fix/enhance it with a patch to the module
private:
final processCmd(reference<string> rv);
public:
// don't override this method, fix/enhance it with a patch to the module
private:
final doSubNegotiation();
public:
};
class TelnetConnection : public ConnectionProvider::AbstractConnection {
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
string getType();
*hash getRuntimeOptions();
private:
TelnetClient getImpl(bool connect = True, *hash rtopts);
public:
static TelnetConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
};
TelnetClient::TOPT_OCRD
const TOPT_OCRD
OutputCarriage-ReturnDisposition.
Definition: TelnetClient.qm.dox.h:152
TelnetClient::TOPT_OHTD
const TOPT_OHTD
OutputHorizontalTabDisposition.
Definition: TelnetClient.qm.dox.h:154
ConnectionProvider::AbstractConnection::monitor
bool monitor
TelnetClient::BRK
const BRK
Break.
Definition: TelnetClient.qm.dox.h:107
TelnetClient::TOPT_SUPO
const TOPT_SUPO
SUPDUPOutput.
Definition: TelnetClient.qm.dox.h:164
TelnetClient::GA
const GA
Go Ahead.
Definition: TelnetClient.qm.dox.h:113
TelnetClient::TOPT_EXTOP
const TOPT_EXTOP
Extended-Options-List.
Definition: TelnetClient.qm.dox.h:190
TelnetClient::TOPT_APRX
const TOPT_APRX
ApproxMessageSizeNegotiation.
Definition: TelnetClient.qm.dox.h:146
TelnetClient::TelnetConnection::getRuntimeOptions
*hash getRuntimeOptions()
returns runtime options
TelnetClient::TOPT_NAWS
const TOPT_NAWS
NegotiateAboutWindowSize.
Definition: TelnetClient.qm.dox.h:173
ConnectionProvider::AbstractConnection::opts
*hash opts
TelnetClient::TOPT_OVTD
const TOPT_OVTD
OutputVerticalTabDisposition.
Definition: TelnetClient.qm.dox.h:157
TelnetClient::TOPT_TS
const TOPT_TS
TerminalSpeed.
Definition: TelnetClient.qm.dox.h:174
TelnetClient::TOPT_SUP
const TOPT_SUP
SUPDUP.
Definition: TelnetClient.qm.dox.h:163
TelnetClient
contains constant definitions and the definition of the TelnetClient class
Definition: TelnetClient.qm.dox.h:76
TelnetClient::TOPT_STAT
const TOPT_STAT
Status.
Definition: TelnetClient.qm.dox.h:147
True
const True
TelnetClient::TOPT_STARTTLS
const TOPT_STARTTLS
TelnetStartTLS.
Definition: TelnetClient.qm.dox.h:187
ConnectionProvider::AbstractConnection::name
string name
TelnetClient::TOPT_SUPP
const TOPT_SUPP
SuppressGoAhead.
Definition: TelnetClient.qm.dox.h:145
TelnetClient::TOPT_DATA
const TOPT_DATA
DataEntryTerminal.
Definition: TelnetClient.qm.dox.h:162
TelnetClient::TOPT_COMPORT
const TOPT_COMPORT
TelnetComPortControl.
Definition: TelnetClient.qm.dox.h:185
ConnectionProvider::AbstractConnection::urlh
hash urlh
TelnetClient::WILL
const WILL
WILL.
Definition: TelnetClient.qm.dox.h:103
TelnetClient::TOPT_X_AUTH
const TOPT_X_AUTH
TelnetXAUTH.
Definition: TelnetClient.qm.dox.h:182
TelnetClient::EL
const EL
Erase Line.
Definition: TelnetClient.qm.dox.h:112
False
const False
TelnetClient::TOPT_OM
const TOPT_OM
OutputMarking.
Definition: TelnetClient.qm.dox.h:169
TelnetClient::TOPT_CHARSET
const TOPT_CHARSET
TelnetCHARSET.
Definition: TelnetClient.qm.dox.h:183
TelnetClient::DO
const DO
DO.
Definition: TelnetClient.qm.dox.h:101
TelnetClient::TOPT_SNDL
const TOPT_SNDL
SendLocation.
Definition: TelnetClient.qm.dox.h:165
ConnectionProvider::AbstractConnection
TelnetClient::TOPT_OFD
const TOPT_OFD
OutputFormfeedDisposition.
Definition: TelnetClient.qm.dox.h:155
TelnetClient::TOPT_OPS
const TOPT_OPS
OutputPageSize.
Definition: TelnetClient.qm.dox.h:151
TelnetClient::SB
const SB
Subnegotiation Begin.
Definition: TelnetClient.qm.dox.h:114
TelnetClient::TOPT_REM
const TOPT_REM
RemoteControlledTransandEcho.
Definition: TelnetClient.qm.dox.h:149
TelnetClient::TOPT_BIN
const TOPT_BIN
BinaryTransmission.
Definition: TelnetClient.qm.dox.h:142
TelnetClient::TOPT_LOGO
const TOPT_LOGO
Logout.
Definition: TelnetClient.qm.dox.h:160
TelnetClient::EC
const EC
Erase Character.
Definition: TelnetClient.qm.dox.h:111
TelnetClient::TOPT_OLW
const TOPT_OLW
OutputLineWidth.
Definition: TelnetClient.qm.dox.h:150
TelnetClient::TelnetConnection::constructor
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
creates the TelnetConnection object
TelnetClient::AYT
const AYT
Are You There.
Definition: TelnetClient.qm.dox.h:110
TelnetClient::TOPT_SEND_URL
const TOPT_SEND_URL
Send-URL.
Definition: TelnetClient.qm.dox.h:189
TelnetClient::TOPT_TERM
const TOPT_TERM
TerminalType.
Definition: TelnetClient.qm.dox.h:166
TelnetClient::TelnetConnection::getType
string getType()
returns "telnet"
TelnetClient::TOPT_ECHO
const TOPT_ECHO
Echo|Is|Send.
Definition: TelnetClient.qm.dox.h:143
TelnetClient::TOPT_TACACS
const TOPT_TACACS
TACACSUserIdent.
Definition: TelnetClient.qm.dox.h:168
ConnectionProvider::AbstractConnection::desc
string desc
HttpServer::DefaultTimeout
const DefaultTimeout
TelnetClient::TOPT_TLN
const TOPT_TLN
TerminalLocationNumber.
Definition: TelnetClient.qm.dox.h:170
TelnetClient::CmdMap
const CmdMap
command name map
Definition: TelnetClient.qm.dox.h:117
TelnetClient::TOPT_XDL
const TOPT_XDL
XDisplayLocation.
Definition: TelnetClient.qm.dox.h:177
TelnetClient::TOPT_TN3270
const TOPT_TN3270
TN3270Enhancements.
Definition: TelnetClient.qm.dox.h:181
TelnetClient::TOPT_LINE
const TOPT_LINE
Linemode.
Definition: TelnetClient.qm.dox.h:176
TelnetClient::TOPT_AUTH
const TOPT_AUTH
TelnetAuthenticationOption.
Definition: TelnetClient.qm.dox.h:179
TelnetClient::TelnetConnection::getImpl
TelnetClient getImpl(bool connect=True, *hash rtopts)
returns an TelnetClient object
TelnetClient::TelnetConnection::make
static TelnetConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
static constructor
TelnetClient::IP
const IP
Interrupt process.
Definition: TelnetClient.qm.dox.h:108
TelnetClient::TOPT_EOR
const TOPT_EOR
EndofRecord.
Definition: TelnetClient.qm.dox.h:167
TelnetClient::TOPT_ENVIR
const TOPT_ENVIR
TelnetEnvironmentOption.
Definition: TelnetClient.qm.dox.h:178
TelnetClient::TOPT_BYTE
const TOPT_BYTE
ByteMacro.
Definition: TelnetClient.qm.dox.h:161
TelnetClient::TOPT_ENVIR_NEW
const TOPT_ENVIR_NEW
TelnetNewEnvironmentOption.
Definition: TelnetClient.qm.dox.h:180
TelnetClient::TOPT_OLD
const TOPT_OLD
OutputLinefeedDisposition.
Definition: TelnetClient.qm.dox.h:158
TelnetClient::AO
const AO
Abort output.
Definition: TelnetClient.qm.dox.h:109
TelnetClient::TOPT_OVT
const TOPT_OVT
OutputVerticalTabstops.
Definition: TelnetClient.qm.dox.h:156
ConnectionProvider::AbstractConnection::url
string url
TelnetClient::NOP
const NOP
No Operation.
Definition: TelnetClient.qm.dox.h:105
TelnetClient::TOPT_X3
const TOPT_X3
X.3PAD.
Definition: TelnetClient.qm.dox.h:172
hash
hash hash(object obj)
TelnetClient::TOPT_OHT
const TOPT_OHT
OutputHorizontalTabstops.
Definition: TelnetClient.qm.dox.h:153
TelnetClient::IAC
const IAC
IAC.
Definition: TelnetClient.qm.dox.h:99
TelnetClient::TOPT_RSP
const TOPT_RSP
TelnetRemoteSerialPort.
Definition: TelnetClient.qm.dox.h:184
TelnetClient::TelnetConnection
class for Telnet connections; returns an object of class TelnetClient for connecting to telnet sessio...
Definition: TelnetClient.qm.dox.h:612
TelnetClient::TOPT_SLE
const TOPT_SLE
TelnetSuppressLocalEcho.
Definition: TelnetClient.qm.dox.h:186
TelnetClient::TOPT_RFC
const TOPT_RFC
RemoteFlowControl.
Definition: TelnetClient.qm.dox.h:175
TelnetClient::WONT
const WONT
WONT.
Definition: TelnetClient.qm.dox.h:102
TelnetClient::DONT
const DONT
DONT.
Definition: TelnetClient.qm.dox.h:100
TelnetClient::TOPT_RECN
const TOPT_RECN
Reconnection.
Definition: TelnetClient.qm.dox.h:144
TelnetClient::SE
const SE
Subnegotiation End.
Definition: TelnetClient.qm.dox.h:104
TelnetClient::TOPT_KERMIT
const TOPT_KERMIT
TelnetKERMIT.
Definition: TelnetClient.qm.dox.h:188
TelnetClient::DM
const DM
Data Mark.
Definition: TelnetClient.qm.dox.h:106
TelnetClient::OptMap
const OptMap
option map, maps codes to text descriptions
Definition: TelnetClient.qm.dox.h:193
TelnetClient::TOPT_EXT
const TOPT_EXT
ExtendedASCII.
Definition: TelnetClient.qm.dox.h:159
TelnetClient::TOPT_3270
const TOPT_3270
Telnet3270Regime.
Definition: TelnetClient.qm.dox.h:171
TelnetClient::TOPT_TIM
const TOPT_TIM
TimingMark.
Definition: TelnetClient.qm.dox.h:148