new feature: log & bump version

fix #2
This commit is contained in:
asvow
2024-05-30 22:38:15 +08:00
parent f97a9ed158
commit 1f3bc92cc7
7 changed files with 135 additions and 13 deletions

View File

@@ -8,7 +8,7 @@ LUCI_TITLE:=LuCI for Tailscale
LUCI_DEPENDS:=+tailscale +jsonfilter +ucode
LUCI_PKGARCH:=all
PKG_VERSION:=1.0.5
PKG_VERSION:=1.0.6
include $(TOPDIR)/feeds/luci/luci.mk

View File

@@ -0,0 +1,77 @@
/* SPDX-License-Identifier: GPL-3.0-only
*
* Copyright (C) 2024 asvow
*/
'use strict';
'require fs';
'require poll';
'require ui';
'require view';
return view.extend({
logs: [],
reverseLogs: false,
load: function () {
var self = this;
/* Thanks to @animegasan */
poll.add(function() {
return fs.exec('/sbin/logread', ['-e', 'tailscale'])
.then(function (res) {
if (res.code === 0) {
var statusMappings = {
'daemon.err': { status: 'StdErr', startIndex: 9 },
'daemon.notice': { status: 'Info', startIndex: 10 }
};
self.logs = res.stdout.split('\n').map(function(log) {
var logParts = log.split(' ');
if (logParts.length >= 6) {
var formattedTime = logParts[1] + ' ' + logParts[2] + ' - ' + logParts[3];
var status = logParts[5];
var mapping = statusMappings[status] || { status: status, startIndex: 9 };
status = mapping.status;
var startIndex = mapping.startIndex;
var message = logParts.slice(startIndex).join(' ');
return formattedTime + ' [ ' + status + ' ] - ' + message;
} else {
return '';
}
}).filter(Boolean);
self.updateLogView();
} else {
throw new Error(res.stdout + ' ' + res.stderr);
}
})
});
},
updateLogView: function() {
var view = document.getElementById('syslog');
var logs = this.logs;
if (logs.length === 0) {
view.textContent = _('No logs available');
return;
}
if (this.reverseLogs) {
logs = logs.slice().reverse();
}
view.textContent = logs.join('\n');
},
render: function () {
var self = this;
var button = E('button', {
'class': 'cbi-button cbi-button-neutral',
click: function() {
self.reverseLogs = !self.reverseLogs;
self.updateLogView();
}
}, _('Toggle Log Order'));
var logArea = E('div', { 'id': 'syslog', 'style': 'white-space: pre;' });
return E('div', {}, [ button, logArea ]);
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});

View File

@@ -1,10 +1,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:167
msgid "Use site-to-site layer 3 networking to connect two subnets on your Tailscale network with each other."
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:159
msgid "Accept DNS"
msgstr ""
@@ -126,6 +122,10 @@ msgstr ""
msgid "Logout and Unbind"
msgstr ""
#: luci-app-tailscale/root/usr/share/luci/menu.d/luci-app-tailscale.json:30
msgid "Logs"
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/interface.js:94
msgid "MTU"
msgstr ""
@@ -147,6 +147,10 @@ msgstr ""
msgid "No interface online."
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/log.js:52
msgid "No logs available"
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:163
msgid "Offer to be an exit node for outbound internet traffic from the Tailscale network."
msgstr ""
@@ -200,6 +204,10 @@ msgstr ""
msgid "The working directory contains config files, audit logs, and runtime info."
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/log.js:69
msgid "Toggle Log Order"
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/interface.js:98
msgid "Total Download"
msgstr ""
@@ -220,6 +228,10 @@ msgstr ""
msgid "Use %s to deploy a private server."
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:167
msgid "Use site-to-site layer 3 networking to connect two subnets on your Tailscale network with each other."
msgstr ""
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:181
msgid "WAN access Tailscale"
msgstr ""

View File

@@ -7,10 +7,6 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:167
msgid "Use site-to-site layer 3 networking to connect two subnets on your Tailscale network with each other."
msgstr "使用站点到站点的三层网络连接 Tailscale 中的两个子网。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:159
msgid "Accept DNS"
msgstr "允许DNS"
@@ -132,6 +128,10 @@ msgstr "已绑定用户"
msgid "Logout and Unbind"
msgstr "注销登录并解除绑定"
#: luci-app-tailscale/root/usr/share/luci/menu.d/luci-app-tailscale.json:30
msgid "Logs"
msgstr "日志"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/interface.js:94
msgid "MTU"
msgstr "MTU"
@@ -153,6 +153,10 @@ msgstr "网络接口信息"
msgid "No interface online."
msgstr "无在线接口。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/log.js:52
msgid "No logs available"
msgstr "日志不存在"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:163
msgid "Offer to be an exit node for outbound internet traffic from the Tailscale network."
msgstr "作为 Tailscale 广域网出口节点。"
@@ -206,6 +210,10 @@ msgstr "Tailscale 是一个跨平台且易于使用的虚拟局域网 VPN。"
msgid "The working directory contains config files, audit logs, and runtime info."
msgstr "工作目录包含配置文件、审计日志和运行时信息。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/log.js:69
msgid "Toggle Log Order"
msgstr "切换日志排序"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/interface.js:98
msgid "Total Download"
msgstr "总下载量"
@@ -226,6 +234,10 @@ msgstr "无法获取接口信息:%s。"
msgid "Use %s to deploy a private server."
msgstr "使用 %s 部署私有服务器"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:167
msgid "Use site-to-site layer 3 networking to connect two subnets on your Tailscale network with each other."
msgstr "使用站点到站点的三层网络连接 Tailscale 中的两个子网。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:181
msgid "WAN access Tailscale"
msgstr "本地广域网访问虚拟局域网"

View File

@@ -7,10 +7,6 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:167
msgid "Use site-to-site layer 3 networking to connect two subnets on your Tailscale network with each other."
msgstr "使用站點到站點的三層網路連線 Tailscale 中的兩個子網。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:159
msgid "Accept DNS"
msgstr "允許DNS"
@@ -132,6 +128,10 @@ msgstr "已綁定用戶"
msgid "Logout and Unbind"
msgstr "註銷登錄並解除綁定"
#: luci-app-tailscale/root/usr/share/luci/menu.d/luci-app-tailscale.json:30
msgid "Logs"
msgstr "日誌"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/interface.js:94
msgid "MTU"
msgstr "MTU"
@@ -153,6 +153,10 @@ msgstr "網絡接口信息"
msgid "No interface online."
msgstr "無在線接口。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/log.js:52
msgid "No logs available"
msgstr "日誌不存在"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:163
msgid "Offer to be an exit node for outbound internet traffic from the Tailscale network."
msgstr "作為 Tailscale 廣域網出口節點。"
@@ -206,6 +210,10 @@ msgstr "Tailscale 是一個跨平臺且易於使用的虛擬局域網 VPN。"
msgid "The working directory contains config files, audit logs, and runtime info."
msgstr "工作目錄包含配置文件、審計日誌和運行時信息。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/log.js:69
msgid "Toggle Log Order"
msgstr "切換日誌排序"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/interface.js:98
msgid "Total Download"
msgstr "總下載量"
@@ -226,6 +234,10 @@ msgstr "無法獲取接口信息:%s。"
msgid "Use %s to deploy a private server."
msgstr "使用 %s 部署私有服務器"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:167
msgid "Use site-to-site layer 3 networking to connect two subnets on your Tailscale network with each other."
msgstr "使用站點到站點的三層網路連線 Tailscale 中的兩個子網。"
#: luci-app-tailscale/htdocs/luci-static/resources/view/tailscale/setting.js:181
msgid "WAN access Tailscale"
msgstr "本地廣域網訪問虛擬局域網"

View File

@@ -25,5 +25,13 @@
"type": "view",
"path": "tailscale/interface"
}
},
"admin/services/tailscale/log": {
"title": "Logs",
"order": 30,
"action": {
"type": "view",
"path": "tailscale/log"
}
}
}

View File

@@ -4,6 +4,7 @@
"read": {
"file": {
"/sbin/ifconfig": [ "exec" ],
"/sbin/logread": [ "exec" ],
"/usr/sbin/tailscale": [ "exec" ]
},
"ubus": {