Fixed net.dns.getdnsserver() by @md5crypt.
This commit is contained in:
parent
11ca2bc096
commit
a32df17579
|
@ -13,6 +13,7 @@
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "espconn.h"
|
#include "espconn.h"
|
||||||
|
#include "lwip/dns.h"
|
||||||
|
|
||||||
#ifdef CLIENT_SSL_ENABLE
|
#ifdef CLIENT_SSL_ENABLE
|
||||||
unsigned char *default_certificate;
|
unsigned char *default_certificate;
|
||||||
|
@ -1447,14 +1448,16 @@ static int net_getdnsserver( lua_State* L )
|
||||||
if (numdns >= DNS_MAX_SERVERS)
|
if (numdns >= DNS_MAX_SERVERS)
|
||||||
return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1);
|
return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1);
|
||||||
|
|
||||||
ip_addr_t ipaddr;
|
// ip_addr_t ipaddr;
|
||||||
dns_getserver(numdns,&ipaddr);
|
// dns_getserver(numdns,&ipaddr);
|
||||||
|
// Bug fix by @md5crypt https://github.com/nodemcu/nodemcu-firmware/pull/500
|
||||||
|
ip_addr_t ipaddr = dns_getserver(numdns);
|
||||||
|
|
||||||
if ( ip_addr_isany(&ipaddr) ) {
|
if ( ip_addr_isany(&ipaddr) ) {
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
} else {
|
} else {
|
||||||
char temp[20] = {0};
|
char temp[20] = {0};
|
||||||
c_sprintf(temp, IPSTR, IP2STR( &ipaddr ) );
|
c_sprintf(temp, IPSTR, IP2STR( &ipaddr.addr ) );
|
||||||
lua_pushstring( L, temp );
|
lua_pushstring( L, temp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue