From ed609e622351e0c0bf3bbe6d6d218e3a8c07cafc Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 1 May 2018 18:45:41 +0300 Subject: [PATCH 1/3] Handle C-d in telnet --- code/espurna/telnet.ino | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index fc3912c6..996da567 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -66,6 +66,15 @@ void _telnetData(unsigned char clientId, void *data, size_t len) { // Capture close connection char * p = (char *) data; + + // C-d is sent as two bytes + if (len == 2) { + if ((p[0] == 0xFF) && (p[1] == 0xEC)) { + _telnetClients[clientId]->close(); + return; + } + } + if ((strncmp(p, "close", 5) == 0) || (strncmp(p, "quit", 4) == 0)) { _telnetClients[clientId]->close(); return; From 99311bbe714c14fab0ea97d9fa0309147b7f2cd0 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 2 May 2018 15:39:55 +0300 Subject: [PATCH 2/3] Sometimes telnet spams this sequence --- code/espurna/telnet.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index 996da567..918f228e 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -67,8 +67,8 @@ void _telnetData(unsigned char clientId, void *data, size_t len) { // Capture close connection char * p = (char *) data; - // C-d is sent as two bytes - if (len == 2) { + // C-d is sent as two bytes (sometimes repeating) + if (len >= 2) { if ((p[0] == 0xFF) && (p[1] == 0xEC)) { _telnetClients[clientId]->close(); return; From 5708a23d2f5ae6d5f63e7bdaa04fc29294117d77 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 2 May 2018 15:40:11 +0300 Subject: [PATCH 3/3] Immediatly close connection to avoid watchdog --- code/espurna/telnet.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index 918f228e..006d5d21 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -70,7 +70,7 @@ void _telnetData(unsigned char clientId, void *data, size_t len) { // C-d is sent as two bytes (sometimes repeating) if (len >= 2) { if ((p[0] == 0xFF) && (p[1] == 0xEC)) { - _telnetClients[clientId]->close(); + _telnetClients[clientId]->close(true); return; } }