public final class TelnetConsole extends Console
Console
connected to a telnet client via a Socket
.
This class can be used to implement an embedded CLI console within an application, accessed via telnet. For example:
// Accept a new connection and setup telnet CLI console try (Socket socket = /* accept new TCP connection */; TelnetConsole console = TelnetConsole.create(database, socket)) { // Install commands and functions console.getSession().loadFunctionsFromClasspath(); console.getSession().loadCommandsFromClasspath(); // Run the console console.run(); }
Modifier and Type | Class and Description |
---|---|
static class |
TelnetConsole.ForwardingTerminal
Wrapper class for a JLine
Terminal that forwards all methods to the wrapped delegate. |
static class |
TelnetConsole.TelnetTerminal
JLine
Terminal that gets window size information from an associated nvt4j Terminal . |
Modifier and Type | Method and Description |
---|---|
static TelnetConsole |
create(Database db,
Socket socket)
Simplified factory method for
SessionMode.CORE_API mode. |
static TelnetConsole |
create(KVDatabase kvdb,
Database db,
Permazen jdb,
InputStream input,
OutputStream output,
String encoding,
String appName)
Generic factory method.
|
static TelnetConsole |
create(KVDatabase kvdb,
Socket socket)
Simplified factory method for
SessionMode.KEY_VALUE mode. |
static TelnetConsole |
create(Permazen jdb,
Socket socket)
Simplified factory method for
SessionMode.PERMAZEN mode. |
close, getConsoleReader, getSession, getTerminal, parseCommand, run, runNonInteractive, setHistoryFile, setPassword
public static TelnetConsole create(KVDatabase kvdb, Socket socket) throws IOException
SessionMode.KEY_VALUE
mode.kvdb
- key/value KVDatabase
socket
- socket connected to telnet clientIOException
- if an I/O error occurspublic static TelnetConsole create(Database db, Socket socket) throws IOException
SessionMode.CORE_API
mode.db
- core API Database
socket
- socket connected to telnet clientIOException
- if an I/O error occurspublic static TelnetConsole create(Permazen jdb, Socket socket) throws IOException
SessionMode.PERMAZEN
mode.jdb
- Permazen
databasesocket
- socket connected to telnet clientIOException
- if an I/O error occurspublic static TelnetConsole create(KVDatabase kvdb, Database db, Permazen jdb, InputStream input, OutputStream output, String encoding, String appName) throws IOException
kvdb
- KVDatabase
for SessionMode.KEY_VALUE
(otherwise must be null)db
- Database
for SessionMode.CORE_API
(otherwise must be null)jdb
- Permazen
for SessionMode.PERMAZEN
(otherwise must be null)input
- console inputoutput
- console outputencoding
- character encoding for terminal
, or null for defaultappName
- JLine application name, or null for noneIOException
- if an I/O error occursIllegalArgumentException
- if not exactly one of kvdb
, db
or jdb
is not nullCopyright © 2022. All rights reserved.