diff --git a/install.sh b/install.sh index ae3c51d..0a460cb 100755 --- a/install.sh +++ b/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 \ No newline at end of file diff --git a/luci/cbi.lua b/luci/cbi.lua new file mode 100644 index 0000000..51ac557 --- /dev/null +++ b/luci/cbi.lua @@ -0,0 +1,50 @@ +local uci = require("luci.model.uci").cursor() + +ua3f = Map("ua3f", + "UA3F", + [[ + Version: 0.1.3 +
+ 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 "" .. translate("Disabled") .. "" + else + return "" .. translate("Enabled") .. "" + 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 diff --git a/luci/controller.lua b/luci/controller.lua new file mode 100644 index 0000000..569b3bd --- /dev/null +++ b/luci/controller.lua @@ -0,0 +1,5 @@ +module("luci.controller.ua3f", package.seeall) + +function index() + entry({"admin", "services", "ua3f"}, cbi("ua3f"), "UA3F", 1) +end \ No newline at end of file