Browse Source

Option to enable TELNET in STA mode from the Web UI

fastled
Xose Pérez 7 years ago
parent
commit
64d502b6b6
7 changed files with 3584 additions and 3564 deletions
  1. +2
    -2
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +3562
    -3557
      code/espurna/static/index.html.gz.h
  4. +4
    -3
      code/espurna/telnet.ino
  5. +5
    -0
      code/espurna/web.ino
  6. +10
    -1
      code/html/index.html
  7. +1
    -1
      code/ota_flash.sh

+ 2
- 2
code/espurna/config/general.h View File

@ -18,8 +18,8 @@
#define TELNET_SUPPORT 1 // Enable telnet support by default #define TELNET_SUPPORT 1 // Enable telnet support by default
#endif #endif
#ifndef TELNET_ONLY_AP
#define TELNET_ONLY_AP 1 // By default, allow only connections via AP interface
#ifndef TELNET_STA
#define TELNET_STA 0 // By default, disallow connections via STA interface
#endif #endif
#define TELNET_PORT 23 // Port to listen to telnet clients #define TELNET_PORT 23 // Port to listen to telnet clients


BIN
code/espurna/data/index.html.gz View File


+ 3562
- 3557
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 4
- 3
code/espurna/telnet.ino View File

@ -57,8 +57,9 @@ void _telnetData(unsigned char clientId, void *data, size_t len) {
void _telnetNewClient(AsyncClient *client) { void _telnetNewClient(AsyncClient *client) {
#if TELNET_ONLY_AP
if (client->localIP() != WiFi.softAPIP()) {
if (client->localIP() != WiFi.softAPIP()) {
bool telnetSTA = getSetting("telnetSTA", TELNET_STA).toInt() == 1;
if (!telnetSTA) {
DEBUG_MSG_P(PSTR("[TELNET] Rejecting - Only local connections\n")); DEBUG_MSG_P(PSTR("[TELNET] Rejecting - Only local connections\n"));
client->onDisconnect([](void *s, AsyncClient *c) { client->onDisconnect([](void *s, AsyncClient *c) {
c->free(); c->free();
@ -67,7 +68,7 @@ void _telnetNewClient(AsyncClient *client) {
client->close(true); client->close(true);
return; return;
} }
#endif
}
for (unsigned char i = 0; i < TELNET_MAX_CLIENTS; i++) { for (unsigned char i = 0; i < TELNET_MAX_CLIENTS; i++) {
if (!_telnetClients[i] || !_telnetClients[i]->connected()) { if (!_telnetClients[i] || !_telnetClients[i]->connected()) {


+ 5
- 0
code/espurna/web.ino View File

@ -688,6 +688,11 @@ void _wsStart(uint32_t client_id) {
} }
#endif #endif
#if TELNET_SUPPORT
root["telnetVisible"] = 1;
root["telnetSTA"] = getSetting("telnetSTA", TELNET_STA).toInt() == 1;
#endif
root["maxNetworks"] = WIFI_MAX_NETWORKS; root["maxNetworks"] = WIFI_MAX_NETWORKS;
JsonArray& wifi = root.createNestedArray("wifi"); JsonArray& wifi = root.createNestedArray("wifi");
for (byte i=0; i<WIFI_MAX_NETWORKS; i++) { for (byte i=0; i<WIFI_MAX_NETWORKS; i++) {


+ 10
- 1
code/html/index.html View File

@ -435,7 +435,7 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="adminPass2">Admin password (repeat)</label>
<label class="pure-u-1 pure-u-md-1-4" for="adminPass2">Repeat password</label>
<input name="adminPass2" class="pure-u-1 pure-u-md-3-4" type="password" tabindex="12" autocomplete="false" /> <input name="adminPass2" class="pure-u-1 pure-u-md-3-4" type="password" tabindex="12" autocomplete="false" />
</div> </div>
@ -466,6 +466,15 @@
</div> </div>
</div> </div>
<div class="pure-g module module-telnet">
<div class="pure-u-1 pure-u-sm-1-4"><label for="telnetSTA">Enable TELNET</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="telnetSTA" /></div>
<div class="pure-u-0 pure-u-md-1-2">&nbsp;</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Turn ON to be able to telnet to your device while connected to your home router.<br />TELNET is always enabled in AP mode.</div>
</div>
<div class="pure-g module module-nofuss"> <div class="pure-g module module-nofuss">
<div class="pure-u-1 pure-u-sm-1-4"><label for="nofussEnabled">Automatic remote updates (NoFUSS)</label></div> <div class="pure-u-1 pure-u-sm-1-4"><label for="nofussEnabled">Automatic remote updates (NoFUSS)</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="nofussEnabled" /></div> <div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" name="nofussEnabled" /></div>


+ 1
- 1
code/ota_flash.sh View File

@ -173,7 +173,7 @@ if [ "$auth" == "" ]; then
fi fi
if [ "$flags" == "" ]; then if [ "$flags" == "" ]; then
read -p "Extra flags for the build: " -e -i "-DTELNET_ONLY_AP=0" flags
read -p "Extra flags for the build: " -e -i "" flags
fi fi
read -p "Environment to build: " -e -i "esp8266-1m-ota" env read -p "Environment to build: " -e -i "esp8266-1m-ota" env


Loading…
Cancel
Save