luci-base: luci.sys: canonicalize src and dest addrs in luci.sys.net.conntrack()
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 20 Feb 2016 21:14:37 +0000 (22:14 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 20 Feb 2016 21:14:47 +0000 (22:14 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
modules/luci-base/luasrc/sys.lua

index fb2c4b1..a972717 100644 (file)
@@ -343,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)
                        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
                                        if entry[key] == nil then
                                                entry[key] = val
                                        end