2023-03-04 23:33:55 +08:00
# Command Parameters
2021-05-26 19:05:53 +08:00
::: tip
2023-03-04 23:33:55 +08:00
Xray uses Go-style commands and parameters
2021-05-26 19:05:53 +08:00
:::
2023-03-04 23:33:55 +08:00
## Get Basic Commands
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
You can run `xray help` to get the most basic usage of all xray, as well as available commands and instructions.
2021-05-26 19:05:53 +08:00
```
Xray is a platform for building proxies.
Usage:
xray < command > [arguments]
The commands are:
run Run Xray with config, the default command
version Show current version of Xray
api Call an API in an Xray process
tls TLS tools
2023-12-25 03:45:01 +08:00
uuid Generate UUIDv4 or UUIDv5
x25519 Generate key pair for x25519 key exchange
wg Generate key pair for wireguard key exchange
2021-05-26 19:05:53 +08:00
Use "xray help < command > " for more information about a command.
2023-12-25 03:45:01 +08:00
```
2021-05-26 19:05:53 +08:00
### xray run
2023-03-04 23:33:55 +08:00
Specify one or more configuration files and run.
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
Usage:
2021-05-26 19:05:53 +08:00
```
xray run [-c config.json] [-confdir dir]
```
```
Run Xray with config, the default command.
The -config=file, -c=file flags set the config files for
Xray. Multiple assign is accepted.
The -confdir=dir flag sets a dir with multiple json config
The -format=json flag sets the format of config files.
Default "json".
The -test flag tells Xray to test config files only,
without launching the server
2024-09-12 19:54:45 +08:00
The -dump flag tells Xray to print the merged config.
2021-05-26 19:05:53 +08:00
```
2024-09-12 19:54:45 +08:00
::: tip
Except from the default JSON format, config can also use TOML and YAML. It will automatically recognized from file extensions when the `-format` flag is not set.
:::
2021-05-26 19:05:53 +08:00
### xray version
2023-03-04 23:33:55 +08:00
Output Xray version, Golang version and other information.
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
Usage:
2021-05-26 19:05:53 +08:00
```
xray version
```
### xray api
2023-03-04 23:33:55 +08:00
To call Xray's gRPC API, it needs to be enabled in the configuration file.
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
Usage:
2021-05-26 19:05:53 +08:00
```
xray api < command > [arguments]
```
```
restartlogger Restart the logger
stats Get statistics
statsquery Query statistics
statssys Get system statistics
adi Add inbounds
ado Add outbounds
rmi Remove inbounds
rmo Remove outbounds
```
2024-09-12 19:54:45 +08:00
### xray convert
Convert config to protobuf, or convert typedMessage to JSON
usage:
```
xray convert < command > [arguments]
The commands are:
pb Convert multiple json configs to protobuf
json Convert typedMessage to json
```
Sub-command `pb`
```bash
# Usage: xray convert pb [-debug] [-type] [json file] [json file] ...
# mix three config files to mix.pb
xray convert pb c1.json c2.json c3.json > mix.pb
# Use -debug option to view the content of mix.pb
xray convert pb -debug mix.pb
# Start Xray-core with mix.pb
xray -c mix.pb
# Detailed usage
xray help convert pb
```
Sub-command JSON
```bash
# Usage: xray convert json [-type] [stdin:] [typedMessage file]
tmsg='{
"type": "xray.proxy.shadowsocks.Account",
"value": "CgMxMTEQBg=="
}'
echo ${tmsg} | xray convert json stdin:
# Outputs from above:
'{
"cipherType": "AES_256_GCM",
"password": "111"
}'
# Detailed usage
xray help convert json
```
2021-05-26 19:05:53 +08:00
### xray tls
2023-03-04 23:33:55 +08:00
Some tools related to TLS.
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
Usage:
2021-05-26 19:05:53 +08:00
```
xray tls < command > [arguments]
```
```
2024-09-12 19:54:45 +08:00
cert Generate TLS certificates
ping Ping the domain with TLS handshake
certChainHash Calculate TLS certificates hash.
2021-05-26 19:05:53 +08:00
```
### xray uuid
2023-12-25 03:45:01 +08:00
Generate UUID.
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
Usage:
2021-05-26 19:05:53 +08:00
```
xray uuid
```
2023-12-25 03:45:01 +08:00
### xray x25519
Generate x25519 key pair。
Usage:
```
xray x25519 [-i "(base64.RawURLEncoding)" --std-encoding]
```
### xray wg
Generate wireguard curve25519 key pair。
Usage:
```
xray wg [-i "(base64.StdEncoding)"]
```
2021-05-26 19:05:53 +08:00
::: tip
2023-03-04 23:33:55 +08:00
When `-config` is not specified, Xray will try to load `config.json` from the following paths:
2021-05-26 19:05:53 +08:00
2023-03-04 23:33:55 +08:00
- Working Directory
- The path specified by `Xray.location.asset` in the [environment variable ](../config/features/env.md ).
2021-05-26 19:05:53 +08:00
:::