From 2eb8abf61e6aae94ef3cefae33c2a08595cc5fce Mon Sep 17 00:00:00 2001
From: fgsfds <4870330+fgsfds@users.noreply.github.com>
Date: Wed, 17 Sep 2025 16:19:55 +0500
Subject: Improved xray logs display handling (#3475)
* improved xray logs handling
* fix download Xray Logs
* Update index.html
---
web/html/index.html | 125 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 78 insertions(+), 47 deletions(-)
(limited to 'web/html')
diff --git a/web/html/index.html b/web/html/index.html
index 819d6df2..4ddf26b5 100644
--- a/web/html/index.html
+++ b/web/html/index.html
@@ -365,8 +365,7 @@
SysLog
-
+
@@ -401,8 +400,7 @@
Proxy
-
+
@@ -796,59 +794,74 @@
};
const xraylogModal = {
- visible: false,
- logs: [],
- rows: 20,
- showDirect: true,
- showBlocked: true,
- showProxy: true,
- loading: false,
- show(logs) {
- this.visible = true;
- this.logs = logs;
- this.formattedLogs = this.logs?.length > 0 ? this.formatLogs(this.logs) : "No Record...";
- },
- formatLogs(logs) {
- let formattedLogs = '';
-
- logs.forEach((log, index) => {
- if (index > 0) formattedLogs += '
';
+ visible: false,
+ logs: [],
+ rows: 20,
+ showDirect: true,
+ showBlocked: true,
+ showProxy: true,
+ loading: false,
+ show(logs) {
+ this.visible = true;
+ this.logs = logs;
+ this.formattedLogs = this.logs?.length > 0 ? this.formatLogs(this.logs) : "No Record...";
+ },
+ formatLogs(logs) {
+ let formattedLogs = `
+
- if (parts.length === 10) {
- const dateTime = `${parts[0]} ${parts[1]}`;
- const from = `${parts[3]}`;
- const to = `${parts[5].replace(/^\/+/, "")}`;
+
+
+ | Date |
+ From |
+ To |
+ Inbound |
+ Outbound |
+ Email |
+
+`;
+ logs.reverse().forEach((log, index) => {
let outboundColor = '';
- if (parts[9] === "b") {
+ if (log.Event === 1) {
outboundColor = ' style="color: #e04141;"'; //red for blocked
}
- else if (parts[9] === "p") {
+ else if (log.Event === 2) {
outboundColor = ' style="color: #3c89e8;"'; //blue for proxies
}
- formattedLogs += `
-${dateTime}
- ${parts[2]}
- ${from}
- ${parts[4]}
- ${to}
- ${parts.slice(6, 9).join(' ')}
-`;
- } else {
- formattedLogs += `${log}`;
- }
- });
+ let text = ``;
+ if (log.Email !== "") {
+ text = `${log.Email} | `;
+ }
- return formattedLogs;
- },
- hide() {
- this.visible = false;
- },
- };
+ formattedLogs += `
+
+ | ${new Date(log.DateTime).toLocaleString()} |
+ ${log.FromAddress} |
+ ${log.ToAddress} |
+ ${log.Inbound} |
+ ${log.Outbound} |
+ ${text}
+
+`;
+ });
+ return formattedLogs += "
";
+ },
+ hide() {
+ this.visible = false;
+ },
+ };
const backupModal = {
visible: false,
show() {
@@ -1023,6 +1036,25 @@ ${dateTime}
await PromiseUtil.sleep(500);
xraylogModal.loading = false;
},
+ downloadXrayLogs() {
+ if (!Array.isArray(this.xraylogModal.logs) || this.xraylogModal.logs.length === 0) {
+ FileManager.downloadTextFile('', 'x-ui.log');
+ return;
+ }
+ const lines = this.xraylogModal.logs.map(l => {
+ try {
+ const dt = l.DateTime ? new Date(l.DateTime) : null;
+ const dateStr = dt && !isNaN(dt.getTime()) ? dt.toISOString() : '';
+ const eventMap = { 0: 'DIRECT', 1: 'BLOCKED', 2: 'PROXY' };
+ const eventText = eventMap[l.Event] || String(l.Event ?? '');
+ const emailPart = l.Email ? ` Email=${l.Email}` : '';
+ return `${dateStr} FROM=${l.FromAddress || ''} TO=${l.ToAddress || ''} INBOUND=${l.Inbound || ''} OUTBOUND=${l.Outbound || ''}${emailPart} EVENT=${eventText}`.trim();
+ } catch (e) {
+ return JSON.stringify(l);
+ }
+ }).join('\n');
+ FileManager.downloadTextFile(lines, 'x-ui.log');
+ },
async openConfig() {
this.loading(true);
const msg = await HttpUtil.get('/panel/api/server/getConfigJson');
@@ -1071,7 +1103,6 @@ ${dateTime}
fileInput.click();
},
},
- computed: {},
async mounted() {
if (window.location.protocol !== "https:") {
this.showAlert = true;
--
cgit v1.2.3