mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Fix build errors
This commit is contained in:
parent
046ecb0b7a
commit
b7366336cc
@ -2,16 +2,18 @@
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#include "hasp_conf.h"
|
||||
|
||||
#if HASP_USE_TELNET > 0
|
||||
|
||||
#include "ArduinoJson.h"
|
||||
#include "ConsoleInput.h"
|
||||
|
||||
#include "log/hasp_debug.h"
|
||||
#include "hasp_debug.h"
|
||||
#include "hasp_config.h"
|
||||
#include "hasp_telnet.h"
|
||||
#include "hasp_http.h"
|
||||
|
||||
#include "../hasp/hasp_dispatch.h"
|
||||
#include "../../hasp/hasp_dispatch.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <WiFi.h>
|
||||
@ -28,8 +30,9 @@ static EthernetServer telnetServer(23);
|
||||
#endif
|
||||
|
||||
#if HASP_USE_HTTP > 0
|
||||
extern char httpUser[32];
|
||||
extern char httpPassword[32];
|
||||
// extern char http_config.user[32];
|
||||
// extern char http_config.password[32];
|
||||
extern hasp_http_config_t http_config;
|
||||
#endif
|
||||
|
||||
uint8_t telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||
@ -84,8 +87,8 @@ void telnetAcceptClient()
|
||||
// telnetClient.print((char)0x1B);
|
||||
|
||||
#if HASP_USE_HTTP > 0
|
||||
if(strlen(httpUser) != 0 || strlen(httpPassword) != 0) {
|
||||
telnetClient.println(F("\r\n" D_TELNET_USERNAME " "));
|
||||
if(strlen(http_config.user) != 0 || strlen(http_config.password) != 0) {
|
||||
telnetClient.println(F("\r\n" D_USERNAME " "));
|
||||
telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||
} else
|
||||
#endif
|
||||
@ -102,15 +105,15 @@ static inline void telnetProcessLine()
|
||||
|
||||
switch(telnetLoginState) {
|
||||
case TELNET_UNAUTHENTICATED: {
|
||||
telnetClient.printf(PSTR(D_TELNET_PASSWORD" %c%c%c"), 0xFF, 0xFB, 0x01); // Hide characters
|
||||
telnetClient.printf(PSTR(D_PASSWORD" %c%c%c"), 0xFF, 0xFB, 0x01); // Hide characters
|
||||
#if HASP_USE_HTTP > 0
|
||||
telnetLoginState = strcmp(telnetInputBuffer, httpUser) == 0 ? TELNET_USERNAME_OK : TELNET_USERNAME_NOK;
|
||||
telnetLoginState = strcmp(telnetInputBuffer, http_config.user) == 0 ? TELNET_USERNAME_OK : TELNET_USERNAME_NOK;
|
||||
break;
|
||||
}
|
||||
case TELNET_USERNAME_OK:
|
||||
case TELNET_USERNAME_NOK: {
|
||||
telnetClient.printf(PSTR("%c%c%c\n"), 0xFF, 0xFC, 0x01); // Show characters
|
||||
if(telnetLoginState == TELNET_USERNAME_OK && strcmp(telnetInputBuffer, httpPassword) == 0) {
|
||||
if(telnetLoginState == TELNET_USERNAME_OK && strcmp(telnetInputBuffer, http_config.password) == 0) {
|
||||
telnetClientLogon();
|
||||
} else {
|
||||
telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||
@ -120,7 +123,7 @@ static inline void telnetProcessLine()
|
||||
if(telnetLoginAttempt >= 3) {
|
||||
telnetClientDisconnect();
|
||||
} else {
|
||||
telnetClient.print(F(D_TELNET_USERNAME" "));
|
||||
telnetClient.print(F(D_USERNAME" "));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -186,17 +189,17 @@ static inline void telnetProcessLine(const char * input)
|
||||
switch(telnetLoginState) {
|
||||
case TELNET_UNAUTHENTICATED: {
|
||||
char buffer[20];
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_TELNET_PASSWORD " %c%c%c\n"), 0xFF, 0xFB,
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_PASSWORD " %c%c%c\n"), 0xFF, 0xFB,
|
||||
0x01); // Hide characters
|
||||
telnetClient.print(buffer);
|
||||
#if HASP_USE_HTTP > 0
|
||||
telnetLoginState = strcmp(input, httpUser) == 0 ? TELNET_USERNAME_OK : TELNET_USERNAME_NOK;
|
||||
telnetLoginState = strcmp(input, http_config.user) == 0 ? TELNET_USERNAME_OK : TELNET_USERNAME_NOK;
|
||||
break;
|
||||
}
|
||||
case TELNET_USERNAME_OK:
|
||||
case TELNET_USERNAME_NOK: {
|
||||
telnetClient.printf(PSTR("%c%c%c\n"), 0xFF, 0xFC, 0x01); // Show characters
|
||||
if(telnetLoginState == TELNET_USERNAME_OK && strcmp(input, httpPassword) == 0) {
|
||||
if(telnetLoginState == TELNET_USERNAME_OK && strcmp(input, http_config.password) == 0) {
|
||||
telnetClientLogon();
|
||||
} else {
|
||||
telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||
@ -206,7 +209,7 @@ static inline void telnetProcessLine(const char * input)
|
||||
if(telnetLoginAttempt >= 3) {
|
||||
telnetClientDisconnect();
|
||||
} else {
|
||||
telnetClient.print(F(D_TELNET_USERNAME " "));
|
||||
telnetClient.print(F(D_USERNAME " "));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -218,7 +221,7 @@ static inline void telnetProcessLine(const char * input)
|
||||
if(strcasecmp_P(input, PSTR("exit")) == 0) {
|
||||
telnetClientDisconnect();
|
||||
} else if(strcasecmp_P(input, PSTR("logoff")) == 0) {
|
||||
telnetClient.println(F("\r\n" D_TELNET_USERNAME " "));
|
||||
telnetClient.println(F("\r\n" D_USERNAME " "));
|
||||
telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||
} else {
|
||||
dispatch_text_line(input);
|
||||
|
Loading…
x
Reference in New Issue
Block a user