-for _, r in ipairs(ipt:find({table="filter", chain="luci_splash_filter", options={"MAC"}})) do
- local c = clients[r.options[2]:lower()]
- if c and c.packets == 0 then
- c.bytes = tonumber(r.bytes)
- c.packets = tonumber(r.packets)
+for mac, client in pairs(clients) do
+ client.bytes_in = 0
+ client.bytes_out = 0
+ client.packets_in = 0
+ client.packets_out = 0
+
+ if client.ipaddr then
+ local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=client.ipaddr})
+ local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", client.mac:upper()}})
+
+ if rin and #rin > 0 then
+ client.bytes_in = rin[1].bytes
+ client.packets_in = rin[1].packets
+ end
+
+ if rout and #rout > 0 then
+ client.bytes_out = rout[1].bytes
+ client.packets_out = rout[1].packets
+ end