Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-app-nft-qos: Remove the redundant MAC address of the static IP speed limit #6477

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ if limit_enable == "1" and limit_type == "static" then
o.titleref = luci.dispatcher.build_url("admin", "status", "overview")
end

o = y:option(Value, "macaddr", translate("MAC (optional)"))
o.rmempty = true
o.datatype = "macaddr"

o = y:option(Value, "rate", translate("Rate"))
o.default = def_rate_ul or '50'
o.size = 4
Expand Down
19 changes: 19 additions & 0 deletions modules/luci-base/root/usr/share/rpcd/ucode/luci
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,25 @@ const methods = {
call: function() {
return { result: process_list() };
}
},

getOnlineUsers: {
call: function() {
const fd = open('/proc/net/arp', 'r');
if (fd) {
let onlineusers = 0;

for (let line = fd.read('line'); length(line); line = fd.read('line'))
if (match(trim(line), /^.*(0x2).*(br-lan)$/))
onlineusers++;

fd.close();

return { onlineusers: onlineusers };
} else {
return { onlineusers: error() };
}
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
'require fs';
'require network';

var callOnlineUsers = rpc.declare({
object: 'luci',
method: 'getOnlineUsers'
});

function progressbar(value, max, byte) {
var vn = parseInt(value) || 0,
mn = parseInt(max) || 100,
Expand Down Expand Up @@ -67,18 +72,21 @@ return baseclass.extend({
fs.trimmed('/proc/sys/net/netfilter/nf_conntrack_count'),
fs.trimmed('/proc/sys/net/netfilter/nf_conntrack_max'),
network.getWANNetworks(),
network.getWAN6Networks()
network.getWAN6Networks(),
L.resolveDefault(callOnlineUsers(), {})
]);
},

render: function(data) {
var ct_count = +data[0],
ct_max = +data[1],
wan_nets = data[2],
wan6_nets = data[3];
wan6_nets = data[3],
onlineusers = data[4];

var fields = [
_('Active Connections'), ct_max ? ct_count : null
_('Active Connections'), ct_max ? ct_count : null,
_('Online Users'), onlineusers ? onlineusers.onlineusers : null
];

var ctstatus = E('table', { 'class': 'table' });
Expand Down