Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

init

Initialize the xrat config directory, config file, and database.

xrat init [--dry-run]

Flags

FlagDescription
--dry-runPrint planned actions without creating anything

Behavior

  1. Creates the app root directory ($HOME/.config/xrat/ or $XRAT_PATH)
  2. Writes a default config.toml with sensible defaults if not already present
  3. Creates the SQLite database and runs all pending migrations
  4. Creates subdirectories: runtime/, logs/, mmdb/
  5. Prints a summary of what was created and what was already present

Idempotent: safe to run multiple times. Existing files are never overwritten. If config.toml exists and has been customized, it is left untouched.

Example: first-time setup

xrat init
xrat initialized successfully.

Created:
  /home/user/.config/xrat/
  /home/user/.config/xrat/config.toml (written default template)
  /home/user/.config/xrat/runtime/
  /home/user/.config/xrat/logs/
  /home/user/.config/xrat/mmdb/

Already present:
  /home/user/.config/xrat/db.sqlite (database ready)

Next steps:
  xrat import <subscription-url>
  xrat list configs

Example: dry run

xrat init --dry-run
--- dry run: no files written ---

Would create (if absent):
  /home/user/.config/xrat/
  /home/user/.config/xrat/config.toml
  /home/user/.config/xrat/db.sqlite
  /home/user/.config/xrat/runtime/
  /home/user/.config/xrat/logs/
  /home/user/.config/xrat/mmdb/

State paths

PathPurposeOverride
$HOME/.config/xrat/App rootXRAT_PATH env var
$HOME/.config/xrat/config.tomlConfiguration--config flag
$HOME/.config/xrat/db.sqliteSQLite database--database flag
$HOME/.config/xrat/runtime/Daemon socket, session state
$HOME/.config/xrat/logs/Runtime logs[runtime.log].dir
$HOME/.config/xrat/mmdb/GeoIP data[mmdb].dir

Default config.toml

xrat init writes a fully documented config file: common settings are active with inline descriptions, and advanced features are present but commented out so the file doubles as offline reference. Default local ports use the 1820x block (SOCKS 18200, HTTP 18201, Shadowsocks 18202, API server 18203).

[runtime]
engine = "xray"
replace_active_session = true

[runtime.socks]
enabled = true
host = "0.0.0.0"
port = 18200
udp = true

[runtime.http]
enabled = false
host = "0.0.0.0"
port = 18201

[runtime.log]
enabled = true
level = "warning"

[testing]
concurrency = 0

[server]
enabled = false
host = "127.0.0.1"
port = 18203

See Config File for full reference.