X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fsys.lua;h=a97271732ad0f2d0d72db2b4695963dc391e9e3f;hb=c8675d0c5560fb47eace7db531c381edbef25db7;hp=a1b5b8f645660388aa04c8da5f1c594b26c58eed;hpb=df7ab69ebaef870ecb82effd27f0b9958f1c203d;p=project%2Fluci.git diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua index a1b5b8f64..a97271732 100644 --- a/modules/luci-base/luasrc/sys.lua +++ b/modules/luci-base/luasrc/sys.lua @@ -185,14 +185,18 @@ local function _nethints(what, callback) end end - if fs.access("/var/dhcp.leases") then - for e in io.lines("/var/dhcp.leases") do - mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)") - if mac and ip then - _add(what, mac:upper(), ip, nil, name ~= "*" and name) + cur:foreach("dhcp", "dnsmasq", + function(s) + if s.leasefile and fs.access(s.leasefile) then + for e in io.lines(s.leasefile) do + mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)") + if mac and ip then + _add(what, mac:upper(), ip, nil, name ~= "*" and name) + end + end end end - end + ) cur:foreach("dhcp", "host", function(s) @@ -321,12 +325,10 @@ function net.conntrack(callback) local line, connt = nil, (not callback) and { } for line in nfct do - local fam, l3, l4, timeout, state, tuples = - line:match("^(ipv[46]) +(%d+) +%S+ +(%d+) +(%d+) +([A-Z_]+) +(.+)$") + local fam, l3, l4, timeout, tuples = + line:match("^(ipv[46]) +(%d+) +%S+ +(%d+) +(%d+) +(.+)$") - if fam and l3 and l4 and timeout and state and tuples and - state ~= "TIME_WAIT" - then + if fam and l3 and l4 and timeout and not tuples:match("^TIME_WAIT ") then l4 = nixio.getprotobynumber(l4) local entry = { @@ -341,7 +343,11 @@ function net.conntrack(callback) for key, val in tuples:gmatch("(%w+)=(%S+)") do if key == "bytes" or key == "packets" then entry[key] = entry[key] + tonumber(val, 10) - elseif key == "src" or key == "dst" or key == "sport" or key == "dport" then + elseif key == "src" or key == "dst" then + if entry[key] == nil then + entry[key] = luci.ip.new(val):string() + end + elseif key == "sport" or key == "dport" then if entry[key] == nil then entry[key] = val end