nslookup added

This commit is contained in:
martin-ger
2018-12-22 10:22:05 +01:00
parent 5692c0fdcf
commit c1f51488b0
6 changed files with 47 additions and 7 deletions
+2 -1
View File
@@ -105,7 +105,6 @@ Most of the set-commands are effective only after save and reset.
- peap_password _value_: sets the PEAP password
### TCP/IP Config
- ping _ip-addr_: checks IP connectivity with ICMP echo request/reply
- set network _ip-addr_: sets the IP address of the internal network, network is always /24, router is always x.x.x.1
- set dns _dns-addr_: sets a static DNS address that is distributed to clients via DHCP
- set dns dhcp: configures use of the dynamic DNS address from DHCP, default
@@ -126,6 +125,8 @@ Most of the set-commands are effective only after save and reset.
- set nat [0|1]: selects, whether the soft-AP interface is NATed (nat=1, default) or not (nat=0). Without NAT transparent forwarding of traffic from the internal STAs doesn't work! Useful mainly in combination with static routing.
- portmap add [TCP|UDP] _external_port_ _internal_ip_ _internal_port_: adds a port forwarding
- portmap remove [TCP|UDP] _external_port_: deletes a port forwarding
- nslookup _name_: starts a DNS lookup for the given name and displays the result
- ping _ip-addr_: checks IP connectivity with ICMP echo request/reply
### Firewall/Monitor Config
- acl [from_sta|to_sta] [TCP|UDP|IP] _src-ip_ [_src_port_] _desr-ip_ [_dest_port_] [allow|deny|allow_monitor|deny_monitor]: adds a new rule to the ACL
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -1,3 +1,3 @@
b439bb9c264dd9df025213128d177bd4616e58c0 firmware/0x02000.bin
30a8bcf3972cf111fc2db7551e1799ea40905383 firmware/0x82000.bin
89709d6484a66253d3159f2740da338337805e0f firmware/0x02000.bin
04fdebd28ce94542519c08a4f94bec262ff343c6 firmware/0x82000.bin
9bd7d25204d71b3db5f35e0b2def8a6aaa7f765c firmware/0x00000.bin
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef _USER_CONFIG_
#define _USER_CONFIG_
#define ESP_REPEATER_VERSION "V2.2.2"
#define ESP_REPEATER_VERSION "V2.2.3"
#define LOCAL_ACCESS 0x01
#define REMOTE_ACCESS 0x02
+42 -3
View File
@@ -103,6 +103,8 @@ bool connected;
uint8_t my_channel;
bool do_ip_config;
static ip_addr_t resolve_ip;
uint8_t mesh_level;
uint8_t uplink_bssid[6];
@@ -232,6 +234,20 @@ static void ICACHE_FLASH_ATTR mqttDataCb(uint32_t *args, const char* topic, uint
}
#endif /* MQTT_CLIENT */
// call back for dns lookup
static void ICACHE_FLASH_ATTR dns_resolved(const char *name, ip_addr_t *ip, void *arg) {
char response[128];
if (ip == 0) {
os_sprintf(response, "DNS lookup failed for: %s\r\n", name);
} else {
os_sprintf(response, "DNS lookup for %s: " IPSTR "\r\n", name, IP2STR(ip));
}
to_console(response);
system_os_post(0, SIG_CONSOLE_TX, (ETSParam) currentconn);
}
#if ALLOW_PING
struct ping_option ping_opt;
uint8_t ping_success_count;
@@ -925,10 +941,14 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn)
os_sprintf_flash(response, "set [daily_limit|timezone] <val>\r\n");
to_console(response);
#endif
os_sprintf_flash(response, "nslookup <name>");
to_console(response);
#if ALLOW_PING
os_sprintf_flash(response, "ping <ip_addr>\r\n");
os_sprintf_flash(response, "|ping <ip_addr>");
to_console(response);
#endif
os_sprintf_flash(response, "\r\n");
to_console(response);
#if REMOTE_MONITORING
os_sprintf_flash(response, "monitor [on|off] <portnumber>\r\n");
to_console(response);
@@ -1628,12 +1648,30 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn)
goto command_handled;
}
}
if (strcmp(tokens[0], "nslookup") == 0)
{
if (nTokens != 2) {
os_sprintf(response, INVALID_NUMARGS);
goto command_handled;
}
to_console("\r\n");
uint32_t result = espconn_gethostbyname(NULL, tokens[1], &resolve_ip, dns_resolved);
if (result == ESPCONN_OK) {
os_sprintf(response, "DNS lookup for %s: " IPSTR "\r\n", tokens[1], IP2STR(&resolve_ip));
} else if (result == ESPCONN_INPROGRESS) {
// lookup taking place, will call dns_resolved on completion
return;
} else {
os_sprintf(response, "DNS lookup failed for: %s\r\n", tokens[1]);
}
goto command_handled;
}
#if ALLOW_SCANNING
if (strcmp(tokens[0], "scan") == 0)
{
to_console("Scanning...\r\n");
currentconn = pespconn;
wifi_station_scan(NULL,scan_done);
os_sprintf_flash(response, "Scanning...\r\n");
goto command_handled;
}
#endif
@@ -1644,9 +1682,10 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn)
os_sprintf(response, INVALID_NUMARGS);
goto command_handled;
}
to_console("\r\n");
currentconn = pespconn;
user_do_ping(ipaddr_addr(tokens[1]));
goto command_handled;
return;
}
#endif
#if OTAUPDATE