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/settings/xray/basics.html | 163 +++++++++++++++++++++++-----------
web/html/settings/xray/outbounds.html | 77 +++++++++++++---
web/html/xray.html | 156 ++++++++++++++++++++++++++------
3 files changed, 304 insertions(+), 92 deletions(-)
(limited to 'web/html')
diff --git a/web/html/settings/xray/basics.html b/web/html/settings/xray/basics.html
index 71aa0d7c..9a31038a 100644
--- a/web/html/settings/xray/basics.html
+++ b/web/html/settings/xray/basics.html
@@ -4,18 +4,22 @@
-
+
{{ i18n "pages.xray.generalConfigsDesc" }}
{{ i18n "pages.xray.FreedomStrategy" }}
- {{ i18n "pages.xray.FreedomStrategyDesc" }}
+ {{ i18n "pages.xray.FreedomStrategyDesc"
+ }}
-
-
+
[[ s ]]
@@ -23,42 +27,63 @@
{{ i18n "pages.xray.RoutingStrategy" }}
- {{ i18n "pages.xray.RoutingStrategyDesc" }}
+ {{ i18n "pages.xray.RoutingStrategyDesc"
+ }}
-
-
+
[[ s ]]
+
+ {{ i18n "pages.xray.outboundTestUrl" }}
+ {{ i18n "pages.xray.outboundTestUrlDesc"
+ }}
+
+
+
+
- {{ i18n "pages.xray.statsInboundUplink" }}
- {{ i18n "pages.xray.statsInboundUplinkDesc" }}
+ {{ i18n "pages.xray.statsInboundUplink"
+ }}
+ {{ i18n "pages.xray.statsInboundUplinkDesc"
+ }}
- {{ i18n "pages.xray.statsInboundDownlink" }}
- {{ i18n "pages.xray.statsInboundDownlinkDesc" }}
+ {{ i18n "pages.xray.statsInboundDownlink"
+ }}
+ {{ i18n "pages.xray.statsInboundDownlinkDesc"
+ }}
- {{ i18n "pages.xray.statsOutboundUplink" }}
- {{ i18n "pages.xray.statsOutboundUplinkDesc" }}
+ {{ i18n "pages.xray.statsOutboundUplink"
+ }}
+ {{ i18n "pages.xray.statsOutboundUplinkDesc"
+ }}
- {{ i18n "pages.xray.statsOutboundDownlink" }}
- {{ i18n "pages.xray.statsOutboundDownlinkDesc" }}
+ {{ i18n "pages.xray.statsOutboundDownlink"
+ }}
+ {{ i18n
+ "pages.xray.statsOutboundDownlinkDesc" }}
@@ -68,16 +93,20 @@
-
+
{{ i18n "pages.xray.logConfigsDesc" }}
{{ i18n "pages.xray.logLevel" }}
- {{ i18n "pages.xray.logLevelDesc" }}
+ {{ i18n "pages.xray.logLevelDesc"
+ }}
-
+
[[ s ]]
@@ -86,10 +115,13 @@
{{ i18n "pages.xray.accessLog" }}
- {{ i18n "pages.xray.accessLogDesc" }}
+ {{ i18n "pages.xray.accessLogDesc"
+ }}
-
-
+
+
Empty
@@ -100,10 +132,13 @@
{{ i18n "pages.xray.errorLog" }}
- {{ i18n "pages.xray.errorLogDesc" }}
+ {{ i18n "pages.xray.errorLogDesc"
+ }}
-
-
+
+
Empty
@@ -114,11 +149,13 @@
{{ i18n "pages.xray.maskAddress" }}
- {{ i18n "pages.xray.maskAddressDesc" }}
+ {{ i18n "pages.xray.maskAddressDesc"
+ }}
-
-
+
Empty
@@ -139,7 +176,8 @@
-
+
{{ i18n "pages.xray.blockConfigsDesc" }}
@@ -153,17 +191,21 @@
-
- {{ i18n "pages.xray.blockConnectionsConfigsDesc" }}
+
+ {{ i18n "pages.xray.blockConnectionsConfigsDesc"
+ }}
{{ i18n "pages.xray.blockips" }}
-
-
+
[[ p.label ]]
@@ -172,28 +214,35 @@
{{ i18n "pages.xray.blockdomains" }}
-
-
+
[[ p.label ]]
-
+
-
- {{ i18n "pages.xray.directConnectionsConfigsDesc" }}
+
+ {{ i18n "pages.xray.directConnectionsConfigsDesc"
+ }}
{{ i18n "pages.xray.directips" }}
-
-
+
[[ p.label ]]
@@ -202,18 +251,22 @@
{{ i18n "pages.xray.directdomains" }}
-
-
+
[[ p.label ]]
-
+
-
+
{{ i18n "pages.xray.ipv4RoutingDesc" }}
@@ -221,18 +274,22 @@
{{ i18n "pages.xray.ipv4Routing" }}
-
-
+
[[ p.label ]]
-
+
-
+
{{ i18n "pages.xray.warpRoutingDesc" }}
@@ -241,20 +298,24 @@
{{ i18n "pages.xray.warpRouting" }}
-
-
+
[[ p.label ]]
- WARP
+ WARP
-
+
{{ i18n "pages.settings.resetDefaultConfig" }}
diff --git a/web/html/settings/xray/outbounds.html b/web/html/settings/xray/outbounds.html
index 1c099308..3995760f 100644
--- a/web/html/settings/xray/outbounds.html
+++ b/web/html/settings/xray/outbounds.html
@@ -4,17 +4,22 @@
- {{ i18n "pages.xray.outbound.addOutbound" }}
+ {{ i18n
+ "pages.xray.outbound.addOutbound" }}
- WARP
+ WARP
-
-
+
@@ -23,8 +28,10 @@
-
[[ index+1 ]]
@@ -32,7 +39,8 @@
e.preventDefault()" type="more"
:style="{ fontSize: '16px', textDecoration: 'bold' }">
-
+
{{ i18n "pages.xray.rules.first"}}
@@ -56,21 +64,64 @@
- [[ addr ]]
+ [[ addr ]]
- [[ outbound.protocol ]]
+ [[ outbound.protocol
+ ]]
- [[ outbound.streamSettings.network ]]
- tls
- [[
+ outbound.streamSettings.network ]]
+ tls
+ reality
[[ findOutboundTraffic(outbound) ]]
+
+
+ {{ i18n "pages.xray.outbound.test"
+ }}
+
+
+
+
+
+
+
+ [[ outboundTestStates[index].result.delay ]]ms
+
+ ([[ outboundTestStates[index].result.statusCode
+ ]])
+
+
+
+ Failed
+
+
+
+
+
+
+ -
+
{{end}}
\ No newline at end of file
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