forked from kiddin9/OpenAppFilter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
258 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
--[[ | ||
LuCI - Lua Configuration Interface | ||
Copyright 2008 Steven Barth <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
$Id$ | ||
]]-- | ||
|
||
local ds = require "luci.dispatcher" | ||
|
||
|
@@ -81,6 +68,57 @@ if class_fd then | |
end | ||
class_fd:close() | ||
end | ||
|
||
|
||
s=m:section(TypedSection,"user",translate("Select users")) | ||
s.anonymous = true | ||
users = s:option(MultiValue, "users", "", translate("Select at least one user, otherwise it will take effect for all users")) | ||
users.widget="checkbox" | ||
|
||
function get_hostname_by_mac(dst_mac) | ||
leasefile="/tmp/dhcp.leases" | ||
local fd = io.open(leasefile, "r") | ||
if not fd then return end | ||
while true do | ||
local ln = fd:read("*l") | ||
if not ln then | ||
break | ||
end | ||
local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)") | ||
print(ln) | ||
if dst_mac == mac then | ||
fd:close() | ||
return name | ||
end | ||
end | ||
fd:close() | ||
return nil | ||
end | ||
|
||
users.widget="checkbox" | ||
--users.widget="select" | ||
users.size=1 | ||
|
||
local fd = io.open("/proc/net/arp", "r") | ||
if not fd then return end | ||
while true do | ||
local line = fd:read("*l") | ||
if not line then | ||
break | ||
end | ||
if not line:match("Ip*") then | ||
local ip, hw_type, flags, mac, mask, device = line:match("(%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+)") | ||
if device:match("lan") then | ||
local hostname=get_hostname_by_mac(mac) | ||
if not hostname then | ||
users:value(mac, mac); | ||
else | ||
users:value(mac, hostname); | ||
end | ||
end | ||
end | ||
end | ||
|
||
m:section(SimpleSection).template = "admin_network/user_status" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
uci -q batch <<-EOF >/dev/null | ||
set appfilter.user=user | ||
commit appfilter | ||
EOF | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.