mirror of
https://github.com/XTLS/Xray-docs-next.git
synced 2026-09-26 16:48:32 +03:00
Clarify xray run -config sources and polish command examples in command docs
This commit is contained in:
+62
-24
@@ -8,7 +8,7 @@ Xray 使用 Go 风格的命令及参数
|
||||
|
||||
您可以运行 `xray help` 来获得所有 xray 最基础的用法, 以及可用的命令及说明。
|
||||
|
||||
```
|
||||
```bash
|
||||
Xray is a platform for building proxies.
|
||||
|
||||
Usage:
|
||||
@@ -38,11 +38,11 @@ Use "xray help <command>" for more information about a command.
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
xray run [-c config.json] [-confdir dir]
|
||||
```bash
|
||||
xray run [-c config.json] [-confdir dir]
|
||||
```
|
||||
|
||||
```
|
||||
```bash
|
||||
Run Xray with config, the default command.
|
||||
|
||||
The -config=file, -c=file flags set the config files for
|
||||
@@ -59,15 +59,53 @@ without launching the server.
|
||||
The -dump flag tells Xray to print the merged config.
|
||||
```
|
||||
|
||||
`-config=` / `-c=` 用于指定使用的配置文件的位置,支持多文件配置。
|
||||
`-confdir=` 用于指定一个包含多个配置文件的文件夹。
|
||||
`-format=` 用于指定使用的配置文件的格式。
|
||||
`-test` 用于测试配置文件的合法性。
|
||||
`-dump` 用于显示多文件配置文件合并之后的效果。
|
||||
- `-config=` / `-c=` 用于指定使用的配置文件的位置。
|
||||
- `-confdir=` 用于指定一个含多个配置文件的文件夹,该目录下的所有配置文件会[自动合并](/config/features/multiple.md)。
|
||||
- `-format=` 用于指定使用的配置文件的格式。
|
||||
- `-test` 用于测试配置文件的合法性。
|
||||
- `-dump` 用于显示多文件配置文件合并之后的效果。
|
||||
|
||||
::: tip
|
||||
配置文件除了默认的 JSON 格式外,也可以使用 TOML 和 YAML。在不指定格式的前提下会通过文件扩展名识别。
|
||||
:::
|
||||
|
||||
:::: tip
|
||||
`-config=` / `-c=` 不仅支持本地文件路径,也支持标准输入和远程地址。
|
||||
|
||||
::: details 展开查看 `-config` 支持的形式与示例
|
||||
`-config=` 可重复使用,以指定多个配置源。例如:
|
||||
|
||||
```bash
|
||||
xray run -config base.json -config routing.json -config outbounds.yaml
|
||||
```
|
||||
|
||||
Xray 会按参数顺序读取这些配置文件,并[自动合并](/config/features/multiple.md)为最终配置。
|
||||
|
||||
除了常见的本地文件绝对路径、相对路径外,还支持以下形式:
|
||||
|
||||
- `stdin:`:从标准输入读取配置内容。适合配合管道、重定向或由上层程序动态生成配置时使用。输入完成后,调用者必须关闭标准输入流,否则 Xray 会继续等待输入结束。
|
||||
- 以 `http://` 或 `https://` 开头的 URL:从远程地址下载配置内容。协议名前缀必须使用小写。**此方式存在安全风险,除非你明确知道自己在做什么,否则不要轻易使用。**
|
||||
- `http+unix://`:通过 Unix Domain Socket 发起 HTTP 请求并读取配置,格式形如 `http+unix:///path/to/socket.sock/api/endpoint`。适合配置由本机某个仅监听 Unix Socket 的服务动态提供时使用。
|
||||
|
||||
示例:
|
||||
|
||||
```bash
|
||||
# 从本地文件读取
|
||||
xray run -config ./config.json
|
||||
|
||||
# 从标准输入读取
|
||||
cat config.json | xray run -config stdin:
|
||||
|
||||
# 从远程地址读取
|
||||
xray run -config https://example.com/xray/config.json
|
||||
|
||||
# 通过 Unix Domain Socket 对应的 HTTP 接口读取
|
||||
xray run -config http+unix:///run/xray-config.sock/config.json
|
||||
```
|
||||
|
||||
:::
|
||||
::::
|
||||
|
||||
::: tip
|
||||
当 `-config` 没有指定时,Xray 将先后尝试从以下路径加载 `config.json` :
|
||||
|
||||
@@ -75,8 +113,8 @@ The -dump flag tells Xray to print the merged config.
|
||||
- [环境变量](../config/features/env.md#资源文件路径)中 `Xray.location.asset` 所指定的路径
|
||||
:::
|
||||
|
||||
```
|
||||
xray run -dump
|
||||
```bash
|
||||
xray run -dump
|
||||
```
|
||||
|
||||
用以输出多文件配置融合之后的结果。
|
||||
@@ -87,8 +125,8 @@ The -dump flag tells Xray to print the merged config.
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
xray version
|
||||
```bash
|
||||
xray version
|
||||
```
|
||||
|
||||
### xray api
|
||||
@@ -97,11 +135,11 @@ The -dump flag tells Xray to print the merged config.
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray api <command> [arguments]
|
||||
```
|
||||
|
||||
```
|
||||
```bash
|
||||
restartlogger Restart the logger
|
||||
stats Get statistics
|
||||
statsquery Query statistics
|
||||
@@ -118,7 +156,7 @@ xray api <command> [arguments]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray convert <command> [arguments]
|
||||
|
||||
The commands are:
|
||||
@@ -173,11 +211,11 @@ xray help convert json
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray tls <command> [arguments]
|
||||
```
|
||||
|
||||
```
|
||||
```bash
|
||||
cert Generate TLS certificates
|
||||
ping Ping the domain with TLS handshake
|
||||
certChainHash Calculate TLS certificates hash.
|
||||
@@ -189,7 +227,7 @@ xray tls <command> [arguments]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray uuid [-i "example"]
|
||||
```
|
||||
|
||||
@@ -199,7 +237,7 @@ xray uuid [-i "example"]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray x25519 [-i "(base64.RawURLEncoding)" --std-encoding ]
|
||||
```
|
||||
|
||||
@@ -209,7 +247,7 @@ xray x25519 [-i "(base64.RawURLEncoding)" --std-encoding ]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray wg [-i "(base64.StdEncoding)"]
|
||||
```
|
||||
|
||||
@@ -226,7 +264,7 @@ xray wg [-i "(base64.StdEncoding)"]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray mldsa65 [-i "seed (base64.StdEncoding)"]
|
||||
```
|
||||
|
||||
@@ -236,7 +274,7 @@ xray mldsa65 [-i "seed (base64.StdEncoding)"]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray mlkem768 [-i "seed (base64.StdEncoding)"]
|
||||
```
|
||||
|
||||
@@ -246,6 +284,6 @@ xray mlkem768 [-i "seed (base64.StdEncoding)"]
|
||||
|
||||
使用方法:
|
||||
|
||||
```
|
||||
```bash
|
||||
xray vlessenc
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user