From e28cf8d983268a6ea669f4292d8e1912bfc701c8 Mon Sep 17 00:00:00 2001 From: vsky Date: Tue, 1 Sep 2020 21:26:25 +0200 Subject: [PATCH] Fixes `net.ifinfo` failure --- app/modules/net.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/modules/net.c b/app/modules/net.c index 74356d26..1455dea5 100644 --- a/app/modules/net.c +++ b/app/modules/net.c @@ -983,7 +983,10 @@ field_from_ipaddr(lua_State *L, const char * field_name, ip_addr_t* addr) { static int net_ifinfo( lua_State* L ) { int ifidx = luaL_optint(L, 1, 0); - + if (ifidx != 0 && ifidx != 1) { + return 0; + } + struct netif * nif = eagle_lwip_getif(ifidx); if (nif == NULL) { return 0; @@ -1004,8 +1007,8 @@ static int net_ifinfo( lua_State* L ) { field_from_ipaddr(L, "server_ip" , &nif->dhcp->server_ip_addr ); field_from_ipaddr(L, "client_ip" , &nif->dhcp->offered_ip_addr ); field_from_ipaddr(L, "ntp_server", &nif->dhcp->offered_ntp_addr); + lua_setfield(L, -2, "dhcp"); } - lua_setfield(L, -2, "dhcp"); return 1; }