mirror of
https://github.com/kenzok8/small-package
synced 2025-01-08 13:27:36 +08:00
update 2023-11-15 09:14:36
This commit is contained in:
parent
059b0789f1
commit
008a73d6e5
@ -7,7 +7,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-lucky
|
||||
PKG_VERSION:=1.0.4
|
||||
PKG_VERSION:=1.1.1
|
||||
PKG_RELEASE:=5
|
||||
|
||||
LUCI_TITLE:=LuCI Support for Dynamic lucky Client
|
||||
|
@ -1,32 +1,54 @@
|
||||
-- Copyright (C) 2021-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-lucky
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
local SYS = require "luci.sys"
|
||||
|
||||
module("luci.controller.lucky", package.seeall)
|
||||
|
||||
function index()
|
||||
|
||||
entry({"admin", "services", "lucky"}, alias("admin", "services", "lucky", "setting"),_("Lucky"), 57).dependent = true
|
||||
local e=entry({"admin", "services", "lucky"}, alias("admin", "services", "lucky", "setting"),_("Lucky"), 57)
|
||||
e.dependent=false
|
||||
e.acl_depends={ "luci-app-lucky" }
|
||||
entry({"admin", "services", "lucky", "setting"}, cbi("lucky"), _("Base Setting"), 20).leaf=true
|
||||
entry({"admin", "services", "lucky", "lucky"}, template("lucky"), _("Lucky"), 30).leaf = true
|
||||
entry({"admin", "services", "lucky", "lucky_admin"}, call("lucky_admin")).leaf = true
|
||||
entry({"admin", "services", "lucky_status"}, call("act_status"))
|
||||
entry({"admin", "services", "lucky_status"}, call("lucky_status"))
|
||||
entry({"admin", "services", "lucky_config"}, call("lucky_config"))
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local uci = require 'luci.model.uci'.cursor()
|
||||
local port = tonumber(uci:get_first("lucky", "lucky", "port"))
|
||||
|
||||
function lucky_config()
|
||||
local e = { }
|
||||
e.running = luci.sys.call("pidof lucky >/dev/null") == 0
|
||||
e.port = (port or 16601)
|
||||
e.safeurl = luci.sys.exec("cat /etc/lucky/lucky.conf | grep SafeURL | sed -e 's/,//g' -e 's/\"//g' -e 's/\ //g' | awk -F ':' '{print $2}' ")
|
||||
local luckyInfo = SYS.exec("/usr/bin/lucky -info")
|
||||
if (luckyInfo~=nil)
|
||||
then
|
||||
local configObj = ConfigureObj()
|
||||
if (configObj~=nil)
|
||||
then
|
||||
e.BaseConfigure = configObj["BaseConfigure"]
|
||||
end
|
||||
end
|
||||
e.luckyArch = SYS.exec("/usr/bin/luckyarch")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
|
||||
function lucky_status()
|
||||
local e = { }
|
||||
e.status = SYS.call("pgrep -f 'lucky -c' >/dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function lucky_admin()
|
||||
local e = { }
|
||||
e.username = luci.sys.exec("cat /etc/lucky/lucky.conf | grep AdminAccount | sed -e 's/,//g' -e 's/\"//g' | awk -F ':' '{print $2}' ")
|
||||
e.password = luci.sys.exec("cat /etc/lucky/lucky.conf | grep AdminPassword | sed -e 's/,//g' -e 's/\"//g' | awk -F ':' '{print $2}' ")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
|
||||
function trim(s)
|
||||
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
|
||||
function ConfigureObj()
|
||||
configPath = trim(luci.sys.exec("uci get lucky.@lucky[0].configdir"))
|
||||
local configContent = luci.sys.exec("lucky -baseConfInfo -cd "..configPath)
|
||||
configObj = luci.jsonc.parse(trim(configContent))
|
||||
return configObj
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ local m, s ,o
|
||||
|
||||
m = Map("lucky")
|
||||
m.title = translate("Lucky")
|
||||
m.description = translate("Main functions of Lucky: dynamic domain name ddns-go service, which replaces socat. It is mainly used for public IPv6 tcp/udp to intranet ipv4, http/https reverse proxy frp")..translate("</br>For specific usage, see:")..translate("<a href=\'https://github.com/sirpdboy/luci-app-lucky.git' target=\'_blank\'>GitHub @sirpdboy/luci-app-lucky </a>。")
|
||||
m.description = translate("ipv4/ipv6 portforward,ddns,reverseproxy proxy,wake on lan,IOT and more,Default username and password 666")
|
||||
|
||||
m:section(SimpleSection).template = "lucky_status"
|
||||
|
||||
@ -19,12 +19,9 @@ o = s:option(Value, "port",translate("Set the Lucky access port"))
|
||||
o.datatype = "uinteger"
|
||||
o.default = 16601
|
||||
|
||||
o = s:option(Flag, "AllowInternetaccess", translate("Enable Internet access"))
|
||||
o.default=0
|
||||
|
||||
o = s:option(Button, "lucky_admin", translate("View Password"))
|
||||
o.rawhtml = true
|
||||
o.template = "lucky_admin"
|
||||
o = s:option( Value, "configdir", translate("Config dir path"),translate("The path to store the config file"))
|
||||
o.placeholder = "/etc/lucky"
|
||||
o.default="/etc/lucky"
|
||||
|
||||
m.apply_on_parse = true
|
||||
m.on_after_apply = function(self,map)
|
||||
|
@ -2,36 +2,38 @@
|
||||
Copyright 2021-2022 sirpdboy Wich <herboy2008@gmail.com>
|
||||
https://github.com/sirpdboy/luci-app-lucky
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%
|
||||
local safeURL = luci.sys.exec("cat /etc/lucky/lucky.conf | grep SafeURL | sed -e 's/,//g' -e 's/\"//g' -e 's/\ //g' | awk -F ':' '{print $2}' ")
|
||||
local luckyHttpPort = luci.model.uci.cursor():get("lucky", "lucky", "port");
|
||||
-%>
|
||||
%>
|
||||
|
||||
<%+header%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var URL = ""
|
||||
XHR.get('<%=url([[admin]], [[services]], [[lucky_config]])%>', null,
|
||||
function (x, d) {
|
||||
if (d) {
|
||||
URL = "http://" + window.location.hostname + ":" + d.BaseConfigure.AdminWebListenPort;
|
||||
if (d.BaseConfigure.SafeURL != undefined) {
|
||||
URL += d.BaseConfigure.SafeURL;
|
||||
|
||||
console.log("test" + URL)
|
||||
document.getElementById("luckyiframe").src = URL
|
||||
document.getElementById("luckyiframe").height = document.documentElement.clientHeight;
|
||||
window.onresize = function(){
|
||||
document.getElementById("luckyiframe").height = document.documentElement.clientHeight;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//]]></script>
|
||||
<div class="cbi-map">
|
||||
|
||||
<iframe id="lucky" style="width: 100%; min-height: 780px; border: none; border-radius: .375rem;box-shadow: rgba(0, 0, 0, 0.75) 0px 0px 15px -5px;"><br/><em style=\"color:red\">
|
||||
<iframe id="luckyiframe" style="width: 100%; min-height: 780px; border: none; border-radius: .375rem;box-shadow: rgba(0, 0, 0, 0.75) 0px 0px 15px -5px;"><br/><em style=\"color:red\">
|
||||
<p ><em><%:The Lucky service is not running.%></em></p>
|
||||
</iframe>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
var luckyAdminURL = ""+ window.location.protocol + "//" + window.location.hostname +":"+ `<%=luckyHttpPort%>`+`<%=safeURL%>`;
|
||||
|
||||
document.getElementById("lucky").src = luckyAdminURL
|
||||
document.getElementById("lucky").height = document.documentElement.clientHeight;
|
||||
window.onresize = function(){
|
||||
document.getElementById("lucky").height = document.documentElement.clientHeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<%+footer%>
|
||||
|
@ -1,26 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function admin_info(btn)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Reading...%>';
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "lucky", "lucky_admin")%>',
|
||||
null,
|
||||
function(x,d)
|
||||
{
|
||||
var tb = document.getElementById('<%=self.option%>-status');
|
||||
if (tb)
|
||||
{
|
||||
tb.innerHTML = "<%:Username:%>" + "<font color='green'>" + d.username + "</font>";
|
||||
tb.innerHTML += "<%:Password:%>" + "<font color='green'>" + d.password + "</font>";
|
||||
}
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Read%>';
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Read%>" onclick="return admin_info(this)" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
<%+cbi/valuefooter%>
|
@ -1,26 +1,45 @@
|
||||
<%
|
||||
protocol="http://"
|
||||
|
||||
%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var URL = ""
|
||||
var URLSAFE = ""
|
||||
function Luckyconfig() {
|
||||
XHR.get('<%=url([[admin]], [[services]], [[lucky_config]])%>', null,
|
||||
function (x, d) {
|
||||
if (d) {
|
||||
URL = "http://" + window.location.hostname + ":" + d.BaseConfigure.AdminWebListenPort;
|
||||
URLSAFE = "http://" + window.location.hostname + ":" + d.BaseConfigure.AdminWebListenPort;
|
||||
if (d.BaseConfigure.SafeURL != undefined) {
|
||||
URL += d.BaseConfigure.SafeURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[lucky_status]])%>', null,
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[lucky_status]])%>', null,
|
||||
function(x, d) {
|
||||
var tb = document.getElementById('lucky_status');
|
||||
if (d && tb)
|
||||
{
|
||||
if (d.running)
|
||||
if (d.status)
|
||||
{
|
||||
var luckyAdminURL = ""+ window.location.protocol + "//" + window.location.hostname +":"+ d.port+d.safeurl+"";
|
||||
Luckyconfig()
|
||||
tb.innerHTML = '<em><b style=\"color:green\"><%:The Lucky service is running.%></b></em>';
|
||||
tb.innerHTML +='<em> <br/><br/>' + ' <b > <%:Click the new page to open Lucky%> <a href="' +luckyAdminURL+'"'+' target="_blank">' + luckyAdminURL + ' </a><br/> </em>';
|
||||
tb.innerHTML +='<em> <br/><br/><%:Click the new page to open Lucky%> </em>';
|
||||
tb.innerHTML += "<input class=\"cbi-button cbi-button-reload \" type=\"button\" value=\" "+ URLSAFE+ "\" onclick=\"window.open('"+URL+"')\"/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.innerHTML = '<em><b style=\"color:red\"><%:The Lucky service is not running.%></b></em>';
|
||||
tb.innerHTML = '<em style=\"color:red\"><%:The Lucky service is not running.%></em><br/>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//]]></script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
|
@ -1,11 +1,14 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
msgid "Config dir path"
|
||||
msgstr "配置文件夹位置"
|
||||
|
||||
msgid "Lucky"
|
||||
msgstr "Lucky大吉"
|
||||
|
||||
msgid "Main functions of Lucky: dynamic domain name ddns-go service, which replaces socat. It is mainly used for public IPv6 tcp/udp to intranet ipv4, http/https reverse proxy frp"
|
||||
msgstr "大吉主要功能:动态域名ddns-go服务,替代socat主要用于公网IPv6 tcp/udp转内网ipv4,http/https反向代理,网络唤醒(可通过第三方物联网平台接入各大语音助手实现语音控制开关电脑)"
|
||||
msgid "ipv4/ipv6 portforward,ddns,reverseproxy proxy,wake on lan,IOT and more,Default username and password 666"
|
||||
msgstr "IPv4/IPv6端口转发,动态域名服务,http/https反向代理,默认用户名密码666.."
|
||||
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
@ -28,29 +31,15 @@ msgstr "设置访问端口"
|
||||
msgid "Lucky configuration file"
|
||||
msgstr "Lucky 配置文件"
|
||||
|
||||
msgid "The path to store the config file"
|
||||
msgstr "存放配置文件的位置"
|
||||
|
||||
msgid "</br>For specific usage, see:"
|
||||
msgstr "</br>具体使用方法参见:"
|
||||
|
||||
msgid "Base Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Enable Internet access"
|
||||
msgstr "开启外网访问"
|
||||
|
||||
msgid "Click the new page to open Lucky"
|
||||
msgstr "点击新页面打开大吉"
|
||||
|
||||
msgid "View Password"
|
||||
msgstr "查看密码"
|
||||
|
||||
msgid "Username:"
|
||||
msgstr "用户名:"
|
||||
|
||||
msgid "Password:"
|
||||
msgstr "密码:"
|
||||
|
||||
msgid "Reading..."
|
||||
msgstr "读取中..."
|
||||
|
||||
msgid "Read"
|
||||
msgstr "读取"
|
@ -1 +0,0 @@
|
||||
zh-cn
|
45
luci-app-lucky/po/zh_Hans/lucky.po
Normal file
45
luci-app-lucky/po/zh_Hans/lucky.po
Normal file
@ -0,0 +1,45 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
msgid "Config dir path"
|
||||
msgstr "配置文件夹位置"
|
||||
|
||||
msgid "Lucky"
|
||||
msgstr "Lucky大吉"
|
||||
|
||||
msgid "ipv4/ipv6 portforward,ddns,reverseproxy proxy,wake on lan,IOT and more,Default username and password 666"
|
||||
msgstr "IPv4/IPv6端口转发,动态域名服务,http/https反向代理,默认用户名密码666.."
|
||||
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "The Lucky service is running."
|
||||
msgstr "大吉服务已启动"
|
||||
|
||||
msgid "The Lucky service is not running."
|
||||
msgstr "大吉服务未启动"
|
||||
|
||||
msgid "Lucky Status"
|
||||
msgstr "大吉服务状态"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "收集数据..."
|
||||
|
||||
msgid "Set the Lucky access port"
|
||||
msgstr "设置访问端口"
|
||||
|
||||
msgid "Lucky configuration file"
|
||||
msgstr "Lucky 配置文件"
|
||||
|
||||
msgid "The path to store the config file"
|
||||
msgstr "存放配置文件的位置"
|
||||
|
||||
msgid "</br>For specific usage, see:"
|
||||
msgstr "</br>具体使用方法参见:"
|
||||
|
||||
msgid "Base Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Click the new page to open Lucky"
|
||||
msgstr "点击新页面打开大吉"
|
||||
|
@ -1,5 +1,5 @@
|
||||
config lucky 'lucky'
|
||||
option enabled '0'
|
||||
option logger '1'
|
||||
option port '16601'
|
||||
option AllowInternetaccess '0'
|
||||
option configdir '/etc/lucky'
|
||||
option enabled '0'
|
||||
|
50
luci-app-lucky/root/etc/init.d/lucky
Executable file → Normal file
50
luci-app-lucky/root/etc/init.d/lucky
Executable file → Normal file
@ -9,50 +9,52 @@
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
STOP=10
|
||||
STOP=15
|
||||
|
||||
CONF="lucky"
|
||||
PROG=/usr/bin/lucky
|
||||
LUCKYDIR=/etc/lucky
|
||||
LUCKYCONF=/etc/lucky/lucky.conf
|
||||
DEFAULT_DIR='/etc/config/lucky.daji/'
|
||||
|
||||
get_tz()
|
||||
{
|
||||
SET_TZ=""
|
||||
|
||||
[ -e "/etc/localtime" ] && return
|
||||
|
||||
for tzfile in /etc/TZ /var/etc/TZ
|
||||
do
|
||||
[ -e "$tzfile" ] || continue
|
||||
tz="$(cat $tzfile 2>/dev/null)"
|
||||
done
|
||||
|
||||
[ -z "$tz" ] && return
|
||||
|
||||
SET_TZ=$tz
|
||||
}
|
||||
|
||||
get_config() {
|
||||
config_get_bool enabled $1 enabled 1
|
||||
config_get_bool logger $1 logger 1
|
||||
config_get port $1 port 16601
|
||||
config_get AllowInternetaccess $1 AllowInternetaccess 0
|
||||
config_get_bool logger $1 logger 1
|
||||
config_get configdir $1 configdir $DEFAULT_DIR
|
||||
}
|
||||
|
||||
lucky_prepare() {
|
||||
pgrep -f $PROG | xargs kill -9 >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
start_service() {
|
||||
stop_service
|
||||
config_load "$CONF"
|
||||
config_foreach get_config "$CONF"
|
||||
|
||||
[ "x$enabled" = "x1" ] || return 1
|
||||
if [ "x$AllowInternetaccess" = "x1" ] ;then
|
||||
sed -i 's/"AllowInternetaccess": false,/"AllowInternetaccess": true,/g' "$LUCKYCONF"
|
||||
else
|
||||
sed -i 's/"AllowInternetaccess": true,/"AllowInternetaccess": false,/g' "$LUCKYCONF"
|
||||
fi
|
||||
# set_firewall
|
||||
[ ! -d $configdir ] && mkdir -p $configdir 2>/dev/null
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command -c "$LUCKYCONF" -p $port
|
||||
get_tz
|
||||
[[ -z "$SET_TZ" ]] || procd_set_param env TZ="$SET_TZ"
|
||||
procd_set_param command $PROG -cd "$configdir"
|
||||
[ "x$logger" == x1 ] && procd_set_param stderr 1
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
lucky_prepare
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONF"
|
||||
procd_add_reload_trigger lucky
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
{
|
||||
"BaseConfigure": {
|
||||
"AdminWebListenPort": 16601,
|
||||
"AdminWebListenTLS": false,
|
||||
"AdminWebListenHttpsPort": 16626,
|
||||
"AdminAccount": "666",
|
||||
"AdminPassword": "666",
|
||||
"AllowInternetaccess": false,
|
||||
"LogMaxSize": 2048,
|
||||
"HttpClientTimeout": 20,
|
||||
"InsecureSkipVerify": false,
|
||||
"DisableModules": null,
|
||||
"SafeURL": ""
|
||||
},
|
||||
"WhiteListConfigure": {
|
||||
"BaseConfigure": {
|
||||
"URL": "",
|
||||
"ActivelifeDuration": 36,
|
||||
"BasicAccount": "666",
|
||||
"BasicPassword": "666"
|
||||
},
|
||||
"WhiteList": null
|
||||
},
|
||||
"BlackListConfigure": {
|
||||
"BlackList": null
|
||||
},
|
||||
"DDNSConfigure": {
|
||||
"Enable": false,
|
||||
"FirstCheckDelay": 0,
|
||||
"Intervals": 0
|
||||
},
|
||||
"DDNSTaskList": null,
|
||||
"ReverseProxyRuleList": null,
|
||||
"SSLCertficateList": null,
|
||||
"PortForwardsRuleList": null,
|
||||
"PortForwardsConfigure": {
|
||||
"PortForwardsLimit": 128,
|
||||
"TCPPortforwardMaxConnections": 1024,
|
||||
"UDPReadTargetDataMaxgoroutineCount": 1024
|
||||
},
|
||||
"WOLDeviceList": null,
|
||||
"WOLServiceConfigure": {
|
||||
"Server": {
|
||||
"Enable": false,
|
||||
"Token": "666666"
|
||||
},
|
||||
"Client": {
|
||||
"Enable": false,
|
||||
"ServerURL": "",
|
||||
"Token": "",
|
||||
"Relay": false,
|
||||
"Key": "",
|
||||
"DeviceName": "",
|
||||
"Mac": "",
|
||||
"BroadcastIP": "",
|
||||
"Port": 9,
|
||||
"Repeat": 5,
|
||||
"PowerOffCMD": "",
|
||||
"UpdateTime": 0
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,6 @@ uci -q batch <<-EOF >/dev/null
|
||||
set ucitrack.@lucky[-1].init=lucky
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
[[ -f /etc/config/lucky ]] || echo "config lucky 'lucky' " > /etc/config/lucky
|
||||
rm -rf /tmp/luci*
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user