我想阻止下载值超过“20480”的mac地址:
json文件:
{
"client_length": 3,
"clients": {
"ac:07:5f:77:40:e9": {
"id": 1,
"ip": "192.168.5.40",
"mac": "ac:07:5f:85:40:e9",
"added": 1576258952,
"active": 1576264642,
"duration": 5711,
"token": "4d8fd3ce",
"state": "Authenticated",
"downloaded": 45059,
"avg_down_speed": 63.12,
"uploaded": 2976,
"avg_up_speed": 4.17
},
"ac:e0:10:55:2d:78": {
"id": 2,
"ip": "192.168.5.132",
"mac": "ac:e0:10:12:2d:75",
"added": 1576258985,
"active": 1576264663,
"duration": 5678,
"token": "35dfa494",
"state": "Authenticated",
"downloaded": 18663,
"avg_down_speed": 26.3,
"uploaded": 4986,
"avg_up_speed": 7.03
},
"58:48:44:db:ba:ba": {
"id": 3,
"ip": "192.168.5.93",
"mac": "58:48:22:db:ba:be",
"added": 1576258973,
"active": 1576264662,
"duration": 5690,
"token": "139fede2",
"state": "Authenticated",
"downloaded": 187876,
"avg_down_speed": 264.15,
"uploaded": 7910,
"avg_up_speed": 11.12
}
}
}
此外,这是结果,ndsctl json
而且总是会改变。ndsctl 是 nodogsplash 包的一部分。我已经在 OpenWrt (BusyBox v1.28.4) 上安装了这个包。
我的目标:
上面的 json 给了我一些信息。根据这个文件,我想阻止ac:07:5f:77:40:e9
,58:48:44:db:ba:ba
因为它们的下载值超过了“20480”。
我需要一个 bash 脚本来为我做这件事。
阻止mac地址的命令:
ndsctl block ac:07:5f:77:40:e9
ndsctl block 58:48:44:db:ba:ba
我做了一些事情:
root@OpenWrt:~# cat test.json | grep "mac\|downloaded"
"mac":"ac:07:5f:85:40:e9",
"downloaded":45059,
"mac":"ac:e0:10:55:2d:78",
"downloaded":18663,
"mac":"58:48:44:db:ba:ba",
"downloaded":187876,
任何想法?