mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-26 20:26:32 +00:00
Add terminate telnet session with command exit or quit
This commit is contained in:
parent
69fca99ac1
commit
6f47f23f7a
@ -41,6 +41,8 @@
|
|||||||
* Cyan 36 96
|
* Cyan 36 96
|
||||||
* White 37 97
|
* White 37 97
|
||||||
* Default 39
|
* Default 39
|
||||||
|
*
|
||||||
|
* Terminate telnet session with command exit or quit
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#define XDRV_78 78
|
#define XDRV_78 78
|
||||||
@ -69,6 +71,8 @@
|
|||||||
#define TELNET_COL_LOGGING 36 // [TelnetColor] ANSI color escape code (default 36 - Cyan)
|
#define TELNET_COL_LOGGING 36 // [TelnetColor] ANSI color escape code (default 36 - Cyan)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char kTelnetExits[] PROGMEM = "exit|quit";
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
WiFiServer *server = nullptr;
|
WiFiServer *server = nullptr;
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
@ -205,8 +209,14 @@ void TelnetLoop(void) {
|
|||||||
if (Telnet.in_byte_counter >= Telnet.buffer_size) {
|
if (Telnet.in_byte_counter >= Telnet.buffer_size) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TLN: buffer overrun"));
|
AddLog(LOG_LEVEL_INFO, PSTR("TLN: buffer overrun"));
|
||||||
} else {
|
} else {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TLN: %s"), Telnet.buffer);
|
char command[CMDSZ];
|
||||||
ExecuteCommand(Telnet.buffer, SRC_TELNET);
|
if (GetCommandCode(command, sizeof(command), Telnet.buffer, kTelnetExits) >= 0) {
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Connection closed"));
|
||||||
|
Telnet.client.stop();
|
||||||
|
} else {
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TLN: %s"), Telnet.buffer);
|
||||||
|
ExecuteCommand(Telnet.buffer, SRC_TELNET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Telnet.in_byte_counter = 0;
|
Telnet.in_byte_counter = 0;
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user