mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
feat: support luci
This commit is contained in:
parent
5b2bcb20b8
commit
65f0cbfefc
17
install.sh
17
install.sh
@ -67,6 +67,23 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
mv ua3f.uci /etc/config/ua3f
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/cbi.lua
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download cbi.lua Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
mv cbi.lua /usr/lib/lua/luci/model/cbi/ua3f.lua
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/controller.lua
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download controller.lua Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
mv controller.lua /usr/lib/lua/luci/controller/ua3f.lua
|
||||
|
||||
rm /tmp/luci-modulecache/* &> /dev/null
|
||||
rm /tmp/luci-indexcache* &> /dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Install UA3F Success."
|
||||
fi
|
||||
50
luci/cbi.lua
Normal file
50
luci/cbi.lua
Normal file
@ -0,0 +1,50 @@
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
|
||||
ua3f = Map("ua3f",
|
||||
"UA3F",
|
||||
[[
|
||||
<a href="https://github.com/SunBK201/UA3F" target="_blank">Version: 0.1.3</a>
|
||||
<br>
|
||||
Across the Campus we can reach every corner in the world.
|
||||
]]
|
||||
)
|
||||
|
||||
enable = ua3f:section(NamedSection, "enabled", "ua3f", "UA3F Status")
|
||||
main = ua3f:section(NamedSection, "main", "ua3f", "UA3F Settings")
|
||||
|
||||
enable:option(Flag, "enabled", "Enabled")
|
||||
status = enable:option(DummyValue, "status", "Status")
|
||||
status.rawhtml = true
|
||||
status.cfgvalue = function(self, section)
|
||||
local pid = luci.sys.exec("pidof ua3f")
|
||||
if pid == "" then
|
||||
return "<span style='color:red'>" .. translate("Disabled") .. "</span>"
|
||||
else
|
||||
return "<span style='color:green'>" .. translate("Enabled") .. "</span>"
|
||||
end
|
||||
end
|
||||
|
||||
main:tab("general", "General Settings")
|
||||
main:tab("log", "Log")
|
||||
|
||||
port = main:taboption("general", Value, "port", "Port")
|
||||
port.placeholder = "1080"
|
||||
bind = main:taboption("general", Value, "bind", "Bind Address")
|
||||
bind:value("127.0.0.1")
|
||||
bind:value("0.0.0.0")
|
||||
ua = main:taboption("general", Value, "ua", "User-Agent")
|
||||
ua.placeholder = "FFF"
|
||||
log_level = main:taboption("general", ListValue, "log_level", "Log Level")
|
||||
log_level:value("debug")
|
||||
log_level:value("info")
|
||||
log_level:value("warn")
|
||||
log_level:value("error")
|
||||
|
||||
log = main:taboption("log", TextValue, "")
|
||||
log.readonly = true
|
||||
log.cfgvalue = function(self, section)
|
||||
return luci.sys.exec("cat /var/log/ua3f.log")
|
||||
end
|
||||
log.rows = 30
|
||||
|
||||
return ua3f
|
||||
5
luci/controller.lua
Normal file
5
luci/controller.lua
Normal file
@ -0,0 +1,5 @@
|
||||
module("luci.controller.ua3f", package.seeall)
|
||||
|
||||
function index()
|
||||
entry({"admin", "services", "ua3f"}, cbi("ua3f"), "UA3F", 1)
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user