04.08.2022, 06:50
Another option is to use mac address instead of IP. This will only work for local clients (not external via port forward).
Run script once:
Add to Custom JS (replace IP check script):
Run script once:
Code:
io.writefile('/www/user/mac.lp', [[<?
clientip = ngx.var.remote_addr
lines = io.readfile('/proc/net/arp'):split('\n')
for i = 2, #lines do
ip, _, _, mac = unpack(lines[ i ]:gsub('%s+', ' '):split(' '))
if clientip == ip then
write(mac)
break
end
end
?>]])
Add to Custom JS (replace IP check script):
Code:
$(function() {
if ($('body').hasClass('usermode') || $('html').hasClass('touch')) {
var plans = {
'aa:bb:cc:dd:ee:ff': 9,
};
$.get('/user/mac.lp', function(resp) {
var mac = $.trim(resp);
var plan = plans[ mac ];
if (plan) {
showPlan(plan);
}
});
}
});