From 957f3dbb5449475f330d863171134b56e37da4ad Mon Sep 17 00:00:00 2001
From: fgsfds <4870330+fgsfds@users.noreply.github.com>
Date: Mon, 4 Aug 2025 21:47:48 +0500
Subject: Added xray access log viewer (#3309)
* added xray access log viewer
* made modal window width adaptive
* hide logs button if xray logs are disabled
---
web/html/index.html | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 112 insertions(+), 2 deletions(-)
(limited to 'web/html/index.html')
diff --git a/web/html/index.html b/web/html/index.html
index db678cd6..4089e6a6 100644
--- a/web/html/index.html
+++ b/web/html/index.html
@@ -167,7 +167,10 @@
{{ i18n "pages.index.xrayErrorPopoverTitle" }}
-
+
+
+
+
@@ -179,6 +182,10 @@
+
+
+ {{ i18n "pages.index.logs" }}
+
{{ i18n "pages.index.stopXray" }}
@@ -422,6 +429,40 @@
+ xraylogModal.visible = false"
+ :class="themeSwitcher.currentTheme"
+ width="80vw"
+ footer="">
+
+ {{ i18n "pages.index.logs" }}
+
+
+
+
+
+
+
+ 10
+ 20
+ 50
+ 100
+ 500
+
+
+
+
+
+
+
+
+
0 ? this.formatLogs(this.logs) : "No Record...";
+ },
+ formatLogs(logs) {
+ let formattedLogs = '';
+
+ logs.forEach((log, index) => {
+ if(index > 0) formattedLogs += '
';
+
+ const parts = log.split(' ');
+
+ if(parts.length === 9) {
+ const dateTime = `${parts[0]} ${parts[1]}`;
+ const from = `${parts[3]}`;
+ const to = `${parts[5].replace(/^\/+/, "")}`;
+
+ let outboundColor = '';
+ if (parts[8].startsWith('blocked')) {
+ outboundColor = ' style="color: #e04141;"';
+ }
+ else if (!parts[8].startsWith('direct')) {
+ outboundColor = ' style="color: #3c89e8;"';
+ }
+
+ formattedLogs += `
+${dateTime}
+ ${parts[2]}
+ ${from}
+ ${parts[4]}
+ ${to}
+ ${parts.slice(6).join(' ')}
+`;
+ } else {
+ formattedLogs += `${parts.join(' ')}`;
+ }
+ });
+
+ return formattedLogs;
+ },
+ hide() {
+ this.visible = false;
+ },
+ };
+
const backupModal = {
visible: false,
show() {
@@ -629,10 +721,12 @@
status: new Status(),
versionModal,
logModal,
+ xraylogModal,
backupModal,
loadingTip: '{{ i18n "loading"}}',
showAlert: false,
- showIp: false
+ showIp: false,
+ ipLimitEnable: false,
},
methods: {
loading(spinning, tip = '{{ i18n "loading"}}') {
@@ -721,6 +815,16 @@
await PromiseUtil.sleep(500);
logModal.loading = false;
},
+ async openXrayLogs(){
+ xraylogModal.loading = true;
+ const msg = await HttpUtil.post('server/xraylogs/'+xraylogModal.rows);
+ if (!msg.success) {
+ return;
+ }
+ xraylogModal.show(msg.obj);
+ await PromiseUtil.sleep(500);
+ xraylogModal.loading = false;
+ },
async openConfig() {
this.loading(true);
const msg = await HttpUtil.post('server/getConfigJson');
@@ -773,6 +877,12 @@
if (window.location.protocol !== "https:") {
this.showAlert = true;
}
+
+ const msg = await HttpUtil.post('/panel/setting/defaultSettings');
+ if (msg.success) {
+ this.ipLimitEnable = msg.obj.ipLimitEnable;
+ }
+
while (true) {
try {
await this.getStatus();
--
cgit v1.2.3