diff options
| author | surbiks <43953720+surbiks@users.noreply.github.com> | 2026-02-09 23:43:17 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-09 23:43:17 +0300 |
| commit | 4779939424eb047d30161631fd89a9876104084c (patch) | |
| tree | 89e2682aa528281879b3afb535f2b34124a17335 | |
| parent | 4a455aa5322e0803005da2d5d65b85a19dfc42e5 (diff) | |
Add url speed test for outbound (#3767)
* add outbound testing functionality with configurable test URL
* use no kernel tun for conflict errors
| -rw-r--r-- | web/controller/xray_setting.go | 46 | ||||
| -rw-r--r-- | web/html/settings/xray/basics.html | 163 | ||||
| -rw-r--r-- | web/html/settings/xray/outbounds.html | 77 | ||||
| -rw-r--r-- | web/html/xray.html | 156 | ||||
| -rw-r--r-- | web/job/xray_traffic_job.go | 2 | ||||
| -rw-r--r-- | web/service/outbound.go | 322 | ||||
| -rw-r--r-- | web/service/setting.go | 10 | ||||
| -rw-r--r-- | web/translation/translate.ar_EG.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.en_US.toml | 8 | ||||
| -rw-r--r-- | web/translation/translate.es_ES.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.fa_IR.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.id_ID.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.ja_JP.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.pt_BR.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.ru_RU.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.tr_TR.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.uk_UA.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.vi_VN.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.zh_CN.toml | 2 | ||||
| -rw-r--r-- | web/translation/translate.zh_TW.toml | 2 | ||||
| -rw-r--r-- | web/websocket/notifier.go | 2 | ||||
| -rw-r--r-- | xray/process.go | 38 |
22 files changed, 746 insertions, 102 deletions
diff --git a/web/controller/xray_setting.go b/web/controller/xray_setting.go index b78925f0..a48726de 100644 --- a/web/controller/xray_setting.go +++ b/web/controller/xray_setting.go @@ -1,6 +1,9 @@ package controller import ( + "encoding/json" + + "github.com/mhsanaei/3x-ui/v2/util/common" "github.com/mhsanaei/3x-ui/v2/web/service" "github.com/gin-gonic/gin" @@ -34,9 +37,10 @@ func (a *XraySettingController) initRouter(g *gin.RouterGroup) { g.POST("/warp/:action", a.warp) g.POST("/update", a.updateSetting) g.POST("/resetOutboundsTraffic", a.resetOutboundsTraffic) + g.POST("/testOutbound", a.testOutbound) } -// getXraySetting retrieves the Xray configuration template and inbound tags. +// getXraySetting retrieves the Xray configuration template, inbound tags, and outbound test URL. func (a *XraySettingController) getXraySetting(c *gin.Context) { xraySetting, err := a.SettingService.GetXrayConfigTemplate() if err != nil { @@ -48,15 +52,28 @@ func (a *XraySettingController) getXraySetting(c *gin.Context) { jsonMsg(c, I18nWeb(c, "pages.settings.toasts.getSettings"), err) return } - xrayResponse := "{ \"xraySetting\": " + xraySetting + ", \"inboundTags\": " + inboundTags + " }" + outboundTestUrl, _ := a.SettingService.GetXrayOutboundTestUrl() + if outboundTestUrl == "" { + outboundTestUrl = "https://www.google.com/generate_204" + } + urlJSON, _ := json.Marshal(outboundTestUrl) + xrayResponse := "{ \"xraySetting\": " + xraySetting + ", \"inboundTags\": " + inboundTags + ", \"outboundTestUrl\": " + string(urlJSON) + " }" jsonObj(c, xrayResponse, nil) } // updateSetting updates the Xray configuration settings. func (a *XraySettingController) updateSetting(c *gin.Context) { xraySetting := c.PostForm("xraySetting") - err := a.XraySettingService.SaveXraySetting(xraySetting) - jsonMsg(c, I18nWeb(c, "pages.settings.toasts.modifySettings"), err) + if err := a.XraySettingService.SaveXraySetting(xraySetting); err != nil { + jsonMsg(c, I18nWeb(c, "pages.settings.toasts.modifySettings"), err) + return + } + outboundTestUrl := c.PostForm("outboundTestUrl") + if outboundTestUrl == "" { + outboundTestUrl = "https://www.google.com/generate_204" + } + _ = a.SettingService.SetXrayOutboundTestUrl(outboundTestUrl) + jsonMsg(c, I18nWeb(c, "pages.settings.toasts.modifySettings"), nil) } // getDefaultXrayConfig retrieves the default Xray configuration. @@ -118,3 +135,24 @@ func (a *XraySettingController) resetOutboundsTraffic(c *gin.Context) { } jsonObj(c, "", nil) } + +// testOutbound tests an outbound configuration and returns the delay/response time. +// Optional form "allOutbounds": JSON array of all outbounds; used to resolve sockopt.dialerProxy dependencies. +func (a *XraySettingController) testOutbound(c *gin.Context) { + outboundJSON := c.PostForm("outbound") + testURL := c.PostForm("testURL") + allOutboundsJSON := c.PostForm("allOutbounds") + + if outboundJSON == "" { + jsonMsg(c, I18nWeb(c, "somethingWentWrong"), common.NewError("outbound parameter is required")) + return + } + + result, err := a.OutboundService.TestOutbound(outboundJSON, testURL, allOutboundsJSON) + if err != nil { + jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err) + return + } + + jsonObj(c, result, nil) +} 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 @@ <a-row :xs="24" :sm="24" :lg="12"> <a-alert type="warning" :style="{ textAlign: 'center' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> <span>{{ i18n "pages.xray.generalConfigsDesc" }}</span> </template> </a-alert> </a-row> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.FreedomStrategy" }}</template> - <template #description>{{ i18n "pages.xray.FreedomStrategyDesc" }}</template> + <template #description>{{ i18n "pages.xray.FreedomStrategyDesc" + }}</template> <template #control> - <a-select v-model="freedomStrategy" :dropdown-class-name="themeSwitcher.currentTheme" + <a-select v-model="freedomStrategy" + :dropdown-class-name="themeSwitcher.currentTheme" :style="{ width: '100%' }"> - <a-select-option v-for="s in OutboundDomainStrategies" :value="s"> + <a-select-option v-for="s in OutboundDomainStrategies" + :value="s"> <span>[[ s ]]</span> </a-select-option> </a-select> @@ -23,42 +27,63 @@ </a-setting-list-item> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.RoutingStrategy" }}</template> - <template #description>{{ i18n "pages.xray.RoutingStrategyDesc" }}</template> + <template #description>{{ i18n "pages.xray.RoutingStrategyDesc" + }}</template> <template #control> - <a-select v-model="routingStrategy" :dropdown-class-name="themeSwitcher.currentTheme" + <a-select v-model="routingStrategy" + :dropdown-class-name="themeSwitcher.currentTheme" :style="{ width: '100%' }"> - <a-select-option v-for="s in routingDomainStrategies" :value="s"> + <a-select-option v-for="s in routingDomainStrategies" + :value="s"> <span>[[ s ]]</span> </a-select-option> </a-select> </template> </a-setting-list-item> + <a-setting-list-item paddings="small"> + <template #title>{{ i18n "pages.xray.outboundTestUrl" }}</template> + <template #description>{{ i18n "pages.xray.outboundTestUrlDesc" + }}</template> + <template #control> + <a-input v-model="outboundTestUrl" + :placeholder="'https://www.google.com/generate_204'" + :style="{ width: '100%' }"></a-input> + </template> + </a-setting-list-item> </a-collapse-panel> <a-collapse-panel key="2" header='{{ i18n "pages.xray.statistics" }}'> <a-setting-list-item paddings="small"> - <template #title>{{ i18n "pages.xray.statsInboundUplink" }}</template> - <template #description>{{ i18n "pages.xray.statsInboundUplinkDesc" }}</template> + <template #title>{{ i18n "pages.xray.statsInboundUplink" + }}</template> + <template #description>{{ i18n "pages.xray.statsInboundUplinkDesc" + }}</template> <template #control> <a-switch v-model="statsInboundUplink"></a-switch> </template> </a-setting-list-item> <a-setting-list-item paddings="small"> - <template #title>{{ i18n "pages.xray.statsInboundDownlink" }}</template> - <template #description>{{ i18n "pages.xray.statsInboundDownlinkDesc" }}</template> + <template #title>{{ i18n "pages.xray.statsInboundDownlink" + }}</template> + <template #description>{{ i18n "pages.xray.statsInboundDownlinkDesc" + }}</template> <template #control> <a-switch v-model="statsInboundDownlink"></a-switch> </template> </a-setting-list-item> <a-setting-list-item paddings="small"> - <template #title>{{ i18n "pages.xray.statsOutboundUplink" }}</template> - <template #description>{{ i18n "pages.xray.statsOutboundUplinkDesc" }}</template> + <template #title>{{ i18n "pages.xray.statsOutboundUplink" + }}</template> + <template #description>{{ i18n "pages.xray.statsOutboundUplinkDesc" + }}</template> <template #control> <a-switch v-model="statsOutboundUplink"></a-switch> </template> </a-setting-list-item> <a-setting-list-item paddings="small"> - <template #title>{{ i18n "pages.xray.statsOutboundDownlink" }}</template> - <template #description>{{ i18n "pages.xray.statsOutboundDownlinkDesc" }}</template> + <template #title>{{ i18n "pages.xray.statsOutboundDownlink" + }}</template> + <template #description>{{ i18n + "pages.xray.statsOutboundDownlinkDesc" }}</template> <template #control> <a-switch v-model="statsOutboundDownlink"></a-switch> </template> @@ -68,16 +93,20 @@ <a-row :xs="24" :sm="24" :lg="12"> <a-alert type="warning" :style="{ textAlign: 'center' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> <span>{{ i18n "pages.xray.logConfigsDesc" }}</span> </template> </a-alert> </a-row> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.logLevel" }}</template> - <template #description>{{ i18n "pages.xray.logLevelDesc" }}</template> + <template #description>{{ i18n "pages.xray.logLevelDesc" + }}</template> <template #control> - <a-select v-model="logLevel" :dropdown-class-name="themeSwitcher.currentTheme" :style="{ width: '100%' }"> + <a-select v-model="logLevel" + :dropdown-class-name="themeSwitcher.currentTheme" + :style="{ width: '100%' }"> <a-select-option v-for="s in log.loglevel" :value="s"> <span>[[ s ]]</span> </a-select-option> @@ -86,10 +115,13 @@ </a-setting-list-item> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.accessLog" }}</template> - <template #description>{{ i18n "pages.xray.accessLogDesc" }}</template> + <template #description>{{ i18n "pages.xray.accessLogDesc" + }}</template> <template #control> - <a-select v-model="accessLog" :dropdown-class-name="themeSwitcher.currentTheme" :style="{ width: '100%' }"> - <a-select-option value=''> + <a-select v-model="accessLog" + :dropdown-class-name="themeSwitcher.currentTheme" + :style="{ width: '100%' }"> + <a-select-option value> <span>Empty</span> </a-select-option> <a-select-option v-for="s in log.access" :value="s"> @@ -100,10 +132,13 @@ </a-setting-list-item> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.errorLog" }}</template> - <template #description>{{ i18n "pages.xray.errorLogDesc" }}</template> + <template #description>{{ i18n "pages.xray.errorLogDesc" + }}</template> <template #control> - <a-select v-model="errorLog" :dropdown-class-name="themeSwitcher.currentTheme" :style="{ width: '100%' }"> - <a-select-option value=''> + <a-select v-model="errorLog" + :dropdown-class-name="themeSwitcher.currentTheme" + :style="{ width: '100%' }"> + <a-select-option value> <span>Empty</span> </a-select-option> <a-select-option v-for="s in log.error" :value="s"> @@ -114,11 +149,13 @@ </a-setting-list-item> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.maskAddress" }}</template> - <template #description>{{ i18n "pages.xray.maskAddressDesc" }}</template> + <template #description>{{ i18n "pages.xray.maskAddressDesc" + }}</template> <template #control> - <a-select v-model="maskAddressLog" :dropdown-class-name="themeSwitcher.currentTheme" + <a-select v-model="maskAddressLog" + :dropdown-class-name="themeSwitcher.currentTheme" :style="{ width: '100%' }"> - <a-select-option value=''> + <a-select-option value> <span>Empty</span> </a-select-option> <a-select-option v-for="s in log.maskAddress" :value="s"> @@ -139,7 +176,8 @@ <a-row :xs="24" :sm="24" :lg="12"> <a-alert type="warning" :style="{ textAlign: 'center' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> <span>{{ i18n "pages.xray.blockConfigsDesc" }}</span> </template> </a-alert> @@ -153,17 +191,21 @@ <a-row :xs="24" :sm="24" :lg="12"> <a-alert type="warning" :style="{ textAlign: 'center' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> - <span>{{ i18n "pages.xray.blockConnectionsConfigsDesc" }}</span> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> + <span>{{ i18n "pages.xray.blockConnectionsConfigsDesc" + }}</span> </template> </a-alert> </a-row> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.blockips" }}</template> <template #control> - <a-select mode="tags" v-model="blockedIPs" :style="{ width: '100%' }" + <a-select mode="tags" v-model="blockedIPs" + :style="{ width: '100%' }" :dropdown-class-name="themeSwitcher.currentTheme"> - <a-select-option :value="p.value" :label="p.label" v-for="p in settingsData.IPsOptions"> + <a-select-option :value="p.value" :label="p.label" + v-for="p in settingsData.IPsOptions"> <span>[[ p.label ]]</span> </a-select-option> </a-select> @@ -172,28 +214,35 @@ <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.blockdomains" }}</template> <template #control> - <a-select mode="tags" v-model="blockedDomains" :style="{ width: '100%' }" + <a-select mode="tags" v-model="blockedDomains" + :style="{ width: '100%' }" :dropdown-class-name="themeSwitcher.currentTheme"> - <a-select-option :value="p.value" :label="p.label" v-for="p in settingsData.BlockDomainsOptions"> + <a-select-option :value="p.value" :label="p.label" + v-for="p in settingsData.BlockDomainsOptions"> <span>[[ p.label ]]</span> </a-select-option> </a-select> </template> </a-setting-list-item> <a-row :xs="24" :sm="24" :lg="12"> - <a-alert type="warning" :style="{ textAlign: 'center', marginTop: '20px' }"> + <a-alert type="warning" + :style="{ textAlign: 'center', marginTop: '20px' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> - <span>{{ i18n "pages.xray.directConnectionsConfigsDesc" }}</span> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> + <span>{{ i18n "pages.xray.directConnectionsConfigsDesc" + }}</span> </template> </a-alert> </a-row> <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.directips" }}</template> <template #control> - <a-select mode="tags" :style="{ width: '100%' }" v-model="directIPs" + <a-select mode="tags" :style="{ width: '100%' }" + v-model="directIPs" :dropdown-class-name="themeSwitcher.currentTheme"> - <a-select-option :value="p.value" :label="p.label" v-for="p in settingsData.IPsOptions"> + <a-select-option :value="p.value" :label="p.label" + v-for="p in settingsData.IPsOptions"> <span>[[ p.label ]]</span> </a-select-option> </a-select> @@ -202,18 +251,22 @@ <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.directdomains" }}</template> <template #control> - <a-select mode="tags" :style="{ width: '100%' }" v-model="directDomains" + <a-select mode="tags" :style="{ width: '100%' }" + v-model="directDomains" :dropdown-class-name="themeSwitcher.currentTheme"> - <a-select-option :value="p.value" :label="p.label" v-for="p in settingsData.DomainsOptions"> + <a-select-option :value="p.value" :label="p.label" + v-for="p in settingsData.DomainsOptions"> <span>[[ p.label ]]</span> </a-select-option> </a-select> </template> </a-setting-list-item> <a-row :xs="24" :sm="24" :lg="12"> - <a-alert type="warning" :style="{ textAlign: 'center', marginTop: '20px' }"> + <a-alert type="warning" + :style="{ textAlign: 'center', marginTop: '20px' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> <span>{{ i18n "pages.xray.ipv4RoutingDesc" }}</span> </template> </a-alert> @@ -221,18 +274,22 @@ <a-setting-list-item paddings="small"> <template #title>{{ i18n "pages.xray.ipv4Routing" }}</template> <template #control> - <a-select mode="tags" :style="{ width: '100%' }" v-model="ipv4Domains" + <a-select mode="tags" :style="{ width: '100%' }" + v-model="ipv4Domains" :dropdown-class-name="themeSwitcher.currentTheme"> - <a-select-option :value="p.value" :label="p.label" v-for="p in settingsData.ServicesOptions"> + <a-select-option :value="p.value" :label="p.label" + v-for="p in settingsData.ServicesOptions"> <span>[[ p.label ]]</span> </a-select-option> </a-select> </template> </a-setting-list-item> <a-row :xs="24" :sm="24" :lg="12"> - <a-alert type="warning" :style="{ textAlign: 'center', marginTop: '20px' }"> + <a-alert type="warning" + :style="{ textAlign: 'center', marginTop: '20px' }"> <template slot="message"> - <a-icon type="exclamation-circle" theme="filled" :style="{ color: '#FFA031' }"></a-icon> + <a-icon type="exclamation-circle" theme="filled" + :style="{ color: '#FFA031' }"></a-icon> {{ i18n "pages.xray.warpRoutingDesc" }} </template> </a-alert> @@ -241,20 +298,24 @@ <template #title>{{ i18n "pages.xray.warpRouting" }}</template> <template #control> <template v-if="WarpExist"> - <a-select mode="tags" :style="{ width: '100%' }" v-model="warpDomains" + <a-select mode="tags" :style="{ width: '100%' }" + v-model="warpDomains" :dropdown-class-name="themeSwitcher.currentTheme"> - <a-select-option :value="p.value" :label="p.label" v-for="p in settingsData.ServicesOptions"> + <a-select-option :value="p.value" :label="p.label" + v-for="p in settingsData.ServicesOptions"> <span>[[ p.label ]]</span> </a-select-option> </a-select> </template> <template v-else> - <a-button type="primary" icon="cloud" @click="showWarp()">WARP</a-button> + <a-button type="primary" icon="cloud" + @click="showWarp()">WARP</a-button> </template> </template> </a-setting-list-item> </a-collapse-panel> - <a-collapse-panel key="6" header='{{ i18n "pages.settings.resetDefaultConfig"}}'> + <a-collapse-panel key="6" + header='{{ i18n "pages.settings.resetDefaultConfig"}}'> <a-space direction="horizontal" :style="{ padding: '0 20px' }"> <a-button type="danger" @click="resetXrayConfigToDefault"> <span>{{ i18n "pages.settings.resetDefaultConfig" }}</span> 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 @@ <a-col :xs="12" :sm="12" :lg="12"> <a-space direction="horizontal" size="small"> <a-button type="primary" icon="plus" @click="addOutbound"> - <span v-if="!isMobile">{{ i18n "pages.xray.outbound.addOutbound" }}</span> + <span v-if="!isMobile">{{ i18n + "pages.xray.outbound.addOutbound" }}</span> </a-button> - <a-button type="primary" icon="cloud" @click="showWarp()">WARP</a-button> + <a-button type="primary" icon="cloud" + @click="showWarp()">WARP</a-button> </a-space> </a-col> <a-col :xs="12" :sm="12" :lg="12" :style="{ textAlign: 'right' }"> <a-button-group> - <a-button icon="sync" @click="refreshOutboundTraffic()" :loading="refreshing"></a-button> - <a-popconfirm placement="topRight" @confirm="resetOutboundTraffic(-1)" + <a-button icon="sync" @click="refreshOutboundTraffic()" + :loading="refreshing"></a-button> + <a-popconfirm placement="topRight" + @confirm="resetOutboundTraffic(-1)" title='{{ i18n "pages.inbounds.resetTrafficContent"}}' - :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "reset"}}' + :overlay-class-name="themeSwitcher.currentTheme" + ok-text='{{ i18n "reset"}}' cancel-text='{{ i18n "cancel"}}'> <a-icon slot="icon" type="question-circle-o" :style="{ color: themeSwitcher.isDarkTheme ? '#008771' : '#008771' }"></a-icon> @@ -23,8 +28,10 @@ </a-button-group> </a-col> </a-row> - <a-table :columns="outboundColumns" bordered :row-key="r => r.key" :data-source="outboundData" - :scroll="isMobile ? {} : { x: 800 }" :pagination="false" :indent-size="0" + <a-table :columns="outboundColumns" bordered :row-key="r => r.key" + :data-source="outboundData" + :scroll="isMobile ? {} : { x: 800 }" :pagination="false" + :indent-size="0" :locale='{ filterConfirm: `{{ i18n "confirm" }}`, filterReset: `{{ i18n "reset" }}` }'> <template slot="action" slot-scope="text, outbound, index"> <span>[[ index+1 ]]</span> @@ -32,7 +39,8 @@ <a-icon @click="e => e.preventDefault()" type="more" :style="{ fontSize: '16px', textDecoration: 'bold' }"></a-icon> <a-menu slot="overlay" :theme="themeSwitcher.currentTheme"> - <a-menu-item v-if="index>0" @click="setFirstOutbound(index)"> + <a-menu-item v-if="index>0" + @click="setFirstOutbound(index)"> <a-icon type="vertical-align-top"></a-icon> <span>{{ i18n "pages.xray.rules.first"}}</span> </a-menu-item> @@ -56,21 +64,64 @@ </a-dropdown> </template> <template slot="address" slot-scope="text, outbound, index"> - <p :style="{ margin: '0 5px' }" v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p> + <p :style="{ margin: '0 5px' }" + v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p> </template> <template slot="protocol" slot-scope="text, outbound, index"> - <a-tag :style="{ margin: '0' }" color="purple">[[ outbound.protocol ]]</a-tag> + <a-tag :style="{ margin: '0' }" color="purple">[[ outbound.protocol + ]]</a-tag> <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)"> - <a-tag :style="{ margin: '0' }" color="blue">[[ outbound.streamSettings.network ]]</a-tag> - <a-tag :style="{ margin: '0' }" v-if="outbound.streamSettings.security=='tls'" color="green">tls</a-tag> - <a-tag :style="{ margin: '0' }" v-if="outbound.streamSettings.security=='reality'" + <a-tag :style="{ margin: '0' }" color="blue">[[ + outbound.streamSettings.network ]]</a-tag> + <a-tag :style="{ margin: '0' }" + v-if="outbound.streamSettings.security=='tls'" + color="green">tls</a-tag> + <a-tag :style="{ margin: '0' }" + v-if="outbound.streamSettings.security=='reality'" color="green">reality</a-tag> </template> </template> <template slot="traffic" slot-scope="text, outbound, index"> <a-tag color="green">[[ findOutboundTraffic(outbound) ]]</a-tag> </template> + <template slot="test" slot-scope="text, outbound, index"> + <a-tooltip> + <template slot="title">{{ i18n "pages.xray.outbound.test" + }}</template> + <a-button + type="primary" + shape="circle" + icon="thunderbolt" + :loading="outboundTestStates[index] && outboundTestStates[index].testing" + @click="testOutbound(index)" + :disabled="(outbound.protocol === 'blackhole' || outbound.tag === 'blocked') || (outboundTestStates[index] && outboundTestStates[index].testing)"> + </a-button> + </a-tooltip> + </template> + <template slot="testResult" slot-scope="text, outbound, index"> + <div + v-if="outboundTestStates[index] && outboundTestStates[index].result"> + <a-tag v-if="outboundTestStates[index].result.success" + color="green"> + [[ outboundTestStates[index].result.delay ]]ms + <span v-if="outboundTestStates[index].result.statusCode"> + ([[ outboundTestStates[index].result.statusCode + ]])</span> + </a-tag> + <a-tooltip v-else + :title="outboundTestStates[index].result.error"> + <a-tag color="red"> + Failed + </a-tag> + </a-tooltip> + </div> + <span + v-else-if="outboundTestStates[index] && outboundTestStates[index].testing"> + <a-icon type="loading" /> + </span> + <span v-else>-</span> + </template> </a-table> </a-space> {{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" .}} -<link rel="stylesheet" href="{{ .base_path }}assets/codemirror/codemirror.min.css?{{ .cur_ver }}"> -<link rel="stylesheet" href="{{ .base_path }}assets/codemirror/fold/foldgutter.css"> -<link rel="stylesheet" href="{{ .base_path }}assets/codemirror/xq.min.css?{{ .cur_ver }}"> +<link rel="stylesheet" + href="{{ .base_path }}assets/codemirror/codemirror.min.css?{{ .cur_ver }}"> +<link rel="stylesheet" + href="{{ .base_path }}assets/codemirror/fold/foldgutter.css"> +<link rel="stylesheet" + href="{{ .base_path }}assets/codemirror/xq.min.css?{{ .cur_ver }}"> <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/lint/lint.css"> {{ template "page/head_end" .}} @@ -10,10 +13,13 @@ <a-sidebar></a-sidebar> <a-layout id="content-layout"> <a-layout-content> - <a-spin :spinning="loadingStates.spinning" :delay="500" tip='{{ i18n "loading"}}'> + <a-spin :spinning="loadingStates.spinning" :delay="500" + tip='{{ i18n "loading"}}'> <transition name="list" appear> - <a-alert type="error" v-if="showAlert && loadingStates.fetched" :style="{ marginBottom: '10px' }" - message='{{ i18n "secAlertTitle" }}' color="red" description='{{ i18n "secAlertSsl" }}' show-icon closable> + <a-alert type="error" v-if="showAlert && loadingStates.fetched" + :style="{ marginBottom: '10px' }" + message='{{ i18n "secAlertTitle" }}' color="red" + description='{{ i18n "secAlertSsl" }}' show-icon closable> </a-alert> </transition> <transition name="list" appear> @@ -26,19 +32,25 @@ <a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else> <a-col> <a-card hoverable> - <a-row :style="{ display: 'flex', flexWrap: 'wrap', alignItems: 'center' }"> + <a-row + :style="{ display: 'flex', flexWrap: 'wrap', alignItems: 'center' }"> <a-col :xs="24" :sm="10" :style="{ padding: '4px' }"> <a-space direction="horizontal"> - <a-button type="primary" :disabled="saveBtnDisable" @click="updateXraySetting"> + <a-button type="primary" :disabled="saveBtnDisable" + @click="updateXraySetting"> {{ i18n "pages.xray.save" }} </a-button> - <a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray"> + <a-button type="danger" :disabled="!saveBtnDisable" + @click="restartXray"&g
|
