From 4779939424eb047d30161631fd89a9876104084c Mon Sep 17 00:00:00 2001
From: surbiks <43953720+surbiks@users.noreply.github.com>
Date: Tue, 10 Feb 2026 00:13:17 +0330
Subject: Add url speed test for outbound (#3767)
* add outbound testing functionality with configurable test URL
* use no kernel tun for conflict errors
---
web/html/xray.html | 156 +++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 128 insertions(+), 28 deletions(-)
(limited to 'web/html/xray.html')
diff --git a/web/html/xray.html b/web/html/xray.html
index 186156ff..a350ee57 100644
--- a/web/html/xray.html
+++ b/web/html/xray.html
@@ -1,7 +1,10 @@
{{ template "page/head_start" .}}
-
-
-
+
+
+
{{ template "page/head_end" .}}
@@ -10,10 +13,13 @@
-
+
-
+
@@ -26,19 +32,25 @@
-
+
-
+
{{ i18n "pages.xray.save" }}
-
+
{{ i18n "pages.xray.restart" }}
-
- {{ i18n "pages.index.xrayErrorPopoverTitle" }}
+
+ {{ i18n
+ "pages.index.xrayErrorPopoverTitle" }}
- [[ line
+ [[ line
]]
@@ -48,10 +60,13 @@
@@ -60,7 +75,8 @@
- { this.changePage(activeKey); }"
+ { this.changePage(activeKey); }"
:class="themeSwitcher.currentTheme">
@@ -83,21 +99,24 @@
{{ template "settings/xray/outbounds" . }}
-
+
{{ i18n "pages.xray.outbound.reverse"}}
{{ template "settings/xray/reverse" . }}
-
+
{{ i18n "pages.xray.Balancers"}}
{{ template "settings/xray/balancers" . }}
-
+
DNS
@@ -120,14 +139,18 @@
{{template "page/body_scripts" .}}
-
-
+
+
-
-
+
+
@@ -181,11 +204,13 @@
];
const outboundColumns = [
- { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
+ { title: "#", align: 'center', width: 60, scopedSlots: { customRender: 'action' } },
{ title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
{ title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
{ title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
{ title: '{{ i18n "pages.inbounds.traffic" }}', align: 'center', width: 50, scopedSlots: { customRender: 'traffic' } },
+ { title: '{{ i18n "pages.xray.outbound.testResult" }}', align: 'center', width: 120, scopedSlots: { customRender: 'testResult' } },
+ { title: '{{ i18n "pages.xray.outbound.test" }}', align: 'center', width: 60, scopedSlots: { customRender: 'test' } },
];
const reverseColumns = [
@@ -228,8 +253,11 @@
},
oldXraySetting: '',
xraySetting: '',
+ outboundTestUrl: 'https://www.google.com/generate_204',
+ oldOutboundTestUrl: 'https://www.google.com/generate_204',
inboundTags: [],
outboundsTraffic: [],
+ outboundTestStates: {}, // Track testing state and results for each outbound
saveBtnDisable: true,
refreshing: false,
restartResult: '',
@@ -337,14 +365,14 @@
},
defaultObservatory: {
subjectSelector: [],
- probeURL: "http://www.google.com/gen_204",
+ probeURL: "https://www.google.com/generate_204",
probeInterval: "10m",
enableConcurrency: true
},
defaultBurstObservatory: {
subjectSelector: [],
pingConfig: {
- destination: "http://www.google.com/gen_204",
+ destination: "https://www.google.com/generate_204",
interval: "30m",
connectivity: "http://connectivitycheck.platform.hicloud.com/generate_204",
timeout: "10s",
@@ -375,12 +403,17 @@
this.oldXraySetting = xs;
this.xraySetting = xs;
this.inboundTags = result.inboundTags;
+ this.outboundTestUrl = result.outboundTestUrl || 'https://www.google.com/generate_204';
+ this.oldOutboundTestUrl = this.outboundTestUrl;
this.saveBtnDisable = true;
}
},
async updateXraySetting() {
this.loading(true);
- const msg = await HttpUtil.post("/panel/xray/update", { xraySetting: this.xraySetting });
+ const msg = await HttpUtil.post("/panel/xray/update", {
+ xraySetting: this.xraySetting,
+ outboundTestUrl: this.outboundTestUrl || 'https://www.google.com/generate_204'
+ });
this.loading(false);
if (msg.success) {
await this.getXraySetting();
@@ -595,6 +628,73 @@
outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
this.outboundSettings = JSON.stringify(outbounds);
},
+ async testOutbound(index) {
+ const outbound = this.templateSettings.outbounds[index];
+ if (!outbound) {
+ Vue.prototype.$message.error('{{ i18n "pages.xray.outbound.testError" }}');
+ return;
+ }
+
+ if (outbound.protocol === 'blackhole' || outbound.tag === 'blocked') {
+ Vue.prototype.$message.warning('{{ i18n "pages.xray.outbound.testError" }}: blocked/blackhole outbound');
+ return;
+ }
+
+ // Initialize test state for this outbound if not exists
+ if (!this.outboundTestStates[index]) {
+ this.$set(this.outboundTestStates, index, {
+ testing: false,
+ result: null
+ });
+ }
+
+ // Set testing state
+ this.$set(this.outboundTestStates[index], 'testing', true);
+ this.$set(this.outboundTestStates[index], 'result', null);
+
+ try {
+ const outboundJSON = JSON.stringify(outbound);
+ const testURL = this.outboundTestUrl || 'https://www.google.com/generate_204';
+ const allOutboundsJSON = JSON.stringify(this.templateSettings.outbounds || []);
+
+ const msg = await HttpUtil.post("/panel/xray/testOutbound", {
+ outbound: outboundJSON,
+ testURL: testURL,
+ allOutbounds: allOutboundsJSON
+ });
+
+ // Update test state
+ this.$set(this.outboundTestStates[index], 'testing', false);
+
+ if (msg.success && msg.obj) {
+ const result = msg.obj;
+ this.$set(this.outboundTestStates[index], 'result', result);
+
+ if (result.success) {
+ Vue.prototype.$message.success(
+ `{{ i18n "pages.xray.outbound.testSuccess" }}: ${result.delay}ms (${result.statusCode})`
+ );
+ } else {
+ Vue.prototype.$message.error(
+ `{{ i18n "pages.xray.outbound.testFailed" }}: ${result.error || 'Unknown error'}`
+ );
+ }
+ } else {
+ this.$set(this.outboundTestStates[index], 'result', {
+ success: false,
+ error: msg.msg || '{{ i18n "pages.xray.outbound.testError" }}'
+ });
+ Vue.prototype.$message.error(msg.msg || '{{ i18n "pages.xray.outbound.testError" }}');
+ }
+ } catch (error) {
+ this.$set(this.outboundTestStates[index], 'testing', false);
+ this.$set(this.outboundTestStates[index], 'result', {
+ success: false,
+ error: error.message || '{{ i18n "pages.xray.outbound.testError" }}'
+ });
+ Vue.prototype.$message.error('{{ i18n "pages.xray.outbound.testError" }}: ' + error.message);
+ }
+ },
addReverse() {
reverseModal.show({
title: '{{ i18n "pages.xray.outbound.addReverse"}}',
@@ -981,7 +1081,7 @@
while (true) {
await PromiseUtil.sleep(800);
- this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
+ this.saveBtnDisable = this.oldXraySetting === this.xraySetting && this.oldOutboundTestUrl === this.outboundTestUrl;
}
},
computed: {
--
cgit v1.2.3