diff --git a/luci-app-gost/Makefile b/luci-app-gost/Makefile index 2c674d816..cb5d6fffd 100644 --- a/luci-app-gost/Makefile +++ b/luci-app-gost/Makefile @@ -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 diff --git a/luci-app-gost/htdocs/luci-static/resources/view/gost.js b/luci-app-gost/htdocs/luci-static/resources/view/gost.js new file mode 100644 index 000000000..98a24c69e --- /dev/null +++ b/luci-app-gost/htdocs/luci-static/resources/view/gost.js @@ -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 = '%s %s'; + 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(); + } +}); diff --git a/luci-app-gost/luasrc/controller/gost.lua b/luci-app-gost/luasrc/controller/gost.lua deleted file mode 100644 index 37f8af1f1..000000000 --- a/luci-app-gost/luasrc/controller/gost.lua +++ /dev/null @@ -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 diff --git a/luci-app-gost/luasrc/model/cbi/gost.lua b/luci-app-gost/luasrc/model/cbi/gost.lua deleted file mode 100644 index 116bd0dc9..000000000 --- a/luci-app-gost/luasrc/model/cbi/gost.lua +++ /dev/null @@ -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 diff --git a/luci-app-gost/luasrc/view/gost/gost_status.htm b/luci-app-gost/luasrc/view/gost/gost_status.htm deleted file mode 100644 index 3f279c9ef..000000000 --- a/luci-app-gost/luasrc/view/gost/gost_status.htm +++ /dev/null @@ -1,22 +0,0 @@ - - -
-

- <%:Collecting data...%> -

-
diff --git a/luci-app-gost/po/templates/gost.pot b/luci-app-gost/po/templates/gost.pot new file mode 100644 index 000000000..bded96350 --- /dev/null +++ b/luci-app-gost/po/templates/gost.pot @@ -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 "" diff --git a/luci-app-gost/po/zh_Hans/gost.po b/luci-app-gost/po/zh_Hans/gost.po index 9ccabdeca..2eaaa73da 100644 --- a/luci-app-gost/po/zh_Hans/gost.po +++ b/luci-app-gost/po/zh_Hans/gost.po @@ -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 "非空值" diff --git a/luci-app-gost/root/etc/uci-defaults/gost b/luci-app-gost/root/etc/uci-defaults/gost deleted file mode 100755 index e1ddf16fa..000000000 --- a/luci-app-gost/root/etc/uci-defaults/gost +++ /dev/null @@ -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 diff --git a/luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json b/luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json new file mode 100644 index 000000000..4c5a6e722 --- /dev/null +++ b/luci-app-gost/root/usr/share/luci/menu.d/luci-app-gost.json @@ -0,0 +1,13 @@ +{ + "admin/services/gost": { + "title": "GOST", + "action": { + "type": "view", + "path": "gost" + }, + "depends": { + "acl": [ "luci-app-gost" ], + "uci": { "gost": true } + } + } +}