Start making changes for Danny's security settings

pull/205/head
Alex 8 years ago
parent b8404a1c1c
commit bda82deddb
  1. 22
      esp-link/cgitelnet.c
  2. 14
      esp-link/config.c
  3. 2
      esp-link/config.h
  4. 2
      esp-link/main.c

@ -3,6 +3,8 @@
#include "config.h" #include "config.h"
#include "serbridge.h" #include "serbridge.h"
static char *portMode[] = { "open", "disabled", "secure" };
// Cgi to return choice of Telnet ports // Cgi to return choice of Telnet ports
int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) { int ICACHE_FLASH_ATTR cgiTelnetGet(HttpdConnData *connData) {
char buff[80]; char buff[80];
@ -96,3 +98,23 @@ int ICACHE_FLASH_ATTR cgiTelnet(HttpdConnData *connData) {
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
} }
} }
static char *portMode2string(int8_t m) { //Should we put this into flash?
if (m < 0 || m > 2) return "?";
return portMode[m];
}
// print various Telnet information into json buffer
int ICACHE_FLASH_ATTR printTelnetSecurity(char *buff) {
int len;
len = os_sprintf(buff,
"{ \"port0mode\": \"%s\", \"port0portnumber\": \"%d\", \"port0pwd\": \"%s\", "
"\"port1mode\": \"%s\", \"port1portnumber\": \"%d\", \"port1pwd\": \"%s\" }",
portMode2string(flashConfig.telnet_port0mode), flashConfig.telnet_port0, flashConfig.telnet_port0pass,
portMode2string(flashConfig.telnet_port1mode), flashConfig.telnet_port1, flashConfig.telnet_port1pass
);
return len;
}

@ -39,6 +39,8 @@ FlashConfig flashDefault = {
.telnet_port1 = 2323, .telnet_port1 = 2323,
.telnet_port0mode = 0, .telnet_port0mode = 0,
.telnet_port1mode = 0, .telnet_port1mode = 0,
.telnet_port0pass = "123456",
.telnet_port1pass = "123456",
}; };
typedef union { typedef union {
@ -166,8 +168,16 @@ bool ICACHE_FLASH_ATTR configRestore(void) {
flashConfig.stop_bits = flashDefault.stop_bits; flashConfig.stop_bits = flashDefault.stop_bits;
} }
if (flashConfig.telnet_port0 == 0) { flashConfig.telnet_port0 = flashDefault.telnet_port0; } if (flashConfig.telnet_port0 == 0) {
if (flashConfig.telnet_port1 == 0) { flashConfig.telnet_port1 = flashDefault.telnet_port1; } flashConfig.telnet_port0 = flashDefault.telnet_port0;
flashConfig.telnet_port0mode = flashDefault.telnet_port0mode;
flashConfig.telnet_port0pass = flashDefault.telnet_port0pass;
}
if (flashConfig.telnet_port1 == 0) {
flashConfig.telnet_port1 = flashDefault.telnet_port1;
flashConfig.telnet_port1mode = flashDefault.telnet_port1mode;
flashConfig.telnet_port1pass = flashDefault.telnet_port1pass;
}
return true; return true;
} }

@ -45,6 +45,8 @@ typedef struct {
telnet_port1; telnet_port1;
int8_t telnet_port0mode, int8_t telnet_port0mode,
telnet_port1mode; telnet_port1mode;
char telnet_port0pass[32],
telnet_port1pass[32];
} FlashConfig; } FlashConfig;
extern FlashConfig flashConfig; extern FlashConfig flashConfig;
extern FlashConfig flashDefault; extern FlashConfig flashDefault;

@ -180,7 +180,7 @@ user_init(void) {
httpdInit(builtInUrls, 80); httpdInit(builtInUrls, 80);
WEB_Init(); WEB_Init();
// init the wifi-serial transparent bridge (port 23) // init the wifi-serial configurable transparent bridge (port defaults 23&2323)
serbridgeInit(); serbridgeInit();
serbridgeStart(0, flashConfig.telnet_port0, flashDefault.telnet_port0mode); serbridgeStart(0, flashConfig.telnet_port0, flashDefault.telnet_port0mode);
serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode); serbridgeStart(1, flashConfig.telnet_port1, flashDefault.telnet_port1mode);

Loading…
Cancel
Save