diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2016-01-20 16:55:15 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2016-01-20 16:56:25 +0100 |
commit | c23885f6a776db74aa728b1efcd1bf644dde626d (patch) | |
tree | 6df0b0a71a3bc9e694ef382c1d7b92b7b161b892 /modules/luci-base/luasrc/sys.lua | |
parent | e0988b089be0e33d64c62339cfdd90755b6dbd79 (diff) |
luci-base: add luci.sys.net.host_hints() and regenerate documentation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-base/luasrc/sys.lua')
-rw-r--r-- | modules/luci-base/luasrc/sys.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua index 31c3e1209..5d203aa8f 100644 --- a/modules/luci-base/luasrc/sys.lua +++ b/modules/luci-base/luasrc/sys.lua @@ -292,6 +292,28 @@ function net.ipv6_hints(callback) end end +function net.host_hints(callback) + if callback then + _nethints(1, function(mac, v4, v6, name) + if mac and mac ~= "00:00:00:00:00:00" and (v4 or v6 or name) then + callback(mac, v4, v6, name) + end + end) + else + local rv = { } + _nethints(1, function(mac, v4, v6, name) + if mac and mac ~= "00:00:00:00:00:00" and (v4 or v6 or name) then + local e = { } + if v4 then e.ipv4 = v4 end + if v6 then e.ipv6 = v6 end + if name then e.name = name end + rv[mac] = e + end + end) + return rv + end +end + function net.conntrack(callback) local ok, nfct = pcall(io.lines, "/proc/net/nf_conntrack") if not ok or not nfct then |