Qore TelnetClient Module Reference 1.7
Loading...
Searching...
No Matches
TelnetClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* TelnetClient.qm Copyright 2012 - 2023 Qore Technologies s.r.o.
5
6 Original Author: Pavol Potancok
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25*/
26
27// minimum required Qore version
28
29// assume local var scope, do not use "$" for vars, members, and method calls
30
31
32}
33
96namespace TelnetClient {
100// default telnet port
101const DefaultTelnetPort = 23;
102
103// default connection timeout
104const DefaultConnTimeout = 15s;
105
106// default poll timeout
107const DefaultTimeout = 100ms;
108
109// default terminal type
110const DefaultTerminalType = "xterm";
111
112// default terminal speed
113const DefaultTerminalSpeed = 38400;
115
119const IAC = 255; #!< IAC
120const DONT = 254; #!< DONT
121const DO = 253; #!< DO
122const WONT = 252; #!< WONT
123const WILL = 251; #!< WILL
124const SE = 240; #!< Subnegotiation End
125const NOP = 241; #!< No Operation
126const DM = 242; #!< Data Mark
127const BRK = 243; #!< Break
128const IP = 244; #!< Interrupt process
129const AO = 245; #!< Abort output
130const AYT = 246; #!< Are You There
131const EC = 247; #!< Erase Character
132const EL = 248; #!< Erase Line
133const GA = 249; #!< Go Ahead
134const SB = 250; #!< Subnegotiation Begin
135
137const CmdMap = ...;
138
140
141const SUPDUP_OPT = 21; # SUPDUP_OPT display protocol
142
146const TOPT_BIN = 0; #!< BinaryTransmission
147const TOPT_ECHO = 1; #!< Echo|Is|Send
148const TOPT_RECN = 2; #!< Reconnection
149const TOPT_SUPP = 3; #!< SuppressGoAhead
150const TOPT_APRX = 4; #!< ApproxMessageSizeNegotiation
151const TOPT_STAT = 5; #!< Status
152const TOPT_TIM = 6; #!< TimingMark
153const TOPT_REM = 7; #!< RemoteControlledTransandEcho
154const TOPT_OLW = 8; #!< OutputLineWidth
155const TOPT_OPS = 9; #!< OutputPageSize
156const TOPT_OCRD = 10; #!< OutputCarriage-ReturnDisposition
157const TOPT_OHT = 11; #!< OutputHorizontalTabstops
158const TOPT_OHTD = 12; #!< OutputHorizontalTabDisposition
159const TOPT_OFD = 13; #!< OutputFormfeedDisposition
160const TOPT_OVT = 14; #!< OutputVerticalTabstops
161const TOPT_OVTD = 15; #!< OutputVerticalTabDisposition
162const TOPT_OLD = 16; #!< OutputLinefeedDisposition
163const TOPT_EXT = 17; #!< ExtendedASCII
164const TOPT_LOGO = 18; #!< Logout
165const TOPT_BYTE = 19; #!< ByteMacro
166const TOPT_DATA = 20; #!< DataEntryTerminal
167const TOPT_SUP = 21; #!< SUPDUP
168const TOPT_SUPO = 22; #!< SUPDUPOutput
169const TOPT_SNDL = 23; #!< SendLocation
170const TOPT_TERM = 24; #!< TerminalType
171const TOPT_EOR = 25; #!< EndofRecord
172const TOPT_TACACS = 26; #!< TACACSUserIdent
173const TOPT_OM = 27; #!< OutputMarking
174const TOPT_TLN = 28; #!< TerminalLocationNumber
175const TOPT_3270 = 29; #!< Telnet3270Regime
176const TOPT_X3 = 30; #!< X.3PAD
177const TOPT_NAWS = 31; #!< NegotiateAboutWindowSize
178const TOPT_TS = 32; #!< TerminalSpeed
179const TOPT_RFC = 33; #!< RemoteFlowControl
180const TOPT_LINE = 34; #!< Linemode
181const TOPT_XDL = 35; #!< XDisplayLocation
182const TOPT_ENVIR = 36; #!< TelnetEnvironmentOption
183const TOPT_AUTH = 37; #!< TelnetAuthenticationOption
184const TOPT_ENVIR_NEW = 39; #!< TelnetNewEnvironmentOption
185const TOPT_TN3270 = 40; #!< TN3270Enhancements
186const TOPT_X_AUTH = 41; #!< TelnetXAUTH
187const TOPT_CHARSET = 42; #!< TelnetCHARSET
188const TOPT_RSP = 43; #!< TelnetRemoteSerialPort
189const TOPT_COMPORT = 44; #!< TelnetComPortControl
190const TOPT_SLE = 45; #!< TelnetSuppressLocalEcho
191const TOPT_STARTTLS = 46; #!< TelnetStartTLS
192const TOPT_KERMIT = 47; #!< TelnetKERMIT
193const TOPT_SEND_URL = 48; #!< Send-URL
194const TOPT_EXTOP = 255; #!< Extended-Options-List
195
197const OptMap = ...;
198
200
202
206
207public:
209protected:
210 // the connection string
211 string connect;
212
213 // the socket for all communication with the server
214 Socket conn();
215
216 // to manage contention on the Socket
217 Mutex m();
218
219 // login user
220 *string user;
221
222 // logging closures
223 *code log_info;
224 *code log_debug;
225
226 // hash of features the telnet server has asked for
227 hash fh;
228
229public:
231
232 // no public members
233
234
236
241 constructor(string host, softint port, *code log, *code dbglog);
242
243
245
257 constructor(string connect, *code log, *code dbglog);
258
259
262
263
265protected:
266 log(string msg);
267public:
268
269
271protected:
272 logDbg(string msg);
273public:
274
275
277
280 connect(timeout timeout = DefaultConnTimeout);
281
282
285
286
288
292 setUser(*string n_user);
293
294
296 *string getUser();
297
298
300
303
304
306
318 sendData(softlist arr);
319
320
322
330 sendTextData(string str);
331
332
334
340 *string getAvailableData(timeout t = DefaultTimeout);
341
342
344
352 bool hasFeature(int fc);
353
354
356
359
360
362
364protected:
365 *string getDisplay();
366public:
367
368
370
372protected:
374public:
375
376
378
380protected:
382public:
383
384
386
388protected:
390public:
391
392
394
401protected:
403public:
404
405
407
417
418
420
450 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms = 1s);
451
452
454
472 hash<auto> getUsageInfo();
473
474
476
486
487
489
505 setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data);
506
507
509
519
520
522
524 string getTarget();
525
526
528 // don't override this method, fix/enhance it with a patch to the module
529protected:
530 final disconnectIntern();
531public:
532
533
534protected:
535 checkConnIntern();
536public:
537
538
539 // don't override this method, fix/enhance it with a patch to the module
540protected:
541 final sendDataIntern(softlist arr, bool double_aic = False);
542public:
543
544
545protected:
546 sendTextDataIntern(string str);
547public:
548
549
550 // don't override this method, fix/enhance it with a patch to the module
551protected:
552 final *string getAvailableDataIntern(timeout t = DefaultTimeout);
553public:
554
555
556 // don't override this method, fix/enhance it with a patch to the module
557protected:
558 final updateWindowSizeIntern(hash wh);
559public:
560
561
562 // don't override this method, fix/enhance it with a patch to the module
563protected:
564 final processCmd(reference<string> rv);
565public:
566
567
568 // don't override this method, fix/enhance it with a patch to the module
569protected:
570 final doSubNegotiation();
571public:
572
574};
575
577
584
585public:
587 const ConnectionScheme = <ConnectionSchemeInfo>{
588 "cls": Class::forName("TelnetConnection"),
589 };
590
592
602 constructor(string name, string description, string url, hash attributes = {}, hash options = {})
603 ;
604
605
607 string getType();
608
609
611
615 *hash<auto> getRuntimeOptions();
616
617
619
626protected:
627 TelnetClient getImpl(bool connect = True, *hash rtopts);
628public:
629
630
632protected:
633 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
634public:
635
636};
637};
setEventQueue()
Removes any Queue object so that socket events are no longer added to the Queue.
int getTerminalSpeed()
this method provides the value that will be given as the terminal speed in protocol negotiation
string getTarget()
Returns the connection target string.
log(string msg)
logs the message to the log closure set with the constructor (if any)
constructor(string host, softint port, *code log, *code dbglog)
creates the TelnetClient object
disconnect()
disconnects from the Telnet server
constructor(string connect, *code log, *code dbglog)
creates the TelnetClient object from a target string and optional log closure(s)
connect(timeout timeout=DefaultConnTimeout)
connects to the Telnet server
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
sendData(softlist arr)
sends data to the server
hash getWindowSize()
this method provides the value that will be given as the terminal window size in protocol negotiation
clearStats()
Clears performance statistics.
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
bool isConnected()
returns True if the client is connected to the server
windowSizeUpdated()
this method should be called externally when the window size has changed
sendTextData(string str)
sends literal string data to the server; the text dat is converted to the socket's encoding if necess...
*string getTerminalType()
this method provides the value that will be given as the terminal type in protocol negotiation
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
setUser(*string n_user)
sets or clears (in case passed with no value) the username parameter for logging in to the telnet ser...
*string getAvailableData(timeout t=DefaultTimeout)
returns all data available as a string (which could be an empty string if no data is available in the...
hash getEnvironment()
this method provides the value that will be given as the user's environment in protocol negotiation
destructor()
disconnects from the server if connected and deletes the object
bool hasFeature(int fc)
returns True if the server has confirmed with a DO command that it supports the given feature
logDbg(string msg)
logs the message to the debug log closure set with the constructor (if any)
*string getDisplay()
this method provides the value that will be given as the DISPLAY value in protocol negotiation
setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
*string getUser()
returns the current value of the username parameter
class for Telnet connections; returns an object of class TelnetClient for connecting to telnet sessio...
Definition: TelnetClient.qm.dox.h:583
string getType()
returns "telnet"
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
constructor(string name, string description, string url, hash attributes={}, hash options={})
creates the RestConnection connection object
const ConnectionScheme
Connection entry info.
Definition: TelnetClient.qm.dox.h:587
TelnetClient getImpl(bool connect=True, *hash rtopts)
returns an TelnetClient object
*hash< auto > getRuntimeOptions()
returns runtime options
const CmdMap
command name map
Definition: TelnetClient.qm.dox.h:137
const OptMap
option map, maps codes to text descriptions
Definition: TelnetClient.qm.dox.h:197
contains constant definitions and the definition of the TelnetClient class
Definition: TelnetClient.qm.dox.h:96