Skip to content

Configuration Validation

v2rayroot edited this page Jun 14, 2026 · 1 revision

Configuration Validation

ValidateConfig

char *ValidateConfig(char *configInput, char *optionsJSON);

The accepted input forms match Start: JSON text, JSON file path, or supported share URI.

Success:

{"result":"valid"}

Failure:

{"error":"config validation failed: ..."}

Always parse the response as JSON and check for error. Do not compare full error strings because upstream Xray details can change.

Validation Processing

The library:

  1. Loads or parses the input.
  2. Migrates legacy dnsConfig to dns.
  3. Adds missing common defaults.
  4. Validates required outbound fields.
  5. Asks Xray-core to load the finalized JSON.

Validation does not start a persistent runtime.

Recommended Use

Run validation:

  • Before every user-requested connection
  • After editing configuration
  • After importing a URI
  • During application migrations

Treat imported configuration as untrusted data.

Clone this wiki locally