mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-07 15:20:14 +08:00
update 2025-08-06 00:27:44
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
# Copyright (C) 2020 Openwrt.org
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# This is a free software, use it under GNU General Public License v3.0.
|
||||
#
|
||||
# Created By ImmortalWrt
|
||||
# https://github.com/project-openwrt
|
||||
# Copyright (C) 2025 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-gost
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
LUCI_TITLE:=LuCI support for Gost
|
||||
LUCI_TITLE:=LuCI support for GOST
|
||||
LUCI_DEPENDS:=+gost
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_MAINTAINER:=ImmortalWrt
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
86
luci-app-gost/htdocs/luci-static/resources/view/gost.js
Normal file
86
luci-app-gost/htdocs/luci-static/resources/view/gost.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
* Copyright (C) 2025 ImmortalWrt.org
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
'require form';
|
||||
'require poll';
|
||||
'require rpc';
|
||||
'require uci';
|
||||
'require view';
|
||||
|
||||
var callServiceList = rpc.declare({
|
||||
object: 'service',
|
||||
method: 'list',
|
||||
params: ['name'],
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
function getServiceStatus() {
|
||||
return L.resolveDefault(callServiceList('gost'), {}).then(function (res) {
|
||||
let isRunning = false;
|
||||
try {
|
||||
isRunning = res['gost']['instances']['instance1']['running'];
|
||||
} catch (e) { }
|
||||
return isRunning;
|
||||
});
|
||||
}
|
||||
|
||||
function renderStatus(isRunning) {
|
||||
let spanTemp = '<em><span style="color:%s"><strong>%s %s</strong></span></em>';
|
||||
let renderHTML;
|
||||
if (isRunning)
|
||||
renderHTML = spanTemp.format('green', _('GOST'), _('RUNNING'));
|
||||
else
|
||||
renderHTML = spanTemp.format('red', _('GOST'), _('NOT RUNNING'));
|
||||
|
||||
return renderHTML;
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
render: function() {
|
||||
var m, s, o;
|
||||
|
||||
m = new form.Map('gost', _('GOST'),
|
||||
_('A simple security tunnel written in Golang.'));
|
||||
|
||||
s = m.section(form.TypedSection);
|
||||
s.anonymous = true;
|
||||
s.render = function () {
|
||||
poll.add(function () {
|
||||
return L.resolveDefault(getServiceStatus()).then(function (res) {
|
||||
let view = document.getElementById('service_status');
|
||||
view.innerHTML = renderStatus(res);
|
||||
});
|
||||
});
|
||||
|
||||
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
|
||||
E('p', { id: 'service_status' }, _('Collecting data…'))
|
||||
]);
|
||||
}
|
||||
|
||||
s = m.section(form.NamedSection, 'config', 'gost');
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enable'));
|
||||
|
||||
o = s.option(form.Value, 'config_file', _('Configuration file'));
|
||||
o.value('/etc/gost/gost.json');
|
||||
o.datatype = 'path';
|
||||
|
||||
o = s.option(form.DynamicList, 'arguments', _('Arguments'));
|
||||
o.validate = function(section_id) {
|
||||
if (section_id) {
|
||||
let config_file = this.section.formvalue(section_id, 'config_file');
|
||||
let value = this.section.formvalue(section_id, 'arguments');
|
||||
|
||||
if (!config_file && !value?.length)
|
||||
return _('Expecting: %s').format(_('non-empty value'));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
-- This is a free software, use it under GNU General Public License v3.0.
|
||||
-- Created By ImmortalWrt
|
||||
-- https://github.com/immortalwrt
|
||||
|
||||
module("luci.controller.gost", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/gost") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
page = entry({"admin", "services", "gost"}, cbi("gost"), _("Gost"), 100)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-gost" }
|
||||
entry({"admin", "services", "gost", "status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("pgrep gost >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
-- Created By ImmortalWrt
|
||||
-- https://github.com/immortalwrt
|
||||
|
||||
mp = Map("gost", translate("Gost"))
|
||||
mp.description = translate("A simple security tunnel written in Golang.")
|
||||
|
||||
mp:section(SimpleSection).template = "gost/gost_status"
|
||||
|
||||
s = mp:section(TypedSection, "gost")
|
||||
s.anonymous=true
|
||||
s.addremove=false
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.default = 0
|
||||
enable.rmempty = false
|
||||
|
||||
run_command = s:option(Value, "run_command", translate("Command"))
|
||||
run_command.rmempty = false
|
||||
|
||||
return mp
|
||||
@@ -1,22 +0,0 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[gost]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('gost_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>Gost <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>Gost <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="gost_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
49
luci-app-gost/po/templates/gost.pot
Normal file
49
luci-app-gost/po/templates/gost.pot
Normal file
@@ -0,0 +1,49 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:46
|
||||
msgid "A simple security tunnel written in Golang."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:71
|
||||
msgid "Arguments"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:59
|
||||
msgid "Collecting data…"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:67
|
||||
msgid "Configuration file"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:65
|
||||
msgid "Enable"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:78
|
||||
msgid "Expecting: %s"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:34
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:36
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:45
|
||||
#: applications/luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json:3
|
||||
msgid "GOST"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/root/usr/share/rpcd/acl.d/luci-app-gost.json:3
|
||||
msgid "Grant UCI access for luci-app-gost"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:36
|
||||
msgid "NOT RUNNING"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:34
|
||||
msgid "RUNNING"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:78
|
||||
msgid "non-empty value"
|
||||
msgstr ""
|
||||
@@ -1,17 +1,56 @@
|
||||
msgid "Gost"
|
||||
msgstr "Gost"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh-Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:46
|
||||
msgid "A simple security tunnel written in Golang."
|
||||
msgstr "GO语言实现的安全隧道。"
|
||||
msgstr "GO 语言实现的安全隧道。"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:71
|
||||
msgid "Arguments"
|
||||
msgstr "参数"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:59
|
||||
msgid "Collecting data…"
|
||||
msgstr "正在收集数据中…"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:67
|
||||
msgid "Configuration file"
|
||||
msgstr "配置文件"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:65
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Command"
|
||||
msgstr "命令"
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:78
|
||||
msgid "Expecting: %s"
|
||||
msgstr "请输入:%s"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:34
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:36
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:45
|
||||
#: applications/luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json:3
|
||||
msgid "GOST"
|
||||
msgstr "GOST"
|
||||
|
||||
#: applications/luci-app-gost/root/usr/share/rpcd/acl.d/luci-app-gost.json:3
|
||||
msgid "Grant UCI access for luci-app-gost"
|
||||
msgstr "授予 luci-app-gost 访问 UCI 配置的权限"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:36
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:34
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
#: applications/luci-app-gost/htdocs/luci-static/resources/view/gost.js:78
|
||||
msgid "non-empty value"
|
||||
msgstr "非空值"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@gost[-1]
|
||||
add ucitrack gost
|
||||
set ucitrack.@gost[-1].init=gost
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
13
luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json
Normal file
13
luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"admin/services/gost": {
|
||||
"title": "GOST",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "gost"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-gost" ],
|
||||
"uci": { "gost": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user