mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-25 03:54:47 +03:00
feat(inbounds): replace a dead REALITY target with a tested spare (#6967)
The target scanner finds good REALITY targets, but nothing noticed when the one in use stopped working: every client of the inbound then failed until an admin edited it by hand. A REALITY inbound can now keep spare targets. The panel checks each watched target every 10 minutes with the scanner's own probe, and after three failed checks in a row an inbound with automatic replacement on moves to the first spare that passes both that probe and a real REALITY connection through a throwaway Xray server and client. Only target and serverNames change, saved through UpdateInbound like an admin's edit; nothing changes when no spare passes, and node inbounds are neither checked nor switched from the master. Off until spares are added and automatic replacement is turned on.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
"subscription-server",
|
||||
"subscription-balancers",
|
||||
"hosts",
|
||||
"reality-watch",
|
||||
"nodes",
|
||||
"backup",
|
||||
"mcp",
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
title: REALITY watch
|
||||
description: Spare targets per REALITY inbound. Every 10 minutes the panel
|
||||
checks each watched target from this server; after 3 failed checks in a row,
|
||||
an inbound with auto switch on moves to the first spare that passes the same
|
||||
check and a real REALITY connection through a throwaway Xray server and
|
||||
client. Inbounds on nodes, and targets on this machine or the LAN (a bare
|
||||
port, a unix socket, a private address), are not checked.
|
||||
full: true
|
||||
_openapi:
|
||||
preload:
|
||||
- ./public/openapi.json
|
||||
toc:
|
||||
- depth: 2
|
||||
title: 'Status of every watched inbound: current target, spares, last check and
|
||||
the switch history.'
|
||||
url: '#status-of-every-watched-inbound-current-target-spares-last-check-and-the-switch-history'
|
||||
- depth: 2
|
||||
title: Status of one REALITY inbound.
|
||||
url: '#status-of-one-reality-inbound'
|
||||
- depth: 2
|
||||
title: Set the spare targets (host[:port], in order of preference, at most 10;
|
||||
the current target is dropped) and whether a dead target is replaced
|
||||
automatically.
|
||||
url: '#set-the-spare-targets-hostport-in-order-of-preference-at-most-10-the-current-target-is-dropped-and-whether-a-dead-target-is-replaced-automatically'
|
||||
- depth: 2
|
||||
title: Move the inbound to this target now and return its new status. Refused
|
||||
for a node inbound, or unless the target passes the server check and a
|
||||
real REALITY connection. Only target and serverNames change, plus any
|
||||
Hosts of this inbound that pin an old server name.
|
||||
url: '#move-the-inbound-to-this-target-now-and-return-its-new-status-refused-for-a-node-inbound-or-unless-the-target-passes-the-server-check-and-a-real-reality-connection-only-target-and-servernames-change-plus-any-hosts-of-this-inbound-that-pin-an-old-server-name'
|
||||
- depth: 2
|
||||
title: Check a target from this server and through a real REALITY connection;
|
||||
feasible is false with a reason when either fails.
|
||||
url: '#check-a-target-from-this-server-and-through-a-real-reality-connection-feasible-is-false-with-a-reason-when-either-fails'
|
||||
structuredData:
|
||||
headings:
|
||||
- content: 'Status of every watched inbound: current target, spares, last check
|
||||
and the switch history.'
|
||||
id: status-of-every-watched-inbound-current-target-spares-last-check-and-the-switch-history
|
||||
- content: Status of one REALITY inbound.
|
||||
id: status-of-one-reality-inbound
|
||||
- content: Set the spare targets (host[:port], in order of preference, at most 10;
|
||||
the current target is dropped) and whether a dead target is replaced
|
||||
automatically.
|
||||
id: set-the-spare-targets-hostport-in-order-of-preference-at-most-10-the-current-target-is-dropped-and-whether-a-dead-target-is-replaced-automatically
|
||||
- content: Move the inbound to this target now and return its new status. Refused
|
||||
for a node inbound, or unless the target passes the server check and a
|
||||
real REALITY connection. Only target and serverNames change, plus any
|
||||
Hosts of this inbound that pin an old server name.
|
||||
id: move-the-inbound-to-this-target-now-and-return-its-new-status-refused-for-a-node-inbound-or-unless-the-target-passes-the-server-check-and-a-real-reality-connection-only-target-and-servernames-change-plus-any-hosts-of-this-inbound-that-pin-an-old-server-name
|
||||
- content: Check a target from this server and through a real REALITY connection;
|
||||
feasible is false with a reason when either fails.
|
||||
id: check-a-target-from-this-server-and-through-a-real-reality-connection-feasible-is-false-with-a-reason-when-either-fails
|
||||
contents: []
|
||||
---
|
||||
|
||||
{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
|
||||
|
||||
export default function Layout(props) {
|
||||
const { OpenAPIPage } = props.components ?? {};
|
||||
return (
|
||||
<>
|
||||
{props.children}
|
||||
<OpenAPIPage document="./public/openapi.json" webhooks={[]} operations={[{"path":"/panel/api/realityWatch/list","method":"get"},{"path":"/panel/api/realityWatch/status/{id}","method":"get"},{"path":"/panel/api/realityWatch/save/{id}","method":"post"},{"path":"/panel/api/realityWatch/switch/{id}","method":"post"},{"path":"/panel/api/realityWatch/test","method":"post"}]} showTitle />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -4888,6 +4888,132 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchEntry": {
|
||||
"description": "RealityWatchEntry is what the admin sets per inbound: spare targets (host:port) in order\nof preference, and whether a dead target is replaced without asking.",
|
||||
"properties": {
|
||||
"auto": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"spares": {
|
||||
"example": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"auto",
|
||||
"spares"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchEvent": {
|
||||
"description": "RealityWatchEvent is one switch (To set) or a failed attempt to find a working spare.",
|
||||
"properties": {
|
||||
"at": {
|
||||
"example": 1793000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"from": {
|
||||
"example": "old.example.com:443",
|
||||
"type": "string"
|
||||
},
|
||||
"reason": {
|
||||
"example": "TLS handshake failed: EOF",
|
||||
"type": "string"
|
||||
},
|
||||
"to": {
|
||||
"example": "www.example.com:443",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"from",
|
||||
"reason",
|
||||
"to"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchStatus": {
|
||||
"properties": {
|
||||
"auto": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"checkedAt": {
|
||||
"example": 1793000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"events": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/RealityWatchEvent"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"fails": {
|
||||
"example": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"inboundId": {
|
||||
"example": 3,
|
||||
"type": "integer"
|
||||
},
|
||||
"latencyMs": {
|
||||
"example": 180,
|
||||
"type": "integer"
|
||||
},
|
||||
"ok": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"serverNames": {
|
||||
"example": [
|
||||
"old.example.com"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"spares": {
|
||||
"example": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"target": {
|
||||
"example": "old.example.com:443",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"auto",
|
||||
"checkedAt",
|
||||
"events",
|
||||
"fails",
|
||||
"inboundId",
|
||||
"latencyMs",
|
||||
"ok",
|
||||
"reason",
|
||||
"serverNames",
|
||||
"spares",
|
||||
"target"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ServerSettings": {
|
||||
"description": "ServerSettings is the \"server\" block of an AmneziaWG inbound's Settings\nJSON: the interface-level configuration shared by every client/peer. The\nlisten port is deliberately not duplicated here — it lives on the inbound\nrow itself (Inbound.Port), like every other protocol.",
|
||||
"properties": {
|
||||
@@ -5566,6 +5692,10 @@
|
||||
"name": "Hosts",
|
||||
"description": "Per-inbound override endpoints. Each enabled host renders one extra subscription link/proxy with its own address/port/TLS, superseding the legacy externalProxy array. All endpoints under /panel/api/hosts."
|
||||
},
|
||||
{
|
||||
"name": "REALITY watch",
|
||||
"description": "Spare targets per REALITY inbound. Every 10 minutes the panel checks each watched target from this server; after 3 failed checks in a row, an inbound with auto switch on moves to the first spare that passes the same check and a real REALITY connection through a throwaway Xray server and client. Inbounds on nodes, and targets on this machine or the LAN (a bare port, a unix socket, a private address), are not checked."
|
||||
},
|
||||
{
|
||||
"name": "Backup",
|
||||
"description": "Operations that interact with the configured Telegram bot."
|
||||
@@ -14587,6 +14717,382 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/list": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Status of every watched inbound: current target, spares, last check and the switch history.",
|
||||
"operationId": "get_panel_api_realityWatch_list",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": [
|
||||
{
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/status/{id}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Status of one REALITY inbound.",
|
||||
"operationId": "get_panel_api_realityWatch_status_id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "Inbound ID.",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/save/{id}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Set the spare targets (host[:port], in order of preference, at most 10; the current target is dropped) and whether a dead target is replaced automatically.",
|
||||
"operationId": "post_panel_api_realityWatch_save_id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "Inbound ID.",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"example": {
|
||||
"auto": true,
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/switch/{id}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Move the inbound to this target now and return its new status. Refused for a node inbound, or unless the target passes the server check and a real REALITY connection. Only target and serverNames change, plus any Hosts of this inbound that pin an old server name.",
|
||||
"operationId": "post_panel_api_realityWatch_switch_id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "Inbound ID.",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"example": {
|
||||
"target": "www.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/test": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Check a target from this server and through a real REALITY connection; feasible is false with a reason when either fails.",
|
||||
"operationId": "post_panel_api_realityWatch_test",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"example": {
|
||||
"target": "www.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityScanResult"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"alpn": "h2",
|
||||
"certChainBytes": 3427,
|
||||
"certChainValid": true,
|
||||
"certIssuer": "Google Trust Services",
|
||||
"certSubject": "cloudflare.com",
|
||||
"certValid": true,
|
||||
"curveID": "X25519",
|
||||
"feasible": true,
|
||||
"h2": true,
|
||||
"host": "www.cloudflare.com",
|
||||
"ip": "104.16.124.96",
|
||||
"latencyMs": 180,
|
||||
"notAfter": "2026-08-01T00:00:00Z",
|
||||
"port": 443,
|
||||
"privateTarget": false,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
""
|
||||
],
|
||||
"target": "www.cloudflare.com:443",
|
||||
"tls13": true,
|
||||
"tlsVersion": "1.3",
|
||||
"x25519": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/backuptotgbot": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
||||
@@ -4888,6 +4888,132 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchEntry": {
|
||||
"description": "RealityWatchEntry is what the admin sets per inbound: spare targets (host:port) in order\nof preference, and whether a dead target is replaced without asking.",
|
||||
"properties": {
|
||||
"auto": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"spares": {
|
||||
"example": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"auto",
|
||||
"spares"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchEvent": {
|
||||
"description": "RealityWatchEvent is one switch (To set) or a failed attempt to find a working spare.",
|
||||
"properties": {
|
||||
"at": {
|
||||
"example": 1793000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"from": {
|
||||
"example": "old.example.com:443",
|
||||
"type": "string"
|
||||
},
|
||||
"reason": {
|
||||
"example": "TLS handshake failed: EOF",
|
||||
"type": "string"
|
||||
},
|
||||
"to": {
|
||||
"example": "www.example.com:443",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"from",
|
||||
"reason",
|
||||
"to"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchStatus": {
|
||||
"properties": {
|
||||
"auto": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"checkedAt": {
|
||||
"example": 1793000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"events": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/RealityWatchEvent"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"fails": {
|
||||
"example": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"inboundId": {
|
||||
"example": 3,
|
||||
"type": "integer"
|
||||
},
|
||||
"latencyMs": {
|
||||
"example": 180,
|
||||
"type": "integer"
|
||||
},
|
||||
"ok": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"serverNames": {
|
||||
"example": [
|
||||
"old.example.com"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"spares": {
|
||||
"example": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"target": {
|
||||
"example": "old.example.com:443",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"auto",
|
||||
"checkedAt",
|
||||
"events",
|
||||
"fails",
|
||||
"inboundId",
|
||||
"latencyMs",
|
||||
"ok",
|
||||
"reason",
|
||||
"serverNames",
|
||||
"spares",
|
||||
"target"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ServerSettings": {
|
||||
"description": "ServerSettings is the \"server\" block of an AmneziaWG inbound's Settings\nJSON: the interface-level configuration shared by every client/peer. The\nlisten port is deliberately not duplicated here — it lives on the inbound\nrow itself (Inbound.Port), like every other protocol.",
|
||||
"properties": {
|
||||
@@ -5566,6 +5692,10 @@
|
||||
"name": "Hosts",
|
||||
"description": "Per-inbound override endpoints. Each enabled host renders one extra subscription link/proxy with its own address/port/TLS, superseding the legacy externalProxy array. All endpoints under /panel/api/hosts."
|
||||
},
|
||||
{
|
||||
"name": "REALITY watch",
|
||||
"description": "Spare targets per REALITY inbound. Every 10 minutes the panel checks each watched target from this server; after 3 failed checks in a row, an inbound with auto switch on moves to the first spare that passes the same check and a real REALITY connection through a throwaway Xray server and client. Inbounds on nodes, and targets on this machine or the LAN (a bare port, a unix socket, a private address), are not checked."
|
||||
},
|
||||
{
|
||||
"name": "Backup",
|
||||
"description": "Operations that interact with the configured Telegram bot."
|
||||
@@ -14587,6 +14717,382 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/list": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Status of every watched inbound: current target, spares, last check and the switch history.",
|
||||
"operationId": "get_panel_api_realityWatch_list",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": [
|
||||
{
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/status/{id}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Status of one REALITY inbound.",
|
||||
"operationId": "get_panel_api_realityWatch_status_id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "Inbound ID.",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/save/{id}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Set the spare targets (host[:port], in order of preference, at most 10; the current target is dropped) and whether a dead target is replaced automatically.",
|
||||
"operationId": "post_panel_api_realityWatch_save_id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "Inbound ID.",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"example": {
|
||||
"auto": true,
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/switch/{id}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Move the inbound to this target now and return its new status. Refused for a node inbound, or unless the target passes the server check and a real REALITY connection. Only target and serverNames change, plus any Hosts of this inbound that pin an old server name.",
|
||||
"operationId": "post_panel_api_realityWatch_switch_id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "Inbound ID.",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"example": {
|
||||
"target": "www.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityWatchStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/realityWatch/test": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"REALITY watch"
|
||||
],
|
||||
"summary": "Check a target from this server and through a real REALITY connection; feasible is false with a reason when either fails.",
|
||||
"operationId": "post_panel_api_realityWatch_test",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"example": {
|
||||
"target": "www.example.com:443"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
},
|
||||
"obj": {
|
||||
"$ref": "#/components/schemas/RealityScanResult"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"obj": {
|
||||
"alpn": "h2",
|
||||
"certChainBytes": 3427,
|
||||
"certChainValid": true,
|
||||
"certIssuer": "Google Trust Services",
|
||||
"certSubject": "cloudflare.com",
|
||||
"certValid": true,
|
||||
"curveID": "X25519",
|
||||
"feasible": true,
|
||||
"h2": true,
|
||||
"host": "www.cloudflare.com",
|
||||
"ip": "104.16.124.96",
|
||||
"latencyMs": 180,
|
||||
"notAfter": "2026-08-01T00:00:00Z",
|
||||
"port": 443,
|
||||
"privateTarget": false,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
""
|
||||
],
|
||||
"target": "www.cloudflare.com:443",
|
||||
"tls13": true,
|
||||
"tlsVersion": "1.3",
|
||||
"x25519": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/panel/api/backuptotgbot": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
||||
@@ -1221,6 +1221,42 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"tlsVersion": "1.3",
|
||||
"x25519": true
|
||||
},
|
||||
"RealityWatchEntry": {
|
||||
"auto": true,
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
]
|
||||
},
|
||||
"RealityWatchEvent": {
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
},
|
||||
"RealityWatchStatus": {
|
||||
"auto": true,
|
||||
"checkedAt": 1793000000,
|
||||
"events": [
|
||||
{
|
||||
"at": 1793000000,
|
||||
"from": "old.example.com:443",
|
||||
"reason": "TLS handshake failed: EOF",
|
||||
"to": "www.example.com:443"
|
||||
}
|
||||
],
|
||||
"fails": 0,
|
||||
"inboundId": 3,
|
||||
"latencyMs": 180,
|
||||
"ok": true,
|
||||
"reason": "",
|
||||
"serverNames": [
|
||||
"old.example.com"
|
||||
],
|
||||
"spares": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"target": "old.example.com:443"
|
||||
},
|
||||
"ServerSettings": {
|
||||
"contentPaddingAddition": "",
|
||||
"disableCookies": false,
|
||||
|
||||
@@ -4862,6 +4862,132 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchEntry": {
|
||||
"description": "RealityWatchEntry is what the admin sets per inbound: spare targets (host:port) in order\nof preference, and whether a dead target is replaced without asking.",
|
||||
"properties": {
|
||||
"auto": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"spares": {
|
||||
"example": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"auto",
|
||||
"spares"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchEvent": {
|
||||
"description": "RealityWatchEvent is one switch (To set) or a failed attempt to find a working spare.",
|
||||
"properties": {
|
||||
"at": {
|
||||
"example": 1793000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"from": {
|
||||
"example": "old.example.com:443",
|
||||
"type": "string"
|
||||
},
|
||||
"reason": {
|
||||
"example": "TLS handshake failed: EOF",
|
||||
"type": "string"
|
||||
},
|
||||
"to": {
|
||||
"example": "www.example.com:443",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"from",
|
||||
"reason",
|
||||
"to"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"RealityWatchStatus": {
|
||||
"properties": {
|
||||
"auto": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"checkedAt": {
|
||||
"example": 1793000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"events": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/RealityWatchEvent"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"fails": {
|
||||
"example": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
"inboundId": {
|
||||
"example": 3,
|
||||
"type": "integer"
|
||||
},
|
||||
"latencyMs": {
|
||||
"example": 180,
|
||||
"type": "integer"
|
||||
},
|
||||
"ok": {
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"serverNames": {
|
||||
"example": [
|
||||
"old.example.com"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"spares": {
|
||||
"example": [
|
||||
"www.example.com:443"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"target": {
|
||||
"example": "old.example.com:443",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"auto",
|
||||
"checkedAt",
|
||||
"events",
|
||||
"fails",
|
||||
"inboundId",
|
||||
"latencyMs",
|
||||
"ok",
|
||||
"reason",
|
||||
"serverNames",
|
||||
"spares",
|
||||
"target"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ServerSettings": {
|
||||
"description": "ServerSettings is the \"server\" block of an AmneziaWG inbound's Settings\nJSON: the interface-level configuration shared by every client/peer. The\nlisten port is deliberately not duplicated here — it lives on the inbound\nrow itself (Inbound.Port), like every other protocol.",
|
||||
"properties": {
|
||||
|
||||
@@ -1096,6 +1096,32 @@ export interface RealityScanResult {
|
||||
x25519: boolean;
|
||||
}
|
||||
|
||||
export interface RealityWatchEntry {
|
||||
auto: boolean;
|
||||
spares: string[];
|
||||
}
|
||||
|
||||
export interface RealityWatchEvent {
|
||||
at: number;
|
||||
from: string;
|
||||
reason: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
export interface RealityWatchStatus {
|
||||
auto: boolean;
|
||||
checkedAt: number;
|
||||
events: RealityWatchEvent[];
|
||||
fails: number;
|
||||
inboundId: number;
|
||||
latencyMs: number;
|
||||
ok: boolean;
|
||||
reason: string;
|
||||
serverNames: string[];
|
||||
spares: string[];
|
||||
target: string;
|
||||
}
|
||||
|
||||
export interface ServerSettings {
|
||||
contentPaddingAddition?: string;
|
||||
disableCookies: boolean;
|
||||
|
||||
@@ -1160,6 +1160,35 @@ export const RealityScanResultSchema = z.object({
|
||||
});
|
||||
export type RealityScanResult = z.infer<typeof RealityScanResultSchema>;
|
||||
|
||||
export const RealityWatchEntrySchema = z.object({
|
||||
auto: z.boolean(),
|
||||
spares: z.array(z.string()),
|
||||
});
|
||||
export type RealityWatchEntry = z.infer<typeof RealityWatchEntrySchema>;
|
||||
|
||||
export const RealityWatchEventSchema = z.object({
|
||||
at: z.number().int(),
|
||||
from: z.string(),
|
||||
reason: z.string(),
|
||||
to: z.string(),
|
||||
});
|
||||
export type RealityWatchEvent = z.infer<typeof RealityWatchEventSchema>;
|
||||
|
||||
export const RealityWatchStatusSchema = z.object({
|
||||
auto: z.boolean(),
|
||||
checkedAt: z.number().int(),
|
||||
events: z.array(z.lazy(() => RealityWatchEventSchema)),
|
||||
fails: z.number().int(),
|
||||
inboundId: z.number().int(),
|
||||
latencyMs: z.number().int(),
|
||||
ok: z.boolean(),
|
||||
reason: z.string(),
|
||||
serverNames: z.array(z.string()),
|
||||
spares: z.array(z.string()),
|
||||
target: z.string(),
|
||||
});
|
||||
export type RealityWatchStatus = z.infer<typeof RealityWatchStatusSchema>;
|
||||
|
||||
export const ServerSettingsSchema = z.object({
|
||||
contentPaddingAddition: z.string().optional(),
|
||||
disableCookies: z.boolean(),
|
||||
|
||||
@@ -2150,6 +2150,56 @@ export const sections: readonly Section[] = [
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
id: 'reality-watch',
|
||||
title: 'REALITY watch',
|
||||
description:
|
||||
'Spare targets per REALITY inbound. Every 10 minutes the panel checks each watched target from this server; after 3 failed checks in a row, an inbound with auto switch on moves to the first spare that passes the same check and a real REALITY connection through a throwaway Xray server and client. Inbounds on nodes, and targets on this machine or the LAN (a bare port, a unix socket, a private address), are not checked.',
|
||||
endpoints: [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/panel/api/realityWatch/list',
|
||||
summary:
|
||||
'Status of every watched inbound: current target, spares, last check and the switch history.',
|
||||
responseSchema: 'RealityWatchStatus',
|
||||
responseSchemaArray: true,
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/panel/api/realityWatch/status/:id',
|
||||
summary: 'Status of one REALITY inbound.',
|
||||
params: [{ name: 'id', in: 'path', type: 'number', desc: 'Inbound ID.' }],
|
||||
responseSchema: 'RealityWatchStatus',
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/panel/api/realityWatch/save/:id',
|
||||
summary:
|
||||
'Set the spare targets (host[:port], in order of preference, at most 10; the current target is dropped) and whether a dead target is replaced automatically.',
|
||||
params: [{ name: 'id', in: 'path', type: 'number', desc: 'Inbound ID.' }],
|
||||
body: '{\n "auto": true,\n "spares": ["www.example.com:443"]\n}',
|
||||
responseSchema: 'RealityWatchStatus',
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/panel/api/realityWatch/switch/:id',
|
||||
summary:
|
||||
'Move the inbound to this target now and return its new status. Refused for a node inbound, or unless the target passes the server check and a real REALITY connection. Only target and serverNames change, plus any Hosts of this inbound that pin an old server name.',
|
||||
params: [{ name: 'id', in: 'path', type: 'number', desc: 'Inbound ID.' }],
|
||||
body: '{\n "target": "www.example.com:443"\n}',
|
||||
responseSchema: 'RealityWatchStatus',
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/panel/api/realityWatch/test',
|
||||
summary:
|
||||
'Check a target from this server and through a real REALITY connection; feasible is false with a reason when either fails.',
|
||||
body: '{\n "target": "www.example.com:443"\n}',
|
||||
responseSchema: 'RealityScanResult',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
id: 'backup',
|
||||
title: 'Backup',
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
|
||||
|
||||
import { HttpUtil, NumberFormatter, RandomUtil, SizeFormatter, Wireguard } from '@/utils';
|
||||
import type { RealityScanResult } from '@/generated/types';
|
||||
import type { RealityScanResult, RealityWatchEntry } from '@/generated/types';
|
||||
import {
|
||||
rawInboundToFormValues,
|
||||
formValuesToWirePayload,
|
||||
@@ -328,6 +328,7 @@ export default function InboundFormModal({
|
||||
const trafficReset = useWatch({ control, name: 'trafficReset' }) ?? 'never';
|
||||
const autoTagRef = useRef(true);
|
||||
const lastWrittenTagRef = useRef('');
|
||||
const realityWatchDraft = useRef<RealityWatchEntry | null>(null);
|
||||
const currentTagInput = (): InboundTagInput => ({
|
||||
port: typeof wPort === 'number' ? wPort : 0,
|
||||
nodeId: typeof wNodeId === 'number' ? wNodeId : null,
|
||||
@@ -480,6 +481,7 @@ export default function InboundFormModal({
|
||||
? withoutClients(rawInboundToFormValues(dbInbound))
|
||||
: buildAddModeValues();
|
||||
methods.reset(initial);
|
||||
realityWatchDraft.current = null;
|
||||
savedInboundId.current = null;
|
||||
setScanResult(null);
|
||||
setActiveTab('basic');
|
||||
@@ -649,15 +651,27 @@ export default function InboundFormModal({
|
||||
: '/panel/api/inbounds/add';
|
||||
const msg = await HttpUtil.post(url, payload);
|
||||
if (msg?.success) {
|
||||
if (isFallbackHost) {
|
||||
const obj = msg.obj as { id?: number; Id?: number } | null;
|
||||
const masterId = existingId ?? obj?.id ?? obj?.Id ?? 0;
|
||||
if (masterId) savedInboundId.current = masterId;
|
||||
if (masterId && !(await saveFallbacks(masterId))) {
|
||||
const obj = msg.obj as { id?: number; Id?: number } | null;
|
||||
const masterId = existingId ?? obj?.id ?? obj?.Id ?? 0;
|
||||
if (isFallbackHost && masterId) {
|
||||
savedInboundId.current = masterId;
|
||||
if (!(await saveFallbacks(masterId))) {
|
||||
messageApi.error(t('pages.inbounds.fallbacks.saveFailed'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
const watch = realityWatchDraft.current;
|
||||
if (
|
||||
mode === 'add' &&
|
||||
masterId &&
|
||||
parsed.data.streamSettings?.security === 'reality' &&
|
||||
watch &&
|
||||
(watch.auto || watch.spares.length)
|
||||
) {
|
||||
await HttpUtil.post(`/panel/api/realityWatch/save/${masterId}`, watch, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
onSaved();
|
||||
onClose();
|
||||
}
|
||||
@@ -1127,6 +1141,17 @@ export default function InboundFormModal({
|
||||
clearRealityKeypair={clearRealityKeypair}
|
||||
genMldsa65={genMldsa65}
|
||||
clearMldsa65={clearMldsa65}
|
||||
inboundId={mode === 'edit' && dbInbound ? dbInbound.id : null}
|
||||
onNode={typeof dbInbound?.nodeId === 'number'}
|
||||
messageApi={messageApi}
|
||||
onWatchDraftChange={(entry) => {
|
||||
realityWatchDraft.current = entry;
|
||||
}}
|
||||
onWatchSwitched={(target, serverNames) => {
|
||||
methods.setValue('streamSettings.realitySettings.target', target);
|
||||
methods.setValue('streamSettings.realitySettings.serverNames', serverNames);
|
||||
setScanResult(null);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
import { useCallback, useEffect, useId, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Alert, Button, Divider, Form, Space, Switch, Table, Tag, Typography } from 'antd';
|
||||
import type { MessageInstance } from 'antd/es/message/interface';
|
||||
import { DeleteOutlined, SearchOutlined, SwapOutlined } from '@ant-design/icons';
|
||||
import dayjs from 'dayjs';
|
||||
import { useWatch } from 'react-hook-form';
|
||||
|
||||
import { HttpUtil } from '@/utils';
|
||||
import type { RealityScanResult, RealityWatchEntry, RealityWatchStatus } from '@/generated/types';
|
||||
import RealityTargetScannerModal from './RealityTargetScannerModal';
|
||||
import { REALITY_WATCH_MAX_SPARES, addSpare } from './realityWatch';
|
||||
|
||||
const JSON_HEADERS = { headers: { 'Content-Type': 'application/json' } };
|
||||
// the server switches after this many failed checks in a row (realityWatchFailLimit)
|
||||
const FAIL_LIMIT = 3;
|
||||
|
||||
interface Props {
|
||||
inboundId: number | null;
|
||||
onNode: boolean;
|
||||
scanRealityCandidates: (targets?: string) => Promise<RealityScanResult[]>;
|
||||
message?: MessageInstance;
|
||||
// a new inbound has no id yet: its spares go to the form and are saved after the create
|
||||
onDraftChange?: (entry: RealityWatchEntry) => void;
|
||||
onSwitched?: (target: string, serverNames: string[]) => void;
|
||||
}
|
||||
|
||||
export default function RealityWatchSection({
|
||||
inboundId,
|
||||
onNode,
|
||||
scanRealityCandidates,
|
||||
message,
|
||||
onDraftChange,
|
||||
onSwitched,
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
const uid = useId();
|
||||
const [status, setStatus] = useState<RealityWatchStatus | null>(null);
|
||||
const [spares, setSpares] = useState<string[]>([]);
|
||||
const [auto, setAuto] = useState(false);
|
||||
const [dirty, setDirty] = useState(false);
|
||||
const [busy, setBusy] = useState('');
|
||||
const [tests, setTests] = useState<Record<string, RealityScanResult>>({});
|
||||
const [scannerOpen, setScannerOpen] = useState(false);
|
||||
const formTarget = useWatch({ name: 'streamSettings.realitySettings.target' }) as unknown;
|
||||
const isDraft = !inboundId;
|
||||
const currentTarget = isDraft
|
||||
? typeof formTarget === 'string'
|
||||
? formTarget
|
||||
: ''
|
||||
: (status?.target ?? '');
|
||||
|
||||
const show = useCallback((st: RealityWatchStatus) => {
|
||||
setStatus(st);
|
||||
setSpares(st.spares ?? []);
|
||||
setAuto(st.auto);
|
||||
setDirty(false);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!inboundId) return;
|
||||
void HttpUtil.get<RealityWatchStatus>(
|
||||
`/panel/api/realityWatch/status/${inboundId}`,
|
||||
undefined,
|
||||
{
|
||||
silent: true,
|
||||
},
|
||||
).then((msg) => {
|
||||
if (msg?.success && msg.obj) show(msg.obj);
|
||||
});
|
||||
}, [inboundId, show]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isDraft) onDraftChange?.({ auto, spares });
|
||||
}, [isDraft, auto, spares, onDraftChange]);
|
||||
|
||||
const save = async () => {
|
||||
setBusy('save');
|
||||
try {
|
||||
const msg = await HttpUtil.post<RealityWatchStatus>(
|
||||
`/panel/api/realityWatch/save/${inboundId}`,
|
||||
{ auto, spares },
|
||||
{ ...JSON_HEADERS, silent: true },
|
||||
);
|
||||
if (msg?.success && msg.obj) {
|
||||
show(msg.obj);
|
||||
message?.success(t('pages.inbounds.realityWatch.toasts.saved'));
|
||||
} else message?.error(msg?.msg || t('pages.inbounds.realityWatch.toasts.failed'));
|
||||
} finally {
|
||||
setBusy('');
|
||||
}
|
||||
};
|
||||
|
||||
const test = async (target: string, inBatch = false) => {
|
||||
if (!inBatch) setBusy('test:' + target);
|
||||
try {
|
||||
const msg = await HttpUtil.post<RealityScanResult>(
|
||||
'/panel/api/realityWatch/test',
|
||||
{ target },
|
||||
{ ...JSON_HEADERS, silent: true },
|
||||
);
|
||||
if (msg?.success && msg.obj) setTests((prev) => ({ ...prev, [target]: msg.obj! }));
|
||||
else message?.error(msg?.msg || t('pages.inbounds.realityWatch.toasts.failed'));
|
||||
} finally {
|
||||
if (!inBatch) setBusy('');
|
||||
}
|
||||
};
|
||||
|
||||
const switchTo = async (target: string) => {
|
||||
setBusy('switch:' + target);
|
||||
try {
|
||||
const msg = await HttpUtil.post<RealityWatchStatus>(
|
||||
`/panel/api/realityWatch/switch/${inboundId}`,
|
||||
{ target },
|
||||
{ ...JSON_HEADERS, silent: true },
|
||||
);
|
||||
if (!msg?.success || !msg.obj) {
|
||||
message?.error(msg?.msg || t('pages.inbounds.realityWatch.toasts.switchFailed'));
|
||||
return;
|
||||
}
|
||||
message?.success(t('pages.inbounds.realityWatch.toasts.switched', { target }));
|
||||
show(msg.obj);
|
||||
onSwitched?.(msg.obj.target, msg.obj.serverNames);
|
||||
} finally {
|
||||
setBusy('');
|
||||
}
|
||||
};
|
||||
|
||||
const failing = !!status?.checkedAt && !status.ok;
|
||||
const statusTag = !status?.checkedAt ? (
|
||||
<Tag>{t('pages.inbounds.realityWatch.notChecked')}</Tag>
|
||||
) : failing ? (
|
||||
<Tag color="error">
|
||||
{t('pages.inbounds.realityWatch.failing', { fails: status.fails, limit: FAIL_LIMIT })}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag color="success">{t('pages.inbounds.realityWatch.working')}</Tag>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Divider>{t('pages.inbounds.realityWatch.title')}</Divider>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{t('pages.inbounds.realityWatch.hint', { limit: FAIL_LIMIT })}
|
||||
{isDraft && ` ${t('pages.inbounds.realityWatch.savedWithInbound')}`}
|
||||
</Typography.Paragraph>
|
||||
{onNode && (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
style={{ marginBottom: 12 }}
|
||||
title={t('pages.inbounds.realityWatch.onNode')}
|
||||
/>
|
||||
)}
|
||||
{!isDraft && (
|
||||
<Form.Item label={t('pages.inbounds.realityWatch.status')}>
|
||||
<Space wrap>
|
||||
{statusTag}
|
||||
{status?.checkedAt && status.ok && status.latencyMs > 0 ? (
|
||||
<Typography.Text>{status.latencyMs} ms</Typography.Text>
|
||||
) : null}
|
||||
{status?.checkedAt ? (
|
||||
<Typography.Text type="secondary">
|
||||
{dayjs.unix(status.checkedAt).format('YYYY-MM-DD HH:mm')}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
{failing && status.reason ? (
|
||||
<Typography.Text type="secondary">{status.reason}</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item label={t('pages.inbounds.realityWatch.auto')} htmlFor={`${uid}-auto`}>
|
||||
<Switch
|
||||
id={`${uid}-auto`}
|
||||
checked={auto}
|
||||
onChange={(v) => {
|
||||
setAuto(v);
|
||||
setDirty(true);
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t('pages.inbounds.realityWatch.spares')}
|
||||
labelCol={{ span: 24 }}
|
||||
wrapperCol={{ span: 24 }}
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Table
|
||||
size="small"
|
||||
rowKey={(r) => r}
|
||||
pagination={false}
|
||||
dataSource={spares}
|
||||
locale={{ emptyText: t('pages.inbounds.realityWatch.noSpares') }}
|
||||
columns={[
|
||||
{ title: t('pages.inbounds.form.target'), render: (_, r: string) => r },
|
||||
{
|
||||
title: t('pages.inbounds.realityWatch.realTest'),
|
||||
width: 190,
|
||||
render: (_, r: string) => {
|
||||
const res = tests[r];
|
||||
return res ? (
|
||||
<Tag color={res.feasible ? 'success' : 'error'} title={res.reason}>
|
||||
{res.feasible
|
||||
? `${t('pages.inbounds.realityWatch.testOk')}${res.latencyMs > 0 ? ` · ${res.latencyMs} ms` : ''}`
|
||||
: t('pages.inbounds.realityWatch.testFailed')}
|
||||
</Tag>
|
||||
) : (
|
||||
<Button
|
||||
size="small"
|
||||
loading={busy === 'test:' + r || (busy === 'testAll' && !tests[r])}
|
||||
onClick={() => test(r)}
|
||||
>
|
||||
{t('pages.inbounds.realityWatch.test')}
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
width: 96,
|
||||
render: (_, r: string) => (
|
||||
<Space size={4}>
|
||||
{!isDraft && (
|
||||
<Button
|
||||
size="small"
|
||||
icon={<SwapOutlined aria-hidden />}
|
||||
aria-label={t('pages.inbounds.realityWatch.switchNow')}
|
||||
title={t('pages.inbounds.realityWatch.switchNow')}
|
||||
loading={busy === 'switch:' + r}
|
||||
disabled={dirty || onNode}
|
||||
onClick={() => switchTo(r)}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
size="small"
|
||||
danger
|
||||
icon={<DeleteOutlined aria-hidden />}
|
||||
aria-label={t('delete')}
|
||||
onClick={() => {
|
||||
setSpares(spares.filter((s) => s !== r));
|
||||
setDirty(true);
|
||||
}}
|
||||
/>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Space wrap>
|
||||
<Button
|
||||
icon={<SearchOutlined aria-hidden />}
|
||||
disabled={spares.length >= REALITY_WATCH_MAX_SPARES}
|
||||
onClick={() => setScannerOpen(true)}
|
||||
>
|
||||
{t('pages.inbounds.realityWatch.findSpares')}
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!spares.length || busy !== ''}
|
||||
loading={busy === 'testAll'}
|
||||
onClick={async () => {
|
||||
setBusy('testAll');
|
||||
setTests({});
|
||||
try {
|
||||
for (const r of spares) await test(r, true);
|
||||
} finally {
|
||||
setBusy('');
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('pages.inbounds.realityWatch.testAll')}
|
||||
</Button>
|
||||
{!isDraft && (
|
||||
<Button type="primary" disabled={!dirty} loading={busy === 'save'} onClick={save}>
|
||||
{t('pages.inbounds.realityWatch.save')}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
{!!status?.events?.length && (
|
||||
<Form.Item label={t('pages.inbounds.realityWatch.history')}>
|
||||
<Space direction="vertical" size={2}>
|
||||
{[...status.events].reverse().map((ev) => (
|
||||
<Typography.Text key={ev.at + ev.to} type={ev.to ? undefined : 'danger'}>
|
||||
{dayjs.unix(ev.at).format('MM-DD HH:mm')} ·{' '}
|
||||
{ev.to
|
||||
? t('pages.inbounds.realityWatch.eventSwitched', { from: ev.from, to: ev.to })
|
||||
: t('pages.inbounds.realityWatch.eventNoSpare', { from: ev.from })}
|
||||
</Typography.Text>
|
||||
))}
|
||||
</Space>
|
||||
</Form.Item>
|
||||
)}
|
||||
<RealityTargetScannerModal
|
||||
open={scannerOpen}
|
||||
onClose={() => setScannerOpen(false)}
|
||||
scanRealityCandidates={scanRealityCandidates}
|
||||
onPick={(r) => {
|
||||
setSpares((prev) => addSpare(prev, r.target, currentTarget));
|
||||
setDirty(true);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,9 @@ import {
|
||||
validateRealityMaxClientVer,
|
||||
validateRealityTarget,
|
||||
} from '@/lib/xray/stream-wire-normalize';
|
||||
import type { RealityScanResult } from '@/generated/types';
|
||||
import type { RealityScanResult, RealityWatchEntry } from '@/generated/types';
|
||||
import type { MessageInstance } from 'antd/es/message/interface';
|
||||
import RealityWatchSection from './RealityWatchSection';
|
||||
import RealityTargetScannerModal, {
|
||||
MLDSA65_MIN_CERT_CHAIN_BYTES,
|
||||
} from './RealityTargetScannerModal';
|
||||
@@ -44,6 +46,11 @@ interface RealityFormProps {
|
||||
clearRealityKeypair: () => void;
|
||||
genMldsa65: () => void;
|
||||
clearMldsa65: () => void;
|
||||
inboundId?: number | null;
|
||||
onNode?: boolean;
|
||||
messageApi?: MessageInstance;
|
||||
onWatchDraftChange?: (entry: RealityWatchEntry) => void;
|
||||
onWatchSwitched?: (target: string, serverNames: string[]) => void;
|
||||
}
|
||||
|
||||
export default function RealityForm({
|
||||
@@ -59,6 +66,11 @@ export default function RealityForm({
|
||||
clearRealityKeypair,
|
||||
genMldsa65,
|
||||
clearMldsa65,
|
||||
inboundId = null,
|
||||
onNode = false,
|
||||
messageApi,
|
||||
onWatchDraftChange,
|
||||
onWatchSwitched,
|
||||
}: RealityFormProps) {
|
||||
const { t } = useTranslation();
|
||||
const uid = useId();
|
||||
@@ -387,6 +399,14 @@ export default function RealityForm({
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<RealityWatchSection
|
||||
inboundId={inboundId}
|
||||
onNode={onNode}
|
||||
scanRealityCandidates={scanRealityCandidates}
|
||||
message={messageApi}
|
||||
onDraftChange={onWatchDraftChange}
|
||||
onSwitched={onWatchSwitched}
|
||||
/>
|
||||
<RealityTargetScannerModal
|
||||
open={scannerOpen}
|
||||
onClose={() => setScannerOpen(false)}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Same limit and shape as the server (internal/web/service/reality_watch.go).
|
||||
export const REALITY_WATCH_MAX_SPARES = 10;
|
||||
|
||||
export function normalizeSpare(target: string): string {
|
||||
const t = target.trim().toLowerCase();
|
||||
return /:\d+$/.test(t) ? t : `${t}:443`;
|
||||
}
|
||||
|
||||
export function addSpare(spares: string[], target: string, current: string): string[] {
|
||||
const t = normalizeSpare(target);
|
||||
if (!t || t === ':443' || spares.includes(t) || (current && t === normalizeSpare(current)))
|
||||
return spares;
|
||||
if (spares.length >= REALITY_WATCH_MAX_SPARES) return spares;
|
||||
return [...spares, t];
|
||||
}
|
||||
@@ -17,6 +17,8 @@ exports[`inbound security forms > RealityForm field structure is stable 1`] = `
|
||||
"mldsa65 Seed",
|
||||
"mldsa65 Verify",
|
||||
"Master Key Log",
|
||||
"Replace automatically",
|
||||
"Spare targets",
|
||||
]
|
||||
`;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ vi.mock('antd', async (importOriginal) => {
|
||||
...actual,
|
||||
message: {
|
||||
...actual.message,
|
||||
useMessage: () => [{ error: messageError }, null],
|
||||
useMessage: () => [{ error: messageError, success: vi.fn() }, null],
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -539,6 +539,60 @@ describe('InboundFormModal', () => {
|
||||
|
||||
// Clients and enable change through their own endpoints; the server keeps the
|
||||
// stored ones, so the edit form must neither send nor validate its stale copy.
|
||||
// The editor saves the whole form, so a form left on the old target undid the switch.
|
||||
it('saves the target a REALITY watch switch moved to, not the one it opened with', async () => {
|
||||
const post = vi.mocked(HttpUtil.post);
|
||||
const get = vi.mocked(HttpUtil.get);
|
||||
const realPost = post.getMockImplementation();
|
||||
const realGet = get.getMockImplementation();
|
||||
onTestFinished(() => {
|
||||
post.mockImplementation(realPost!);
|
||||
get.mockImplementation(realGet!);
|
||||
});
|
||||
const status = (target: string, serverNames: string[], spares: string[]) => ({
|
||||
success: true,
|
||||
msg: '',
|
||||
obj: {
|
||||
inboundId: 42,
|
||||
target,
|
||||
serverNames,
|
||||
spares,
|
||||
auto: false,
|
||||
checkedAt: 0,
|
||||
ok: false,
|
||||
fails: 0,
|
||||
reason: '',
|
||||
latencyMs: 0,
|
||||
events: [],
|
||||
},
|
||||
});
|
||||
get.mockImplementation(async (url: string) =>
|
||||
url.startsWith('/panel/api/realityWatch/status/')
|
||||
? status('example.com:443', ['example.com'], ['spare.example:443'])
|
||||
: realGet!(url),
|
||||
);
|
||||
post.mockImplementation(async (url: string) =>
|
||||
url.startsWith('/panel/api/realityWatch/switch/')
|
||||
? status('spare.example:443', ['spare.example'], ['example.com:443'])
|
||||
: { success: true, msg: '', obj: {} },
|
||||
);
|
||||
post.mockClear();
|
||||
await renderCloneLikeEdit(cloneLikeVlessInbound('example.com:443'));
|
||||
|
||||
fireEvent.click(screen.getByRole('tab', { name: 'Security' }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Switch to this now' }));
|
||||
expect(await screen.findByDisplayValue('spare.example:443')).toBeTruthy();
|
||||
fireEvent.click(primaryButton());
|
||||
|
||||
await waitFor(() =>
|
||||
expect(post.mock.calls.some(([url]) => String(url).includes('/inbounds/update/'))).toBe(true),
|
||||
);
|
||||
const update = post.mock.calls.find(([url]) => String(url).includes('/inbounds/update/'))!;
|
||||
const stream = JSON.parse((update[1] as { streamSettings: string }).streamSettings);
|
||||
expect(stream.realitySettings.target).toBe('spare.example:443');
|
||||
expect(stream.realitySettings.serverNames).toEqual(['spare.example']);
|
||||
}, 20_000);
|
||||
|
||||
it('edit save neither sends nor validates the clients it loaded', async () => {
|
||||
const post = vi.mocked(HttpUtil.post);
|
||||
post.mockClear();
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Form } from 'antd';
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
import { FormProvider, useForm } from 'react-hook-form';
|
||||
|
||||
import RealityWatchSection from '@/pages/inbounds/form/security/RealityWatchSection';
|
||||
import type { RealityWatchEntry } from '@/generated/types';
|
||||
import { renderWithProviders } from './test-utils';
|
||||
|
||||
function Harness({ onDraftChange }: { onDraftChange: (d: RealityWatchEntry) => void }) {
|
||||
const methods = useForm({
|
||||
defaultValues: { streamSettings: { realitySettings: { target: 'a.example.com:443' } } },
|
||||
});
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
<Form>
|
||||
<RealityWatchSection
|
||||
inboundId={null}
|
||||
onNode={false}
|
||||
scanRealityCandidates={async () => []}
|
||||
onDraftChange={onDraftChange}
|
||||
/>
|
||||
</Form>
|
||||
</FormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
// A new inbound used to show only "save first", so spares meant a create-then-edit round trip.
|
||||
describe('REALITY watch on a new inbound', () => {
|
||||
it('lets the admin set the auto switch and hands it to the form to save with the inbound', () => {
|
||||
const drafts: RealityWatchEntry[] = [];
|
||||
const { getByRole, getByText } = renderWithProviders(
|
||||
<Harness onDraftChange={(d) => drafts.push(d)} />,
|
||||
);
|
||||
expect(getByText('Find spares')).toBeTruthy();
|
||||
fireEvent.click(getByRole('switch'));
|
||||
expect(drafts.at(-1)).toEqual({ auto: true, spares: [] });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { addSpare } from '@/pages/inbounds/form/security/realityWatch';
|
||||
|
||||
// The server keys spares as lower-case host:port and drops the current target; adding the
|
||||
// same site twice from the scanner must not create a second entry that the server collapses.
|
||||
describe('addSpare', () => {
|
||||
it('normalizes to host:port and skips repeats and the current target', () => {
|
||||
let spares: string[] = [];
|
||||
spares = addSpare(spares, 'WWW.Example.com', 'cur.example.com:443');
|
||||
spares = addSpare(spares, 'www.example.com:443', 'cur.example.com:443');
|
||||
spares = addSpare(spares, 'other.example.com:8443', 'cur.example.com:443');
|
||||
spares = addSpare(spares, 'cur.example.com', 'cur.example.com:443');
|
||||
expect(spares).toEqual(['www.example.com:443', 'other.example.com:8443']);
|
||||
});
|
||||
|
||||
it('keeps at most 10, like the server', () => {
|
||||
let spares: string[] = [];
|
||||
for (let i = 0; i < 12; i++) spares = addSpare(spares, `s${i}.example.com`, '');
|
||||
expect(spares).toHaveLength(10);
|
||||
expect(spares[9]).toBe('s9.example.com:443');
|
||||
});
|
||||
});
|
||||
@@ -248,6 +248,9 @@ func (a *APIController) initRouter(g *gin.RouterGroup, router http.Handler) {
|
||||
// Subscription balancers — client-side balancers for the JSON sub output
|
||||
NewSubBalancerController(api)
|
||||
|
||||
// REALITY watch — spare targets and automatic replacement per REALITY inbound
|
||||
NewRealityWatchController(api.Group("/realityWatch"))
|
||||
|
||||
// Extra routes
|
||||
api.POST("/backuptotgbot", a.BackuptoTgbot)
|
||||
api.POST(mcp.Path, a.requireMCPEnabled, gin.WrapH(mcp.NewHandler(router)))
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/web/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RealityWatchController sets the spare targets of REALITY inbounds and switches them.
|
||||
type RealityWatchController struct {
|
||||
realityWatchService service.RealityWatchService
|
||||
}
|
||||
|
||||
func NewRealityWatchController(g *gin.RouterGroup) *RealityWatchController {
|
||||
a := &RealityWatchController{}
|
||||
g.GET("/list", a.list)
|
||||
g.GET("/status/:id", a.status)
|
||||
g.POST("/save/:id", a.save)
|
||||
g.POST("/switch/:id", a.switchTarget)
|
||||
g.POST("/test", a.test)
|
||||
return a
|
||||
}
|
||||
|
||||
type realityWatchTargetRequest struct {
|
||||
Target string `json:"target"`
|
||||
}
|
||||
|
||||
func (a *RealityWatchController) list(c *gin.Context) {
|
||||
jsonObj(c, a.realityWatchService.List(), nil)
|
||||
}
|
||||
|
||||
func (a *RealityWatchController) status(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.failed"), err)
|
||||
return
|
||||
}
|
||||
jsonObj(c, a.realityWatchService.Status(id), nil)
|
||||
}
|
||||
|
||||
func (a *RealityWatchController) save(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.failed"), err)
|
||||
return
|
||||
}
|
||||
var entry service.RealityWatchEntry
|
||||
if err := c.ShouldBindJSON(&entry); err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.failed"), err)
|
||||
return
|
||||
}
|
||||
if err := a.realityWatchService.SaveConfig(id, entry); err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.failed"), err)
|
||||
return
|
||||
}
|
||||
jsonObj(c, a.realityWatchService.Status(id), nil)
|
||||
}
|
||||
|
||||
// switchTarget answers with the status so the editor gets the saved target and SNIs in one step;
|
||||
// a form left on the old ones would put them back on its next Save.
|
||||
func (a *RealityWatchController) switchTarget(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.switchFailed"), err)
|
||||
return
|
||||
}
|
||||
var req realityWatchTargetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.switchFailed"), err)
|
||||
return
|
||||
}
|
||||
if _, err := a.realityWatchService.SwitchTo(c.Request.Context(), id, req.Target); err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.switchFailed"), err)
|
||||
return
|
||||
}
|
||||
jsonObj(c, a.realityWatchService.Status(id), nil)
|
||||
}
|
||||
|
||||
func (a *RealityWatchController) test(c *gin.Context) {
|
||||
var req realityWatchTargetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.failed"), err)
|
||||
return
|
||||
}
|
||||
res, err := a.realityWatchService.TestTarget(c.Request.Context(), req.Target)
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.realityWatch.toasts.failed"), err)
|
||||
return
|
||||
}
|
||||
jsonObj(c, res, nil)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/web/service"
|
||||
)
|
||||
|
||||
// RealityWatchJob checks the target of every watched REALITY inbound and replaces a dead one.
|
||||
type RealityWatchJob struct {
|
||||
realityWatchService service.RealityWatchService
|
||||
}
|
||||
|
||||
func NewRealityWatchJob() *RealityWatchJob {
|
||||
return &RealityWatchJob{}
|
||||
}
|
||||
|
||||
func (j *RealityWatchJob) Run() {
|
||||
j.realityWatchService.Tick(context.Background())
|
||||
}
|
||||
@@ -409,6 +409,39 @@ func (s *HostService) UpdateHostGroup(groupId string, req *entity.HostGroup) ([]
|
||||
return desired, nil
|
||||
}
|
||||
|
||||
// MoveInboundSni follows a REALITY inbound to a new SNI: a Host's own SNI overrides serverNames in
|
||||
// links. Only this inbound's rows change, because a shared group's other inbounds keep their target.
|
||||
func (s *HostService) MoveInboundSni(inboundId int, oldNames []string, newSni string) error {
|
||||
move := func(sni string) string {
|
||||
if slices.Contains(oldNames, sni) {
|
||||
return newSni
|
||||
}
|
||||
return sni
|
||||
}
|
||||
return database.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
var rows []*model.Host
|
||||
if err := tx.Where("inbound_id = ? AND security IN ?", inboundId, []string{"", "same", "reality"}).Find(&rows).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, h := range rows {
|
||||
sni := move(h.Sni)
|
||||
pool := make([]string, 0, len(h.Snis))
|
||||
for _, name := range h.Snis {
|
||||
pool = append(pool, move(name))
|
||||
}
|
||||
pool = cleanSnis(pool)
|
||||
if sni == h.Sni && slices.Equal(pool, h.Snis) {
|
||||
continue
|
||||
}
|
||||
h.Sni, h.Snis = sni, pool
|
||||
if err := tx.Save(h).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *HostService) DeleteHostGroup(groupId string) error {
|
||||
return database.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
_, err := database.DeleteHosts(tx, "group_id = ?", groupId)
|
||||
|
||||
@@ -0,0 +1,523 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
||||
)
|
||||
|
||||
// The REALITY watch checks a target from this server and, after realityWatchFailLimit failures
|
||||
// in a row, moves the inbound to the first spare that passes both checks.
|
||||
|
||||
const (
|
||||
realityWatchSetting = "realityWatch"
|
||||
realityWatchFailLimit = 3
|
||||
realityWatchMaxSpares = 10
|
||||
realityWatchMaxEvents = 20
|
||||
)
|
||||
|
||||
var (
|
||||
errRealityWatchBadSpare = errors.New("reality watch: invalid spare target")
|
||||
errRealityWatchNotReality = errors.New("reality watch: not a REALITY inbound")
|
||||
errRealityWatchTargetFails = errors.New("reality watch: target fails the check")
|
||||
errRealityWatchNoSpare = errors.New("reality watch: no spare target works")
|
||||
errRealityWatchChanged = errors.New("reality watch: the target changed during the check")
|
||||
errRealityWatchOnNode = errors.New("reality watch: this server cannot test a node inbound's target")
|
||||
|
||||
realityWatchProbe = func(s *ServerService, target, sni string, xver int) *RealityScanResult {
|
||||
res, err := s.ScanRealityTarget(target, sni, xver, false)
|
||||
if err != nil {
|
||||
return &RealityScanResult{Target: target, Reason: err.Error()}
|
||||
}
|
||||
return res
|
||||
}
|
||||
realityWatchRealTest = xrayRealityRealTest
|
||||
)
|
||||
|
||||
// RealityWatchEntry is what the admin sets per inbound: spare targets (host:port) in order
|
||||
// of preference, and whether a dead target is replaced without asking.
|
||||
type RealityWatchEntry struct {
|
||||
Auto bool `json:"auto" example:"true"`
|
||||
Spares []string `json:"spares" example:"[\"www.example.com:443\"]"`
|
||||
}
|
||||
|
||||
// RealityWatchEvent is one switch (To set) or a failed attempt to find a working spare.
|
||||
type RealityWatchEvent struct {
|
||||
At int64 `json:"at" example:"1793000000"`
|
||||
From string `json:"from" example:"old.example.com:443"`
|
||||
To string `json:"to" example:"www.example.com:443"`
|
||||
Reason string `json:"reason" example:"TLS handshake failed: EOF"`
|
||||
}
|
||||
|
||||
type RealityWatchStatus struct {
|
||||
InboundId int `json:"inboundId" example:"3"`
|
||||
Target string `json:"target" example:"old.example.com:443"`
|
||||
ServerNames []string `json:"serverNames" example:"[\"old.example.com\"]"`
|
||||
Auto bool `json:"auto" example:"true"`
|
||||
Spares []string `json:"spares" example:"[\"www.example.com:443\"]"`
|
||||
CheckedAt int64 `json:"checkedAt" example:"1793000000"`
|
||||
Ok bool `json:"ok" example:"true"`
|
||||
Fails int `json:"fails" example:"0"`
|
||||
Reason string `json:"reason" example:""`
|
||||
LatencyMs int `json:"latencyMs" example:"180"`
|
||||
Events []RealityWatchEvent `json:"events"`
|
||||
}
|
||||
|
||||
type realityWatchState struct {
|
||||
checkedAt time.Time
|
||||
ok bool
|
||||
fails int
|
||||
reason string
|
||||
latencyMs int
|
||||
events []RealityWatchEvent
|
||||
}
|
||||
|
||||
// realityWatchMu guards config, state and the final save, never a network check: those take
|
||||
// minutes when targets time out and the API must answer meanwhile.
|
||||
var (
|
||||
realityWatchMu sync.Mutex
|
||||
realityWatchStates = map[int]*realityWatchState{}
|
||||
realityWatchTickMu sync.Mutex
|
||||
)
|
||||
|
||||
func resetRealityWatchState() {
|
||||
realityWatchMu.Lock()
|
||||
defer realityWatchMu.Unlock()
|
||||
realityWatchStates = map[int]*realityWatchState{}
|
||||
}
|
||||
|
||||
type RealityWatchService struct {
|
||||
inboundService InboundService
|
||||
hostService HostService
|
||||
settingService SettingService
|
||||
serverService ServerService
|
||||
xrayService XrayService
|
||||
}
|
||||
|
||||
type realitySettingsView struct {
|
||||
Target string `json:"target"`
|
||||
Dest string `json:"dest"`
|
||||
ServerNames []string `json:"serverNames"`
|
||||
Xver int `json:"xver"`
|
||||
}
|
||||
|
||||
// realityOf reads an inbound's REALITY target (older configs call it dest) and SNIs.
|
||||
func realityOf(ib *model.Inbound) (realitySettingsView, bool) {
|
||||
var stream struct {
|
||||
Security string `json:"security"`
|
||||
RealitySettings realitySettingsView `json:"realitySettings"`
|
||||
}
|
||||
if json.Unmarshal([]byte(ib.StreamSettings), &stream) != nil || stream.Security != "reality" {
|
||||
return realitySettingsView{}, false
|
||||
}
|
||||
rs := stream.RealitySettings
|
||||
if rs.Target == "" {
|
||||
rs.Target = rs.Dest
|
||||
}
|
||||
return rs, rs.Target != ""
|
||||
}
|
||||
|
||||
// normalizeRealityTarget is host:port in lower case, :443 when no port is given.
|
||||
func normalizeRealityTarget(raw string) (string, error) {
|
||||
raw = strings.ToLower(strings.TrimSpace(raw))
|
||||
host, port, err := splitRealityTarget(raw)
|
||||
if err != nil || strings.ContainsAny(raw, " \"'`;") {
|
||||
return "", errRealityWatchBadSpare
|
||||
}
|
||||
return net.JoinHostPort(host, strconv.Itoa(port)), nil
|
||||
}
|
||||
|
||||
func (s *RealityWatchService) loadConfig() map[int]RealityWatchEntry {
|
||||
out := map[int]RealityWatchEntry{}
|
||||
raw, err := s.settingService.getString(realityWatchSetting)
|
||||
if err != nil || raw == "" {
|
||||
return out
|
||||
}
|
||||
var byKey map[string]RealityWatchEntry
|
||||
if json.Unmarshal([]byte(raw), &byKey) != nil {
|
||||
return out
|
||||
}
|
||||
for k, v := range byKey {
|
||||
if id, err := strconv.Atoi(k); err == nil {
|
||||
out[id] = v
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *RealityWatchService) storeConfig(cfg map[int]RealityWatchEntry) error {
|
||||
byKey := make(map[string]RealityWatchEntry, len(cfg))
|
||||
for id, v := range cfg {
|
||||
byKey[strconv.Itoa(id)] = v
|
||||
}
|
||||
b, err := json.Marshal(byKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.settingService.setString(realityWatchSetting, string(b))
|
||||
}
|
||||
|
||||
// SaveConfig sets an inbound's spares and auto switch; the current target is never a spare.
|
||||
func (s *RealityWatchService) SaveConfig(inboundId int, entry RealityWatchEntry) error {
|
||||
ib, err := s.inboundService.GetInbound(inboundId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rs, ok := realityOf(ib)
|
||||
if !ok {
|
||||
return errRealityWatchNotReality
|
||||
}
|
||||
current, _ := normalizeRealityTarget(rs.Target)
|
||||
spares := []string{}
|
||||
for _, raw := range entry.Spares {
|
||||
target, err := normalizeRealityTarget(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if target != current && !containsString(spares, target) && len(spares) < realityWatchMaxSpares {
|
||||
spares = append(spares, target)
|
||||
}
|
||||
}
|
||||
realityWatchMu.Lock()
|
||||
defer realityWatchMu.Unlock()
|
||||
cfg := s.loadConfig()
|
||||
cfg[inboundId] = RealityWatchEntry{Auto: entry.Auto, Spares: spares}
|
||||
return s.storeConfig(cfg)
|
||||
}
|
||||
|
||||
func containsString(list []string, v string) bool {
|
||||
for _, x := range list {
|
||||
if x == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *RealityWatchService) Status(inboundId int) RealityWatchStatus {
|
||||
realityWatchMu.Lock()
|
||||
defer realityWatchMu.Unlock()
|
||||
return s.statusLocked(inboundId, s.loadConfig()[inboundId])
|
||||
}
|
||||
|
||||
func (s *RealityWatchService) statusLocked(inboundId int, entry RealityWatchEntry) RealityWatchStatus {
|
||||
st := RealityWatchStatus{
|
||||
InboundId: inboundId, Auto: entry.Auto, Spares: entry.Spares,
|
||||
ServerNames: []string{}, Events: []RealityWatchEvent{},
|
||||
}
|
||||
if st.Spares == nil {
|
||||
st.Spares = []string{}
|
||||
}
|
||||
if ib, err := s.inboundService.GetInbound(inboundId); err == nil {
|
||||
if rs, ok := realityOf(ib); ok {
|
||||
st.Target = rs.Target
|
||||
if rs.ServerNames != nil {
|
||||
st.ServerNames = rs.ServerNames
|
||||
}
|
||||
}
|
||||
}
|
||||
if state := realityWatchStates[inboundId]; state != nil {
|
||||
st.Ok, st.Fails, st.Reason, st.LatencyMs = state.ok, state.fails, state.reason, state.latencyMs
|
||||
if !state.checkedAt.IsZero() {
|
||||
st.CheckedAt = state.checkedAt.Unix()
|
||||
}
|
||||
st.Events = append(st.Events, state.events...)
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// List is the status of every watched inbound.
|
||||
func (s *RealityWatchService) List() []RealityWatchStatus {
|
||||
realityWatchMu.Lock()
|
||||
defer realityWatchMu.Unlock()
|
||||
out := []RealityWatchStatus{}
|
||||
for id, entry := range s.loadConfig() {
|
||||
out = append(out, s.statusLocked(id, entry))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Tick checks every watched inbound's target once (the cron job calls it). A cycle still running
|
||||
// when the next one fires keeps going alone, so one outage is not counted twice.
|
||||
func (s *RealityWatchService) Tick(ctx context.Context) {
|
||||
if !realityWatchTickMu.TryLock() {
|
||||
return
|
||||
}
|
||||
defer realityWatchTickMu.Unlock()
|
||||
realityWatchMu.Lock()
|
||||
cfg := s.loadConfig()
|
||||
realityWatchMu.Unlock()
|
||||
for id := range cfg {
|
||||
s.checkInbound(ctx, id)
|
||||
}
|
||||
}
|
||||
|
||||
// checkInbound skips node inbounds: their REALITY server runs on the node, so this server's
|
||||
// view says nothing about it.
|
||||
func (s *RealityWatchService) checkInbound(ctx context.Context, id int) {
|
||||
ib, err := s.inboundService.GetInbound(id)
|
||||
if err != nil || !ib.Enable || ib.NodeID != nil {
|
||||
return
|
||||
}
|
||||
rs, ok := realityOf(ib)
|
||||
if !ok || localRealityTarget(rs.Target) {
|
||||
return
|
||||
}
|
||||
res := realityWatchProbe(&s.serverService, rs.Target, firstString(rs.ServerNames), rs.Xver)
|
||||
// a domain that resolves into a private network: the SSRF guard blocked it, nothing failed
|
||||
if res.PrivateTarget {
|
||||
return
|
||||
}
|
||||
alive := realityTargetAlive(ctx, rs, res)
|
||||
|
||||
realityWatchMu.Lock()
|
||||
entry := s.loadConfig()[id]
|
||||
state := realityWatchStates[id]
|
||||
if state == nil {
|
||||
state = &realityWatchState{}
|
||||
realityWatchStates[id] = state
|
||||
}
|
||||
state.checkedAt, state.ok, state.reason, state.latencyMs = time.Now(), alive, res.Reason, res.LatencyMs
|
||||
if alive {
|
||||
state.fails = 0
|
||||
state.reason = ""
|
||||
realityWatchMu.Unlock()
|
||||
return
|
||||
}
|
||||
state.fails++
|
||||
due := entry.Auto && state.fails >= realityWatchFailLimit
|
||||
realityWatchMu.Unlock()
|
||||
if !due {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = s.switchInbound(ctx, id, rs, entry.Spares, res.Reason)
|
||||
switch {
|
||||
case err == nil:
|
||||
case errors.Is(err, errRealityWatchChanged):
|
||||
logger.Infof("reality watch: inbound %d changed during the check, not switching it", id)
|
||||
default:
|
||||
realityWatchMu.Lock()
|
||||
defer realityWatchMu.Unlock()
|
||||
// one "nothing works" line per outage, not one per check
|
||||
if n := len(state.events); n == 0 || state.events[n-1].To != "" {
|
||||
s.recordLocked(id, RealityWatchEvent{At: time.Now().Unix(), From: rs.Target, Reason: res.Reason})
|
||||
}
|
||||
logger.Warningf("reality watch: inbound %d target %s fails (%s) and no spare works", id, rs.Target, res.Reason)
|
||||
}
|
||||
}
|
||||
|
||||
// realityTargetAlive decides whether a target failed. The scanner's bar (h2, SNI on the cert) is
|
||||
// for choosing a target; one that misses it can still carry REALITY, so the real test decides.
|
||||
func realityTargetAlive(ctx context.Context, rs realitySettingsView, res *RealityScanResult) bool {
|
||||
if res.Feasible {
|
||||
return true
|
||||
}
|
||||
if !res.TLS13 {
|
||||
return false
|
||||
}
|
||||
target, err := normalizeRealityTarget(rs.Target)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
sni := firstString(rs.ServerNames)
|
||||
if sni == "" {
|
||||
sni, _, _ = net.SplitHostPort(target)
|
||||
}
|
||||
if err := realityWatchRealTest(ctx, target, sni); err != nil {
|
||||
logger.Infof("reality watch: %s fails a real REALITY connection: %v", target, err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// localRealityTarget is a target on this machine or the LAN: a bare port, a unix socket, or
|
||||
// a private / loopback address. The admin fronts REALITY with it on purpose; never replace it.
|
||||
func localRealityTarget(target string) bool {
|
||||
t := strings.TrimSpace(target)
|
||||
if t == "" || strings.HasPrefix(t, "/") || strings.HasPrefix(t, "@") {
|
||||
return true
|
||||
}
|
||||
if _, err := strconv.Atoi(t); err == nil {
|
||||
return true
|
||||
}
|
||||
host := t
|
||||
if h, _, err := net.SplitHostPort(t); err == nil {
|
||||
host = h
|
||||
}
|
||||
if strings.EqualFold(host, "localhost") {
|
||||
return true
|
||||
}
|
||||
ip := net.ParseIP(strings.Trim(host, "[]"))
|
||||
return ip != nil && (ip.IsLoopback() || ip.IsPrivate() || ip.IsLinkLocalUnicast() || ip.IsUnspecified())
|
||||
}
|
||||
|
||||
func firstString(list []string) string {
|
||||
if len(list) == 0 {
|
||||
return ""
|
||||
}
|
||||
return list[0]
|
||||
}
|
||||
|
||||
// SwitchTo moves an inbound to target now (the admin's button), after the same checks. A node
|
||||
// inbound is refused: both checks run here and say nothing about the node's network.
|
||||
func (s *RealityWatchService) SwitchTo(ctx context.Context, inboundId int, target string) (*RealityWatchEvent, error) {
|
||||
target, err := normalizeRealityTarget(target)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ib, err := s.inboundService.GetInbound(inboundId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ib.NodeID != nil {
|
||||
return nil, errRealityWatchOnNode
|
||||
}
|
||||
rs, ok := realityOf(ib)
|
||||
if !ok {
|
||||
return nil, errRealityWatchNotReality
|
||||
}
|
||||
ev, err := s.switchInbound(ctx, inboundId, rs, []string{target}, "")
|
||||
if errors.Is(err, errRealityWatchNoSpare) {
|
||||
return nil, errRealityWatchTargetFails
|
||||
}
|
||||
return ev, err
|
||||
}
|
||||
|
||||
// TestTarget runs the server check and the real REALITY connection on one target.
|
||||
func (s *RealityWatchService) TestTarget(ctx context.Context, target string) (*RealityScanResult, error) {
|
||||
target, err := normalizeRealityTarget(target)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
host, _, _ := net.SplitHostPort(target)
|
||||
res := realityWatchProbe(&s.serverService, target, host, 0)
|
||||
if res.Feasible {
|
||||
if err := realityWatchRealTest(ctx, target, host); err != nil {
|
||||
res.Feasible, res.Reason = false, "REALITY test failed: "+err.Error()
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// switchInbound tries candidates in order; the first that passes the server check and a real
|
||||
// REALITY connection becomes the target, with its host as the only SNI.
|
||||
func (s *RealityWatchService) switchInbound(ctx context.Context, inboundId int, rs realitySettingsView,
|
||||
candidates []string, reason string,
|
||||
) (*RealityWatchEvent, error) {
|
||||
for _, cand := range candidates {
|
||||
if cand == rs.Target {
|
||||
continue
|
||||
}
|
||||
host, _, err := net.SplitHostPort(cand)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if res := realityWatchProbe(&s.serverService, cand, host, rs.Xver); !res.Feasible {
|
||||
continue
|
||||
}
|
||||
if err := realityWatchRealTest(ctx, cand, host); err != nil {
|
||||
logger.Infof("reality watch: %s passes the TLS check but not a real REALITY connection: %v", cand, err)
|
||||
continue
|
||||
}
|
||||
return s.commitSwitch(inboundId, rs.Target, cand, host, reason)
|
||||
}
|
||||
return nil, errRealityWatchNoSpare
|
||||
}
|
||||
|
||||
// commitSwitch saves a fresh copy of the inbound, since the checks took long enough for an admin
|
||||
// to save an edit. A target changed meanwhile means the admin already chose; nothing is switched.
|
||||
func (s *RealityWatchService) commitSwitch(inboundId int, from, to, sni, reason string) (*RealityWatchEvent, error) {
|
||||
realityWatchMu.Lock()
|
||||
defer realityWatchMu.Unlock()
|
||||
ib, err := s.inboundService.GetInbound(inboundId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rs, ok := realityOf(ib)
|
||||
if !ok {
|
||||
return nil, errRealityWatchNotReality
|
||||
}
|
||||
if rs.Target != from {
|
||||
return nil, errRealityWatchChanged
|
||||
}
|
||||
if err := s.applyTarget(ib, to, sni); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// The inbound has moved, so a host failure must not lose the spares and history below.
|
||||
if err := s.hostService.MoveInboundSni(inboundId, rs.ServerNames, sni); err != nil {
|
||||
logger.Warningf("reality watch: inbound %d switched but its hosts keep the old SNI: %v", inboundId, err)
|
||||
}
|
||||
InvalidateSubData()
|
||||
|
||||
cfg := s.loadConfig()
|
||||
entry := cfg[inboundId]
|
||||
spares := []string{}
|
||||
for _, sp := range entry.Spares {
|
||||
if sp != to {
|
||||
spares = append(spares, sp)
|
||||
}
|
||||
}
|
||||
if old, err := normalizeRealityTarget(from); err == nil && !containsString(spares, old) {
|
||||
spares = append(spares, old)
|
||||
}
|
||||
entry.Spares = spares
|
||||
cfg[inboundId] = entry
|
||||
if err := s.storeConfig(cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ev := RealityWatchEvent{At: time.Now().Unix(), From: from, To: to, Reason: reason}
|
||||
s.recordLocked(inboundId, ev)
|
||||
realityWatchStates[inboundId].fails = 0
|
||||
logger.Warningf("reality watch: inbound %d switched from %s to %s", inboundId, from, to)
|
||||
return &ev, nil
|
||||
}
|
||||
|
||||
func (s *RealityWatchService) recordLocked(inboundId int, ev RealityWatchEvent) {
|
||||
state := realityWatchStates[inboundId]
|
||||
if state == nil {
|
||||
state = &realityWatchState{}
|
||||
realityWatchStates[inboundId] = state
|
||||
}
|
||||
state.events = append(state.events, ev)
|
||||
if len(state.events) > realityWatchMaxEvents {
|
||||
state.events = state.events[len(state.events)-realityWatchMaxEvents:]
|
||||
}
|
||||
}
|
||||
|
||||
// applyTarget rewrites only target and serverNames, keeping every other REALITY setting, and
|
||||
// saves through UpdateInbound so the change reaches Xray the same way an admin's edit does.
|
||||
func (s *RealityWatchService) applyTarget(ib *model.Inbound, target, sni string) error {
|
||||
var stream map[string]any
|
||||
if err := json.Unmarshal([]byte(ib.StreamSettings), &stream); err != nil {
|
||||
return err
|
||||
}
|
||||
rs, ok := stream["realitySettings"].(map[string]any)
|
||||
if !ok {
|
||||
return errRealityWatchNotReality
|
||||
}
|
||||
delete(rs, "dest")
|
||||
rs["target"] = target
|
||||
rs["serverNames"] = []string{sni}
|
||||
b, err := json.Marshal(stream)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ib.StreamSettings = string(b)
|
||||
_, needRestart, err := s.inboundService.UpdateInbound(ib)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if needRestart {
|
||||
s.xrayService.SetToNeedRestart()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,498 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/database"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
||||
)
|
||||
|
||||
// stubRealityWatch makes probe answer from feasible (target -> ok) and the real test from
|
||||
// works; both record what they were asked so a test can tell what was tried.
|
||||
func stubRealityWatch(t *testing.T, feasible, works map[string]bool) *[]string {
|
||||
t.Helper()
|
||||
var tried []string
|
||||
prevProbe, prevReal := realityWatchProbe, realityWatchRealTest
|
||||
realityWatchProbe = func(_ *ServerService, target, _ string, _ int) *RealityScanResult {
|
||||
if feasible[target] {
|
||||
return &RealityScanResult{Target: target, Feasible: true}
|
||||
}
|
||||
return &RealityScanResult{Target: target, Reason: "TLS handshake failed: EOF"}
|
||||
}
|
||||
realityWatchRealTest = func(_ context.Context, target, _ string) error {
|
||||
tried = append(tried, target)
|
||||
if works[target] {
|
||||
return nil
|
||||
}
|
||||
return errors.New("no reply through REALITY")
|
||||
}
|
||||
resetRealityWatchState()
|
||||
t.Cleanup(func() {
|
||||
realityWatchProbe, realityWatchRealTest = prevProbe, prevReal
|
||||
resetRealityWatchState()
|
||||
})
|
||||
return &tried
|
||||
}
|
||||
|
||||
func realityInbound(t *testing.T, port int, target, sni string) *model.Inbound {
|
||||
t.Helper()
|
||||
stream := `{"network":"tcp","security":"reality","realitySettings":{"show":false,"xver":0,"target":"` +
|
||||
target + `","serverNames":["` + sni + `"],"privateKey":"k","shortIds":["ab"]}}`
|
||||
return mkInboundStream(t, port, model.VLESS, `{"clients":[],"decryption":"none"}`, stream)
|
||||
}
|
||||
|
||||
func realityTargetOf(t *testing.T, id int) (string, []string) {
|
||||
t.Helper()
|
||||
ib, err := (&InboundService{}).GetInbound(id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var stream struct {
|
||||
RealitySettings struct {
|
||||
Target string `json:"target"`
|
||||
ServerNames []string `json:"serverNames"`
|
||||
PrivateKey string `json:"privateKey"`
|
||||
} `json:"realitySettings"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(ib.StreamSettings), &stream); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if stream.RealitySettings.PrivateKey != "k" {
|
||||
t.Fatalf("switch lost the other REALITY settings: %s", ib.StreamSettings)
|
||||
}
|
||||
return stream.RealitySettings.Target, stream.RealitySettings.ServerNames
|
||||
}
|
||||
|
||||
// A single failure is often a blip, and a switch moves every client to a new SNI, so only the
|
||||
// third failed check in a row switches, and only to a spare that passed both checks.
|
||||
func TestRealityWatchSwitchesAfterThreeFailedChecks(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
tried := stubRealityWatch(t,
|
||||
map[string]bool{"b.example:443": true, "c.example:443": true},
|
||||
map[string]bool{"b.example:443": false, "c.example:443": true})
|
||||
ib := realityInbound(t, 4431, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Auto: true, Spares: []string{"b.example", "c.example:443"}}); err != nil {
|
||||
t.Fatalf("SaveConfig: %v", err)
|
||||
}
|
||||
|
||||
for check := 1; check <= 2; check++ {
|
||||
s.Tick(context.Background())
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "a.example:443" {
|
||||
t.Fatalf("after %d failed checks target = %s, want it kept", check, target)
|
||||
}
|
||||
}
|
||||
s.Tick(context.Background())
|
||||
target, names := realityTargetOf(t, ib.Id)
|
||||
if target != "c.example:443" || !reflect.DeepEqual(names, []string{"c.example"}) {
|
||||
t.Fatalf("after the third failed check target = %s %v, want c.example:443 [c.example]", target, names)
|
||||
}
|
||||
if !reflect.DeepEqual(*tried, []string{"b.example:443", "c.example:443"}) {
|
||||
t.Errorf("real-tested %v, want b (failed) then c", *tried)
|
||||
}
|
||||
st := s.Status(ib.Id)
|
||||
if !reflect.DeepEqual(st.Spares, []string{"b.example:443", "a.example:443"}) {
|
||||
t.Errorf("spares after the switch = %v, want b kept and the old target last", st.Spares)
|
||||
}
|
||||
if len(st.Events) != 1 || st.Events[0].From != "a.example:443" || st.Events[0].To != "c.example:443" {
|
||||
t.Errorf("events = %+v, want one switch a -> c", st.Events)
|
||||
}
|
||||
}
|
||||
|
||||
// With no spare that works the inbound must stay as it is: a switch would only trade a
|
||||
// broken target for another broken one. The outage is logged once, not every check.
|
||||
func TestRealityWatchKeepsTheTargetWhenNoSpareWorks(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true}, nil)
|
||||
ib := realityInbound(t, 4432, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Auto: true, Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for range 5 {
|
||||
s.Tick(context.Background())
|
||||
}
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "a.example:443" {
|
||||
t.Fatalf("target = %s, want a.example:443 kept", target)
|
||||
}
|
||||
st := s.Status(ib.Id)
|
||||
if st.Fails != 5 || len(st.Events) != 1 || st.Events[0].To != "" {
|
||||
t.Fatalf("fails %d, events %+v; want 5 fails and one 'no spare works' event", st.Fails, st.Events)
|
||||
}
|
||||
}
|
||||
|
||||
// A good check in between starts the count again; auto off and node inbounds never switch.
|
||||
func TestRealityWatchOnlySwitchesSustainedFailuresItOwns(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
feasible := map[string]bool{"b.example:443": true}
|
||||
stubRealityWatch(t, feasible, map[string]bool{"b.example:443": true})
|
||||
ib := realityInbound(t, 4433, "a.example:443", "a.example")
|
||||
manual := realityInbound(t, 4434, "a.example:443", "a.example")
|
||||
node := realityInbound(t, 4435, "a.example:443", "a.example")
|
||||
nodeID := 7
|
||||
if err := database.GetDB().Model(&model.Inbound{}).Where("id = ?", node.Id).Update("node_id", nodeID).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := &RealityWatchService{}
|
||||
for id, auto := range map[int]bool{ib.Id: true, manual.Id: false, node.Id: true} {
|
||||
if err := s.SaveConfig(id, RealityWatchEntry{Auto: auto, Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
s.Tick(context.Background())
|
||||
s.Tick(context.Background())
|
||||
feasible["a.example:443"] = true
|
||||
s.Tick(context.Background())
|
||||
delete(feasible, "a.example:443")
|
||||
s.Tick(context.Background())
|
||||
s.Tick(context.Background())
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "a.example:443" {
|
||||
t.Fatalf("2 fails, ok, 2 fails switched to %s; the good check must reset the count", target)
|
||||
}
|
||||
s.Tick(context.Background())
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
id int
|
||||
want string
|
||||
}{{"auto", ib.Id, "b.example:443"}, {"auto off", manual.Id, "a.example:443"}, {"node inbound", node.Id, "a.example:443"}} {
|
||||
if target, _ := realityTargetOf(t, tc.id); target != tc.want {
|
||||
t.Errorf("%s: target = %s, want %s", tc.name, target, tc.want)
|
||||
}
|
||||
}
|
||||
if st := s.Status(manual.Id); st.Fails != 3 {
|
||||
t.Errorf("auto off still shows the checks: fails = %d, want 3 since the good one", st.Fails)
|
||||
}
|
||||
if st := s.Status(node.Id); st.Fails != 0 || st.CheckedAt != 0 {
|
||||
t.Errorf("node inbound was checked from this server (fails %d); its REALITY runs on the node", st.Fails)
|
||||
}
|
||||
}
|
||||
|
||||
// The admin's switch button goes through the same real test: a spare that fails it is refused.
|
||||
func TestRealityWatchManualSwitchNeedsTheRealTest(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true, "c.example:443": true},
|
||||
map[string]bool{"c.example:443": true})
|
||||
ib := realityInbound(t, 4436, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{"b.example:443", "c.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.SwitchTo(context.Background(), ib.Id, "b.example:443"); !errors.Is(err, errRealityWatchTargetFails) {
|
||||
t.Fatalf("switch to a spare failing the real test: err = %v, want errRealityWatchTargetFails", err)
|
||||
}
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "a.example:443" {
|
||||
t.Fatalf("refused switch still changed the target to %s", target)
|
||||
}
|
||||
if ev, err := s.SwitchTo(context.Background(), ib.Id, "c.example:443"); err != nil || ev.To != "c.example:443" {
|
||||
t.Fatalf("switch to c: %+v, %v", ev, err)
|
||||
}
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "c.example:443" {
|
||||
t.Fatalf("target = %s, want c.example:443", target)
|
||||
}
|
||||
// the editor fills its form from this, or its Save would put the old target back
|
||||
if st := s.Status(ib.Id); st.Target != "c.example:443" || !reflect.DeepEqual(st.ServerNames, []string{"c.example"}) {
|
||||
t.Errorf("status after the switch: target %s names %v", st.Target, st.ServerNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealityWatchSaveConfigNormalizesSpares(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, nil, nil)
|
||||
ib := realityInbound(t, 4437, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{" B.example ", "b.example:443", "c.example:8443", "a.example:443"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := s.Status(ib.Id).Spares; !reflect.DeepEqual(got, []string{"b.example:443", "c.example:8443"}) {
|
||||
t.Errorf("spares = %v, want lower-cased, :443 added, repeats and the current target dropped", got)
|
||||
}
|
||||
for _, bad := range []string{"not a host", "a.example:99999", `x"; rm`} {
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{bad}}); !errors.Is(err, errRealityWatchBadSpare) {
|
||||
t.Errorf("spare %q: err = %v, want errRealityWatchBadSpare", bad, err)
|
||||
}
|
||||
}
|
||||
plain := mkInboundStream(t, 4438, model.VLESS, `{"clients":[]}`, `{"network":"tcp","security":"tls"}`)
|
||||
if err := s.SaveConfig(plain.Id, RealityWatchEntry{Auto: true}); !errors.Is(err, errRealityWatchNotReality) {
|
||||
t.Errorf("watch on a TLS inbound: err = %v, want errRealityWatchNotReality", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A target on this machine or the LAN (a local web server fronting REALITY, a bare port, a
|
||||
// unix socket) is blocked by the probe's SSRF guard; that is not a failure to act on.
|
||||
func TestRealityWatchLeavesLocalTargetsAlone(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true}, map[string]bool{"b.example:443": true})
|
||||
prev := realityWatchProbe
|
||||
realityWatchProbe = func(s *ServerService, target, sni string, xver int) *RealityScanResult {
|
||||
if target == "local.example:443" {
|
||||
return &RealityScanResult{Target: target, PrivateTarget: true, Reason: "connection failed: private address blocked"}
|
||||
}
|
||||
return prev(s, target, sni, xver)
|
||||
}
|
||||
s := &RealityWatchService{}
|
||||
var ids []int
|
||||
for i, target := range []string{"127.0.0.1:8443", "8443", "/run/web.sock", "local.example:443"} {
|
||||
ib := realityInbound(t, 4440+i, target, "a.example")
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Auto: true, Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatalf("SaveConfig(%s): %v", target, err)
|
||||
}
|
||||
ids = append(ids, ib.Id)
|
||||
}
|
||||
for range 4 {
|
||||
s.Tick(context.Background())
|
||||
}
|
||||
for _, id := range ids {
|
||||
target, _ := realityTargetOf(t, id)
|
||||
if target == "b.example:443" || s.Status(id).Fails != 0 {
|
||||
t.Errorf("local target %s: switched or counted as failing (fails %d)", target, s.Status(id).Fails)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// duringRealTest runs edit while the spare's real test is in flight, the slow part of a switch.
|
||||
func duringRealTest(t *testing.T, edit func()) {
|
||||
t.Helper()
|
||||
prev := realityWatchRealTest
|
||||
realityWatchRealTest = func(ctx context.Context, target, sni string) error {
|
||||
edit()
|
||||
return prev(ctx, target, sni)
|
||||
}
|
||||
t.Cleanup(func() { realityWatchRealTest = prev })
|
||||
}
|
||||
|
||||
// A switch used to save the copy read before its checks, wiping what the admin saved meanwhile.
|
||||
func TestRealityWatchSwitchKeepsAnEditSavedDuringTheCheck(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true}, map[string]bool{"b.example:443": true})
|
||||
ib := realityInbound(t, 4441, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
duringRealTest(t, func() {
|
||||
if err := database.GetDB().Model(&model.Inbound{}).Where("id = ?", ib.Id).Update("remark", "edited").Error; err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
if _, err := s.SwitchTo(context.Background(), ib.Id, "b.example:443"); err != nil {
|
||||
t.Fatalf("SwitchTo: %v", err)
|
||||
}
|
||||
got, err := (&InboundService{}).GetInbound(ib.Id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.Remark != "edited" {
|
||||
t.Errorf("remark = %q, the switch overwrote the admin's edit", got.Remark)
|
||||
}
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "b.example:443" {
|
||||
t.Errorf("target = %s, want b.example:443", target)
|
||||
}
|
||||
}
|
||||
|
||||
// An admin who fixes the target by hand mid-check has decided; the watcher must not override it.
|
||||
func TestRealityWatchDoesNotSwitchATargetTheAdminJustChanged(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true}, map[string]bool{"b.example:443": true})
|
||||
ib := realityInbound(t, 4442, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Auto: true, Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.Tick(context.Background())
|
||||
s.Tick(context.Background())
|
||||
duringRealTest(t, func() {
|
||||
cur, err := (&InboundService{}).GetInbound(ib.Id)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
stream := strings.ReplaceAll(cur.StreamSettings, "a.example", "admin.example")
|
||||
if err := database.GetDB().Model(&model.Inbound{}).Where("id = ?", ib.Id).Update("stream_settings", stream).Error; err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
s.Tick(context.Background())
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "admin.example:443" {
|
||||
t.Errorf("target = %s, the watcher replaced the admin's choice", target)
|
||||
}
|
||||
st := s.Status(ib.Id)
|
||||
if !reflect.DeepEqual(st.Spares, []string{"b.example:443"}) {
|
||||
t.Errorf("spares = %v, want them untouched", st.Spares)
|
||||
}
|
||||
if len(st.Events) != 0 {
|
||||
t.Errorf("events = %+v, want none: nothing switched and a spare did pass", st.Events)
|
||||
}
|
||||
}
|
||||
|
||||
// Checks take up to 10 s per probe and 25 s per real test; the watch API must answer meanwhile.
|
||||
func TestRealityWatchApiAnswersDuringACheck(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, nil, nil)
|
||||
ib := realityInbound(t, 4443, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
prev := realityWatchProbe
|
||||
t.Cleanup(func() { realityWatchProbe = prev })
|
||||
realityWatchProbe = func(sv *ServerService, target, sni string, xver int) *RealityScanResult {
|
||||
answered := make(chan struct{})
|
||||
go func() {
|
||||
s.Status(ib.Id)
|
||||
close(answered)
|
||||
}()
|
||||
select {
|
||||
case <-answered:
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Error("Status blocked behind a running check")
|
||||
}
|
||||
return prev(sv, target, sni, xver)
|
||||
}
|
||||
s.Tick(context.Background())
|
||||
}
|
||||
|
||||
// With the lock no longer held across checks, a slow cycle must not double-count failures.
|
||||
func TestRealityWatchTicksDoNotOverlap(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, nil, nil)
|
||||
ib := realityInbound(t, 4444, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
prev := realityWatchProbe
|
||||
t.Cleanup(func() { realityWatchProbe = prev })
|
||||
calls := 0
|
||||
realityWatchProbe = func(sv *ServerService, target, sni string, xver int) *RealityScanResult {
|
||||
calls++
|
||||
if calls == 1 {
|
||||
nested := make(chan struct{})
|
||||
go func() {
|
||||
s.Tick(context.Background())
|
||||
close(nested)
|
||||
}()
|
||||
select {
|
||||
case <-nested:
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Error("the overlapping tick waited instead of returning at once")
|
||||
}
|
||||
}
|
||||
return prev(sv, target, sni, xver)
|
||||
}
|
||||
s.Tick(context.Background())
|
||||
if calls != 1 {
|
||||
t.Errorf("target probed %d times, want the overlapping tick to do nothing", calls)
|
||||
}
|
||||
if st := s.Status(ib.Id); st.Fails != 1 {
|
||||
t.Errorf("fails = %d, want 1", st.Fails)
|
||||
}
|
||||
}
|
||||
|
||||
// Missing the scanner's bar (no h2, SNI not on the cert) does not mean REALITY is broken: only
|
||||
// a target with no TLS 1.3, or one failing the real connection, counts as a failed check.
|
||||
func TestRealityWatchRealTestJudgesATargetTheScannerDislikes(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
worksNow bool
|
||||
tls13 bool
|
||||
wantFails int
|
||||
wantOk bool
|
||||
}{
|
||||
{"works through REALITY", true, true, 0, true},
|
||||
{"fails through REALITY", false, true, 1, false},
|
||||
{"no TLS 1.3", true, false, 1, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, nil, map[string]bool{"a.example:443": tc.worksNow})
|
||||
prev := realityWatchProbe
|
||||
t.Cleanup(func() { realityWatchProbe = prev })
|
||||
realityWatchProbe = func(_ *ServerService, target, _ string, _ int) *RealityScanResult {
|
||||
return &RealityScanResult{Target: target, TLS13: tc.tls13, Reason: "server does not negotiate HTTP/2 (h2)"}
|
||||
}
|
||||
ib := realityInbound(t, 4445, "a.example:443", "a.example")
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.Tick(context.Background())
|
||||
st := s.Status(ib.Id)
|
||||
if st.Fails != tc.wantFails || st.Ok != tc.wantOk {
|
||||
t.Errorf("fails = %d ok = %v, want %d %v", st.Fails, st.Ok, tc.wantFails, tc.wantOk)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A Host's own SNI overrides serverNames in links, so a stale one keeps clients cut off after
|
||||
// a switch. Only rows of this inbound that use REALITY and pin one of its old names may change.
|
||||
func TestRealityWatchSwitchMovesHostSnis(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true}, map[string]bool{"b.example:443": true})
|
||||
ib := realityInbound(t, 4446, "a.example:443", "a.example")
|
||||
other := realityInbound(t, 4447, "a.example:443", "a.example")
|
||||
rows := []*model.Host{
|
||||
{InboundId: ib.Id, Remark: "pinned", Security: "same", Sni: "a.example"},
|
||||
{InboundId: ib.Id, Remark: "pool", Security: "reality", Sni: "a.example", Snis: []string{"a.example", "custom.example"}},
|
||||
{InboundId: ib.Id, Remark: "custom", Security: "same", Sni: "custom.example"},
|
||||
{InboundId: ib.Id, Remark: "tls", Security: "tls", Sni: "a.example"},
|
||||
{InboundId: other.Id, Remark: "other", Security: "same", Sni: "a.example"},
|
||||
}
|
||||
if err := database.GetDB().Create(&rows).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := &RealityWatchService{}
|
||||
if err := s.SaveConfig(ib.Id, RealityWatchEntry{Spares: []string{"b.example:443"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.SwitchTo(context.Background(), ib.Id, "b.example:443"); err != nil {
|
||||
t.Fatalf("SwitchTo: %v", err)
|
||||
}
|
||||
want := map[string]struct {
|
||||
sni string
|
||||
snis []string
|
||||
}{
|
||||
"pinned": {sni: "b.example"},
|
||||
"pool": {sni: "b.example", snis: []string{"b.example", "custom.example"}},
|
||||
"custom": {sni: "custom.example"},
|
||||
"tls": {sni: "a.example"},
|
||||
"other": {sni: "a.example"},
|
||||
}
|
||||
var got []model.Host
|
||||
if err := database.GetDB().Find(&got).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, h := range got {
|
||||
w := want[h.Remark]
|
||||
if h.Sni != w.sni || !slices.Equal(h.Snis, w.snis) {
|
||||
t.Errorf("host %s: sni %q snis %v, want %q %v", h.Remark, h.Sni, h.Snis, w.sni, w.snis)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The UI disables the button for node inbounds because this server's tests say nothing about
|
||||
// the node's network; the API must hold the same line.
|
||||
func TestRealityWatchManualSwitchRefusesANodeInbound(t *testing.T) {
|
||||
setupBulkDB(t)
|
||||
stubRealityWatch(t, map[string]bool{"b.example:443": true}, map[string]bool{"b.example:443": true})
|
||||
ib := realityInbound(t, 4448, "a.example:443", "a.example")
|
||||
if err := database.GetDB().Model(&model.Inbound{}).Where("id = ?", ib.Id).Update("node_id", 7).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := &RealityWatchService{}
|
||||
if _, err := s.SwitchTo(context.Background(), ib.Id, "b.example:443"); !errors.Is(err, errRealityWatchOnNode) {
|
||||
t.Fatalf("err = %v, want errRealityWatchOnNode", err)
|
||||
}
|
||||
if target, _ := realityTargetOf(t, ib.Id); target != "a.example:443" {
|
||||
t.Errorf("target = %s, want it kept", target)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdh"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/xray"
|
||||
)
|
||||
|
||||
const realityRealTestTimeout = 25 * time.Second
|
||||
|
||||
var realityRealTestBinary = xray.GetBinaryPath
|
||||
|
||||
// xrayRealityRealTest fetches https://sni/ through a throwaway REALITY server and client on
|
||||
// loopback: some sites pass TLS 1.3 + h2 but break REALITY's handshake, cutting every client.
|
||||
func xrayRealityRealTest(ctx context.Context, target, sni string) error {
|
||||
bin := realityRealTestBinary()
|
||||
if _, err := os.Stat(bin); err != nil {
|
||||
return fmt.Errorf("xray binary: %w", err)
|
||||
}
|
||||
priv, err := ecdh.X25519().GenerateKey(rand.Reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
privKey := base64.RawURLEncoding.EncodeToString(priv.Bytes())
|
||||
pubKey := base64.RawURLEncoding.EncodeToString(priv.PublicKey().Bytes())
|
||||
id := uuid.NewString()
|
||||
serverPort, err := realityTestPort(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
socksPort, err := realityTestPort(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dir, err := os.MkdirTemp("", "xui-reality-test-")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
server := map[string]any{
|
||||
"log": map[string]any{"loglevel": "none"},
|
||||
"inbounds": []any{map[string]any{
|
||||
"listen": "127.0.0.1", "port": serverPort, "protocol": "vless",
|
||||
"settings": map[string]any{"clients": []any{map[string]any{"id": id}}, "decryption": "none"},
|
||||
"streamSettings": map[string]any{"network": "tcp", "security": "reality", "realitySettings": map[string]any{
|
||||
"target": target, "serverNames": []string{sni}, "privateKey": privKey, "shortIds": []string{"a1"},
|
||||
}},
|
||||
}},
|
||||
"outbounds": []any{map[string]any{"protocol": "freedom"}},
|
||||
}
|
||||
client := map[string]any{
|
||||
"log": map[string]any{"loglevel": "none"},
|
||||
"inbounds": []any{map[string]any{"listen": "127.0.0.1", "port": socksPort, "protocol": "socks", "settings": map[string]any{"udp": false}}},
|
||||
"outbounds": []any{map[string]any{
|
||||
"protocol": "vless",
|
||||
"settings": map[string]any{"vnext": []any{map[string]any{
|
||||
"address": "127.0.0.1", "port": serverPort,
|
||||
"users": []any{map[string]any{"id": id, "encryption": "none"}},
|
||||
}}},
|
||||
"streamSettings": map[string]any{"network": "tcp", "security": "reality", "realitySettings": map[string]any{
|
||||
"serverName": sni, "fingerprint": "chrome", "publicKey": pubKey, "shortId": "a1",
|
||||
}},
|
||||
}},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, realityRealTestTimeout)
|
||||
defer cancel()
|
||||
for name, cfg := range map[string]any{"server.json": server, "client.json": client} {
|
||||
b, _ := json.Marshal(cfg)
|
||||
path := filepath.Join(dir, name)
|
||||
if err := os.WriteFile(path, b, 0o600); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, bin, "run", "-c", path)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = cmd.Process.Kill(); _ = cmd.Wait() }()
|
||||
}
|
||||
socks := "127.0.0.1:" + strconv.Itoa(socksPort)
|
||||
for !portOpen(ctx, socks) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return errors.New("throwaway xray did not start")
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
httpClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(&url.URL{Scheme: "socks5", Host: socks})}}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://"+net.JoinHostPort(sni, "443")+"/", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("no reply through REALITY: %w", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func realityTestPort(ctx context.Context) (int, error) {
|
||||
l, err := (&net.ListenConfig{}).Listen(ctx, "tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer l.Close()
|
||||
return l.Addr().(*net.TCPAddr).Port, nil
|
||||
}
|
||||
|
||||
func portOpen(ctx context.Context, addr string) bool {
|
||||
c, err := (&net.Dialer{Timeout: 200 * time.Millisecond}).DialContext(ctx, "tcp", addr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
c.Close()
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The real test is the gate before every switch: it must pass on a site REALITY works with
|
||||
// and fail when the target is unreachable. Needs an xray binary and internet:
|
||||
//
|
||||
// XRAY_E2E_BINARY=/usr/local/x-ui/bin/xray-linux-amd64 go test ./internal/web/service -run TestRealityRealTestAgainstRealXray
|
||||
func TestRealityRealTestAgainstRealXray(t *testing.T) {
|
||||
bin := os.Getenv("XRAY_E2E_BINARY")
|
||||
if bin == "" {
|
||||
t.Skip("XRAY_E2E_BINARY not set")
|
||||
}
|
||||
prev := realityRealTestBinary
|
||||
realityRealTestBinary = func() string { return bin }
|
||||
t.Cleanup(func() { realityRealTestBinary = prev })
|
||||
|
||||
target := os.Getenv("REALITY_E2E_TARGET")
|
||||
if target == "" {
|
||||
target = "www.speedtest.net"
|
||||
}
|
||||
if err := xrayRealityRealTest(context.Background(), target+":443", target); err != nil {
|
||||
t.Fatalf("REALITY through %s: %v; want a reply", target, err)
|
||||
}
|
||||
if err := xrayRealityRealTest(context.Background(), "127.0.0.1:1", target); err == nil {
|
||||
t.Fatal("REALITY with an unreachable target passed; want an error")
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,7 @@ var defaultValueMap = map[string]string{
|
||||
"publicIpv6Override": "",
|
||||
"trustedProxyCIDRs": DefaultTrustedProxyCIDRs,
|
||||
"realityScanCandidates": DefaultRealityScanCandidatesCSV,
|
||||
"realityWatch": "{}",
|
||||
"ipLimitAllowlist": "",
|
||||
"pageSize": "25",
|
||||
"expireDiff": "0",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "تكوين Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "تجاوز الوجهة",
|
||||
"advancedTitle": "الإعدادات المتقدمة"
|
||||
"advancedTitle": "الإعدادات المتقدمة",
|
||||
"realityWatch": {
|
||||
"title": "إبقاء REALITY يعمل",
|
||||
"savedWithInbound": "تُحفظ مع الوارد نفسه.",
|
||||
"hint": "يفحص هذا الخادم الهدف كل 10 دقائق. بعد {limit} فحوص فاشلة متتالية، ينتقل الوارد إلى أول هدف احتياطي يجتاز الفحص نفسه واتصال REALITY حقيقيًا عبر Xray مؤقت. يتغير الهدف وSNI فقط؛ يحصل العملاء على SNI الجديد مع تحديث الاشتراك التالي.",
|
||||
"onNode": "يعمل هذا الوارد على عقدة، لذا لا يمكن لهذا الخادم فحص هدفه أو تبديله.",
|
||||
"status": "الحالة",
|
||||
"notChecked": "لم يُفحص بعد",
|
||||
"failing": "معطّل ({fails} من {limit})",
|
||||
"working": "يعمل",
|
||||
"auto": "استبدال تلقائي",
|
||||
"spares": "أهداف احتياطية",
|
||||
"noSpares": "لا توجد أهداف احتياطية: أضف بعضها عبر «بحث عن احتياطي»",
|
||||
"realTest": "اختبار حقيقي",
|
||||
"testOk": "يعمل",
|
||||
"testFailed": "لا يعمل",
|
||||
"test": "اختبار",
|
||||
"testAll": "اختبار الكل",
|
||||
"switchNow": "التبديل إليه الآن",
|
||||
"findSpares": "بحث عن احتياطي",
|
||||
"save": "حفظ الاحتياطيات",
|
||||
"history": "السجل",
|
||||
"eventSwitched": "{from} ← {to}",
|
||||
"eventNoSpare": "تعطّل {from} ولم يعمل أي احتياطي",
|
||||
"toasts": {
|
||||
"saved": "تم حفظ الاحتياطيات",
|
||||
"failed": "تعذّر حفظ الاحتياطيات",
|
||||
"switchFailed": "تعذّر التبديل: فشل الهدف في الفحص أو في اختبار REALITY الحقيقي",
|
||||
"switched": "تم التبديل إلى {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "أساسي",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumber": "Peer {n}",
|
||||
"peerNumberConfig": "Peer {n} config"
|
||||
},
|
||||
"sniffingDestOverride": "Destination override"
|
||||
"sniffingDestOverride": "Destination override",
|
||||
"realityWatch": {
|
||||
"title": "Keep REALITY working",
|
||||
"savedWithInbound": "They are saved together with the inbound.",
|
||||
"hint": "Every 10 minutes this server checks the target. After {limit} failed checks in a row, the inbound moves to the first spare that passes the same check and a real REALITY connection through a temporary Xray. Only the target and SNI change; clients get the new SNI with their next subscription update.",
|
||||
"onNode": "This inbound runs on a node, so this server cannot check or switch its target.",
|
||||
"status": "Status",
|
||||
"notChecked": "not checked yet",
|
||||
"failing": "failing ({fails} of {limit})",
|
||||
"working": "working",
|
||||
"auto": "Replace automatically",
|
||||
"spares": "Spare targets",
|
||||
"noSpares": "No spares yet: add some with Find spares",
|
||||
"realTest": "Real test",
|
||||
"testOk": "works",
|
||||
"testFailed": "fails",
|
||||
"test": "Test",
|
||||
"testAll": "Test all",
|
||||
"switchNow": "Switch to this now",
|
||||
"findSpares": "Find spares",
|
||||
"save": "Save spares",
|
||||
"history": "History",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} failed and no spare worked",
|
||||
"toasts": {
|
||||
"saved": "Spares saved",
|
||||
"failed": "Could not save the spares",
|
||||
"switchFailed": "Could not switch: the target failed the check or the real REALITY test",
|
||||
"switched": "Switched to {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Basics",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Config Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Anulación de destino",
|
||||
"advancedTitle": "Configuración avanzada"
|
||||
"advancedTitle": "Configuración avanzada",
|
||||
"realityWatch": {
|
||||
"title": "Mantener REALITY funcionando",
|
||||
"savedWithInbound": "Se guardan junto con la entrada.",
|
||||
"hint": "Cada 10 minutos este servidor comprueba el destino. Tras {limit} comprobaciones fallidas seguidas, el inbound pasa a la primera reserva que supere la misma comprobación y una conexión REALITY real a través de un Xray temporal. Solo cambian el destino y el SNI; los clientes reciben el nuevo SNI con la próxima actualización de la suscripción.",
|
||||
"onNode": "Este inbound se ejecuta en un nodo, así que este servidor no puede comprobar ni cambiar su destino.",
|
||||
"status": "Estado",
|
||||
"notChecked": "aún sin comprobar",
|
||||
"failing": "fallando ({fails} de {limit})",
|
||||
"working": "funciona",
|
||||
"auto": "Reemplazar automáticamente",
|
||||
"spares": "Destinos de reserva",
|
||||
"noSpares": "Aún no hay reservas: añade algunas con Buscar reservas",
|
||||
"realTest": "Prueba real",
|
||||
"testOk": "funciona",
|
||||
"testFailed": "falla",
|
||||
"test": "Probar",
|
||||
"testAll": "Probar todos",
|
||||
"switchNow": "Cambiar a este ahora",
|
||||
"findSpares": "Buscar reservas",
|
||||
"save": "Guardar reservas",
|
||||
"history": "Historial",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} falló y ninguna reserva funcionó",
|
||||
"toasts": {
|
||||
"saved": "Reservas guardadas",
|
||||
"failed": "No se pudieron guardar las reservas",
|
||||
"switchFailed": "No se pudo cambiar: el destino no superó la comprobación o la prueba REALITY real",
|
||||
"switched": "Cambiado a {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Básico",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "پیکربندی Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "بازنویسی مقصد",
|
||||
"advancedTitle": "تنظیمات پیشرفته"
|
||||
"advancedTitle": "تنظیمات پیشرفته",
|
||||
"realityWatch": {
|
||||
"title": "زنده نگه داشتن REALITY",
|
||||
"savedWithInbound": "اینها همراه با خود اینباند ذخیره میشوند.",
|
||||
"hint": "این سرور هر ۱۰ دقیقه تارگت را بررسی میکند. بعد از {limit} بررسی ناموفق پشت سر هم، اینباند به اولین یدکی میرود که همان بررسی و یک اتصال واقعی REALITY از طریق یک Xray موقت را رد کند. فقط تارگت و SNI عوض میشوند؛ کلاینتها SNI جدید را با بهروزرسانی بعدی ساباسکریپشن میگیرند.",
|
||||
"onNode": "این اینباند روی یک نود اجرا میشود، پس این سرور نمیتواند هدف آن را بررسی یا تعویض کند.",
|
||||
"status": "وضعیت",
|
||||
"notChecked": "هنوز بررسی نشده",
|
||||
"failing": "خراب ({fails} از {limit})",
|
||||
"working": "کار میکند",
|
||||
"auto": "جایگزینی خودکار",
|
||||
"spares": "تارگتهای یدک",
|
||||
"noSpares": "هنوز یدکی نیست: با «پیدا کردن یدک» اضافه کنید",
|
||||
"realTest": "تست واقعی",
|
||||
"testOk": "کار میکند",
|
||||
"testFailed": "کار نمیکند",
|
||||
"test": "تست",
|
||||
"testAll": "تست همه",
|
||||
"switchNow": "همین الان جایگزین شود",
|
||||
"findSpares": "پیدا کردن یدک",
|
||||
"save": "ذخیرهٔ یدکها",
|
||||
"history": "تاریخچه",
|
||||
"eventSwitched": "{from} ← {to}",
|
||||
"eventNoSpare": "{from} خراب شد و هیچ یدکی کار نکرد",
|
||||
"toasts": {
|
||||
"saved": "یدکها ذخیره شدند",
|
||||
"failed": "ذخیرهٔ یدکها ممکن نشد",
|
||||
"switchFailed": "تعویض ممکن نشد: تارگت بررسی یا تست واقعی REALITY را رد نکرد",
|
||||
"switched": "به {target} تعویض شد"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "پایه",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Konfig Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Penggantian tujuan",
|
||||
"advancedTitle": "Pengaturan Lanjutan"
|
||||
"advancedTitle": "Pengaturan Lanjutan",
|
||||
"realityWatch": {
|
||||
"title": "Jaga REALITY tetap jalan",
|
||||
"savedWithInbound": "Semua ini disimpan bersama inbound.",
|
||||
"hint": "Setiap 10 menit server ini memeriksa target. Setelah {limit} pemeriksaan gagal berturut-turut, inbound pindah ke cadangan pertama yang lolos pemeriksaan yang sama dan koneksi REALITY sungguhan melalui Xray sementara. Hanya target dan SNI yang berubah; klien mendapat SNI baru pada pembaruan langganan berikutnya.",
|
||||
"onNode": "Inbound ini berjalan di node, jadi server ini tidak dapat memeriksa atau mengganti targetnya.",
|
||||
"status": "Status",
|
||||
"notChecked": "belum diperiksa",
|
||||
"failing": "gagal ({fails} dari {limit})",
|
||||
"working": "berjalan",
|
||||
"auto": "Ganti otomatis",
|
||||
"spares": "Target cadangan",
|
||||
"noSpares": "Belum ada cadangan: tambahkan dengan Cari cadangan",
|
||||
"realTest": "Tes nyata",
|
||||
"testOk": "berhasil",
|
||||
"testFailed": "gagal",
|
||||
"test": "Tes",
|
||||
"testAll": "Tes semua",
|
||||
"switchNow": "Ganti ke ini sekarang",
|
||||
"findSpares": "Cari cadangan",
|
||||
"save": "Simpan cadangan",
|
||||
"history": "Riwayat",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} gagal dan tidak ada cadangan yang berhasil",
|
||||
"toasts": {
|
||||
"saved": "Cadangan disimpan",
|
||||
"failed": "Tidak bisa menyimpan cadangan",
|
||||
"switchFailed": "Tidak bisa mengganti: target gagal pemeriksaan atau tes REALITY nyata",
|
||||
"switched": "Diganti ke {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Dasar",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Peer {n} 設定"
|
||||
},
|
||||
"sniffingDestOverride": "宛先のオーバーライド",
|
||||
"advancedTitle": "詳細設定"
|
||||
"advancedTitle": "詳細設定",
|
||||
"realityWatch": {
|
||||
"title": "REALITY を維持",
|
||||
"savedWithInbound": "インバウンドと一緒に保存されます。",
|
||||
"hint": "このサーバーは10分ごとにターゲットを確認します。{limit}回連続で失敗すると、同じ確認と一時的な Xray を使った実際の REALITY 接続に合格した最初の予備に切り替えます。変わるのはターゲットと SNI だけで、クライアントは次のサブスクリプション更新で新しい SNI を受け取ります。",
|
||||
"onNode": "このインバウンドはノードで動いているため、このサーバーではターゲットの確認も切り替えもできません。",
|
||||
"status": "状態",
|
||||
"notChecked": "未確認",
|
||||
"failing": "失敗中({fails} / {limit})",
|
||||
"working": "正常",
|
||||
"auto": "自動で置き換える",
|
||||
"spares": "予備ターゲット",
|
||||
"noSpares": "予備がありません。「予備を探す」で追加してください",
|
||||
"realTest": "実接続テスト",
|
||||
"testOk": "成功",
|
||||
"testFailed": "失敗",
|
||||
"test": "テスト",
|
||||
"testAll": "すべてテスト",
|
||||
"switchNow": "今すぐこれに切り替え",
|
||||
"findSpares": "予備を探す",
|
||||
"save": "予備を保存",
|
||||
"history": "履歴",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} が失敗し、使える予備がありませんでした",
|
||||
"toasts": {
|
||||
"saved": "予備を保存しました",
|
||||
"failed": "予備を保存できませんでした",
|
||||
"switchFailed": "切り替えできません:ターゲットが確認または実際の REALITY テストに失敗しました",
|
||||
"switched": "{target} に切り替えました"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "基本",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Config Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Substituição de destino",
|
||||
"advancedTitle": "Configurações avançadas"
|
||||
"advancedTitle": "Configurações avançadas",
|
||||
"realityWatch": {
|
||||
"title": "Manter o REALITY funcionando",
|
||||
"savedWithInbound": "Eles são salvos junto com a entrada.",
|
||||
"hint": "A cada 10 minutos este servidor verifica o destino. Após {limit} verificações seguidas com falha, o inbound passa para a primeira reserva que passar na mesma verificação e numa conexão REALITY real por um Xray temporário. Só o destino e o SNI mudam; os clientes recebem o novo SNI na próxima atualização da assinatura.",
|
||||
"onNode": "Este inbound roda em um nó, então este servidor não pode verificar nem trocar o destino dele.",
|
||||
"status": "Status",
|
||||
"notChecked": "ainda não verificado",
|
||||
"failing": "falhando ({fails} de {limit})",
|
||||
"working": "funcionando",
|
||||
"auto": "Substituir automaticamente",
|
||||
"spares": "Destinos reserva",
|
||||
"noSpares": "Nenhuma reserva ainda: adicione com Buscar reservas",
|
||||
"realTest": "Teste real",
|
||||
"testOk": "funciona",
|
||||
"testFailed": "falha",
|
||||
"test": "Testar",
|
||||
"testAll": "Testar todos",
|
||||
"switchNow": "Trocar para este agora",
|
||||
"findSpares": "Buscar reservas",
|
||||
"save": "Salvar reservas",
|
||||
"history": "Histórico",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} falhou e nenhuma reserva funcionou",
|
||||
"toasts": {
|
||||
"saved": "Reservas salvas",
|
||||
"failed": "Não foi possível salvar as reservas",
|
||||
"switchFailed": "Não foi possível trocar: o destino falhou na verificação ou no teste REALITY real",
|
||||
"switched": "Trocado para {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Básico",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumber": "Peer {n}",
|
||||
"peerNumberConfig": "Конфиг Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Переопределение назначения"
|
||||
"sniffingDestOverride": "Переопределение назначения",
|
||||
"realityWatch": {
|
||||
"title": "Поддерживать REALITY в работе",
|
||||
"savedWithInbound": "Они сохраняются вместе с инбаундом.",
|
||||
"hint": "Каждые 10 минут этот сервер проверяет цель. После {limit} неудачных проверок подряд инбаунд переходит на первую запасную цель, прошедшую ту же проверку и реальное подключение REALITY через временный Xray. Меняются только цель и SNI; клиенты получат новый SNI при следующем обновлении подписки.",
|
||||
"onNode": "Этот инбаунд работает на ноде, поэтому этот сервер не может проверить или переключить его цель.",
|
||||
"status": "Статус",
|
||||
"notChecked": "ещё не проверено",
|
||||
"failing": "сбой ({fails} из {limit})",
|
||||
"working": "работает",
|
||||
"auto": "Заменять автоматически",
|
||||
"spares": "Запасные цели",
|
||||
"noSpares": "Запасных пока нет: добавьте через «Найти запасные»",
|
||||
"realTest": "Реальный тест",
|
||||
"testOk": "работает",
|
||||
"testFailed": "не работает",
|
||||
"test": "Тест",
|
||||
"testAll": "Проверить все",
|
||||
"switchNow": "Переключить сейчас",
|
||||
"findSpares": "Найти запасные",
|
||||
"save": "Сохранить запасные",
|
||||
"history": "История",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} перестал работать, и ни одна запасная не подошла",
|
||||
"toasts": {
|
||||
"saved": "Запасные сохранены",
|
||||
"failed": "Не удалось сохранить запасные",
|
||||
"switchFailed": "Не удалось переключить: цель не прошла проверку или реальный тест REALITY",
|
||||
"switched": "Переключено на {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Основные",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumber": "Peer {n}",
|
||||
"peerNumberConfig": "Konfigurácia peeru {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Prepísať cieľ"
|
||||
"sniffingDestOverride": "Prepísať cieľ",
|
||||
"realityWatch": {
|
||||
"title": "Udržať REALITY v chode",
|
||||
"savedWithInbound": "Uložia sa spolu s inboundom.",
|
||||
"hint": "Tento server každých 10 minút kontroluje cieľ. Po {limit} neúspešných kontrolách za sebou sa inbound presunie na prvý záložný cieľ, ktorý prejde rovnakou kontrolou a skutočným spojením REALITY cez dočasný Xray. Mení sa len cieľ a SNI; klienti dostanú nové SNI pri ďalšej aktualizácii odberu.",
|
||||
"onNode": "Tento inbound beží na uzle, preto tento server nemôže skontrolovať ani prepnúť jeho cieľ.",
|
||||
"status": "Stav",
|
||||
"notChecked": "zatiaľ nekontrolované",
|
||||
"failing": "zlyháva ({fails} z {limit})",
|
||||
"working": "funguje",
|
||||
"auto": "Nahradiť automaticky",
|
||||
"spares": "Záložné ciele",
|
||||
"noSpares": "Zatiaľ žiadne záložné: pridajte cez Nájsť záložné",
|
||||
"realTest": "Skutočný test",
|
||||
"testOk": "funguje",
|
||||
"testFailed": "zlyhal",
|
||||
"test": "Test",
|
||||
"testAll": "Otestovať všetky",
|
||||
"switchNow": "Prepnúť naň teraz",
|
||||
"findSpares": "Nájsť záložné",
|
||||
"save": "Uložiť záložné",
|
||||
"history": "História",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} zlyhal a žiadny záložný nefungoval",
|
||||
"toasts": {
|
||||
"saved": "Záložné uložené",
|
||||
"failed": "Záložné sa nepodarilo uložiť",
|
||||
"switchFailed": "Prepnutie zlyhalo: cieľ neprešiel kontrolou alebo skutočným testom REALITY",
|
||||
"switched": "Prepnuté na {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Základné údaje",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Peer {n} Yapılandırması"
|
||||
},
|
||||
"sniffingDestOverride": "Hedef geçersiz kılma",
|
||||
"advancedTitle": "Gelişmiş Ayarlar"
|
||||
"advancedTitle": "Gelişmiş Ayarlar",
|
||||
"realityWatch": {
|
||||
"title": "REALITY'yi çalışır tut",
|
||||
"savedWithInbound": "Bunlar inbound ile birlikte kaydedilir.",
|
||||
"hint": "Bu sunucu hedefi her 10 dakikada bir denetler. Art arda {limit} başarısız denetimden sonra inbound, aynı denetimi ve geçici bir Xray üzerinden gerçek bir REALITY bağlantısını geçen ilk yedeğe geçer. Yalnızca hedef ve SNI değişir; istemciler yeni SNI'yı bir sonraki abonelik güncellemesinde alır.",
|
||||
"onNode": "Bu inbound bir düğümde çalışıyor, bu yüzden bu sunucu hedefini denetleyemez veya değiştiremez.",
|
||||
"status": "Durum",
|
||||
"notChecked": "henüz denetlenmedi",
|
||||
"failing": "başarısız ({fails}/{limit})",
|
||||
"working": "çalışıyor",
|
||||
"auto": "Otomatik değiştir",
|
||||
"spares": "Yedek hedefler",
|
||||
"noSpares": "Henüz yedek yok: Yedek bul ile ekleyin",
|
||||
"realTest": "Gerçek test",
|
||||
"testOk": "çalışıyor",
|
||||
"testFailed": "çalışmıyor",
|
||||
"test": "Test et",
|
||||
"testAll": "Hepsini test et",
|
||||
"switchNow": "Şimdi buna geç",
|
||||
"findSpares": "Yedek bul",
|
||||
"save": "Yedekleri kaydet",
|
||||
"history": "Geçmiş",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} çalışmadı ve hiçbir yedek çalışmadı",
|
||||
"toasts": {
|
||||
"saved": "Yedekler kaydedildi",
|
||||
"failed": "Yedekler kaydedilemedi",
|
||||
"switchFailed": "Geçilemedi: hedef denetimi veya gerçek REALITY testini geçemedi",
|
||||
"switched": "{target} hedefine geçildi"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Temel",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Конфіг Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Перевизначення призначення",
|
||||
"advancedTitle": "Додаткові налаштування"
|
||||
"advancedTitle": "Додаткові налаштування",
|
||||
"realityWatch": {
|
||||
"title": "Підтримувати REALITY у роботі",
|
||||
"savedWithInbound": "Вони зберігаються разом з інбаундом.",
|
||||
"hint": "Кожні 10 хвилин цей сервер перевіряє ціль. Після {limit} невдалих перевірок поспіль інбаунд переходить на першу запасну ціль, що пройшла ту саму перевірку та справжнє підключення REALITY через тимчасовий Xray. Змінюються лише ціль і SNI; клієнти отримають новий SNI під час наступного оновлення підписки.",
|
||||
"onNode": "Цей інбаунд працює на ноді, тому цей сервер не може перевірити чи перемкнути його ціль.",
|
||||
"status": "Стан",
|
||||
"notChecked": "ще не перевірено",
|
||||
"failing": "збій ({fails} з {limit})",
|
||||
"working": "працює",
|
||||
"auto": "Замінювати автоматично",
|
||||
"spares": "Запасні цілі",
|
||||
"noSpares": "Запасних поки немає: додайте через «Знайти запасні»",
|
||||
"realTest": "Справжній тест",
|
||||
"testOk": "працює",
|
||||
"testFailed": "не працює",
|
||||
"test": "Тест",
|
||||
"testAll": "Перевірити всі",
|
||||
"switchNow": "Перемкнути зараз",
|
||||
"findSpares": "Знайти запасні",
|
||||
"save": "Зберегти запасні",
|
||||
"history": "Історія",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} перестав працювати, і жодна запасна не підійшла",
|
||||
"toasts": {
|
||||
"saved": "Запасні збережено",
|
||||
"failed": "Не вдалося зберегти запасні",
|
||||
"switchFailed": "Не вдалося перемкнути: ціль не пройшла перевірку або справжній тест REALITY",
|
||||
"switched": "Перемкнено на {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Основні",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Cấu hình Peer {n}"
|
||||
},
|
||||
"sniffingDestOverride": "Ghi đè đích",
|
||||
"advancedTitle": "Cài đặt nâng cao"
|
||||
"advancedTitle": "Cài đặt nâng cao",
|
||||
"realityWatch": {
|
||||
"title": "Giữ REALITY hoạt động",
|
||||
"savedWithInbound": "Chúng được lưu cùng với inbound.",
|
||||
"hint": "Cứ 10 phút máy chủ này kiểm tra mục tiêu. Sau {limit} lần kiểm tra thất bại liên tiếp, inbound chuyển sang mục tiêu dự phòng đầu tiên vượt qua cùng phép kiểm tra và một kết nối REALITY thật qua một Xray tạm thời. Chỉ mục tiêu và SNI thay đổi; client nhận SNI mới ở lần cập nhật gói đăng ký kế tiếp.",
|
||||
"onNode": "Inbound này chạy trên một node nên máy chủ này không thể kiểm tra hoặc chuyển mục tiêu của nó.",
|
||||
"status": "Trạng thái",
|
||||
"notChecked": "chưa kiểm tra",
|
||||
"failing": "lỗi ({fails}/{limit})",
|
||||
"working": "hoạt động",
|
||||
"auto": "Tự động thay thế",
|
||||
"spares": "Mục tiêu dự phòng",
|
||||
"noSpares": "Chưa có dự phòng: thêm bằng Tìm dự phòng",
|
||||
"realTest": "Kiểm tra thật",
|
||||
"testOk": "hoạt động",
|
||||
"testFailed": "lỗi",
|
||||
"test": "Kiểm tra",
|
||||
"testAll": "Kiểm tra tất cả",
|
||||
"switchNow": "Chuyển sang ngay",
|
||||
"findSpares": "Tìm dự phòng",
|
||||
"save": "Lưu dự phòng",
|
||||
"history": "Lịch sử",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} lỗi và không dự phòng nào hoạt động",
|
||||
"toasts": {
|
||||
"saved": "Đã lưu dự phòng",
|
||||
"failed": "Không lưu được dự phòng",
|
||||
"switchFailed": "Không chuyển được: mục tiêu không qua phép kiểm tra hoặc kiểm tra REALITY thật",
|
||||
"switched": "Đã chuyển sang {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "Cơ bản",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Peer {n} 配置"
|
||||
},
|
||||
"sniffingDestOverride": "目标覆盖",
|
||||
"advancedTitle": "高级设置"
|
||||
"advancedTitle": "高级设置",
|
||||
"realityWatch": {
|
||||
"title": "保持 REALITY 可用",
|
||||
"savedWithInbound": "它们会随入站一起保存。",
|
||||
"hint": "本服务器每 10 分钟检查一次目标。连续 {limit} 次检查失败后,入站会切换到第一个通过同样检查并经临时 Xray 完成真实 REALITY 连接的备用目标。只改变目标和 SNI;客户端会在下次更新订阅时获得新的 SNI。",
|
||||
"onNode": "此入站运行在节点上,本服务器无法检查或切换其目标。",
|
||||
"status": "状态",
|
||||
"notChecked": "尚未检查",
|
||||
"failing": "失败({fails}/{limit})",
|
||||
"working": "正常",
|
||||
"auto": "自动替换",
|
||||
"spares": "备用目标",
|
||||
"noSpares": "还没有备用目标:用“查找备用”添加",
|
||||
"realTest": "真实测试",
|
||||
"testOk": "可用",
|
||||
"testFailed": "不可用",
|
||||
"test": "测试",
|
||||
"testAll": "全部测试",
|
||||
"switchNow": "立即切换到此",
|
||||
"findSpares": "查找备用",
|
||||
"save": "保存备用",
|
||||
"history": "历史",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} 失效,且没有可用的备用目标",
|
||||
"toasts": {
|
||||
"saved": "备用目标已保存",
|
||||
"failed": "无法保存备用目标",
|
||||
"switchFailed": "无法切换:目标未通过检查或真实 REALITY 测试",
|
||||
"switched": "已切换到 {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "基本",
|
||||
|
||||
@@ -810,7 +810,37 @@
|
||||
"peerNumberConfig": "Peer {n} 設定"
|
||||
},
|
||||
"sniffingDestOverride": "目標覆寫",
|
||||
"advancedTitle": "進階設定"
|
||||
"advancedTitle": "進階設定",
|
||||
"realityWatch": {
|
||||
"title": "保持 REALITY 可用",
|
||||
"savedWithInbound": "它們會隨入站一起儲存。",
|
||||
"hint": "本伺服器每 10 分鐘檢查一次目標。連續 {limit} 次檢查失敗後,入站會切換到第一個通過同樣檢查並經臨時 Xray 完成真實 REALITY 連線的備用目標。只改變目標與 SNI;用戶端會在下次更新訂閱時取得新的 SNI。",
|
||||
"onNode": "此入站執行在節點上,本伺服器無法檢查或切換其目標。",
|
||||
"status": "狀態",
|
||||
"notChecked": "尚未檢查",
|
||||
"failing": "失敗({fails}/{limit})",
|
||||
"working": "正常",
|
||||
"auto": "自動替換",
|
||||
"spares": "備用目標",
|
||||
"noSpares": "還沒有備用目標:用「尋找備用」新增",
|
||||
"realTest": "真實測試",
|
||||
"testOk": "可用",
|
||||
"testFailed": "不可用",
|
||||
"test": "測試",
|
||||
"testAll": "全部測試",
|
||||
"switchNow": "立即切換到此",
|
||||
"findSpares": "尋找備用",
|
||||
"save": "儲存備用",
|
||||
"history": "歷史",
|
||||
"eventSwitched": "{from} → {to}",
|
||||
"eventNoSpare": "{from} 失效,且沒有可用的備用目標",
|
||||
"toasts": {
|
||||
"saved": "備用目標已儲存",
|
||||
"failed": "無法儲存備用目標",
|
||||
"switchFailed": "無法切換:目標未通過檢查或真實 REALITY 測試",
|
||||
"switched": "已切換到 {target}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clients": {
|
||||
"tabBasics": "基本",
|
||||
|
||||
@@ -310,6 +310,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||
// counters.
|
||||
const (
|
||||
cadenceXrayRunning = "@every 1s"
|
||||
cadenceRealityWatch = "@every 10m"
|
||||
cadenceXrayRestart = "@every 30s"
|
||||
cadenceXrayTraffic = "@every 5s"
|
||||
cadenceMtproto = "@every 10s"
|
||||
@@ -387,6 +388,7 @@ func (s *Server) startTask(restartXray bool, loc *time.Location) {
|
||||
_, _ = s.cron.AddJob("@daily", job.NewClearLogsJob())
|
||||
_, _ = s.cron.AddJob(cadenceXrayLogPrune, job.NewPruneXrayLogsJob())
|
||||
_, _ = s.cron.AddJob("@hourly", job.NewWarpIpJob())
|
||||
_, _ = s.cron.AddJob(cadenceRealityWatch, job.NewRealityWatchJob())
|
||||
|
||||
// Inbound traffic reset jobs
|
||||
// Run every hour
|
||||
|
||||
@@ -119,6 +119,9 @@ func run(root, outDir string) error {
|
||||
"NodeView",
|
||||
"ProbeResultUI",
|
||||
"RealityScanResult",
|
||||
"RealityWatchEntry",
|
||||
"RealityWatchEvent",
|
||||
"RealityWatchStatus",
|
||||
"GeodataTokenIssue",
|
||||
"AmneziaWGLogs",
|
||||
"PeerActivity",
|
||||
|
||||
Reference in New Issue
Block a user