github.com/imannamdari/v2ray-core/v5@v5.0.5/main/commands/test.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/imannamdari/v2ray-core/v5/main/commands/base" 7 ) 8 9 // CmdTest tests config files 10 var CmdTest = &base.Command{ 11 CustomFlags: true, 12 UsageLine: "{{.Exec}} test [-format=json] [-c config.json] [-d dir]", 13 Short: "test config files", 14 Long: ` 15 Test config files, without launching V2Ray server. 16 17 {{.Exec}} will also use the config directory specified by environment 18 variable "v2ray.location.confdir". If no config found, it tries 19 to load config from one of below: 20 21 1. The default "config.json" in the current directory 22 2. The config file from ENV "v2ray.location.config" 23 3. The stdin if all failed above 24 25 Arguments: 26 27 -c, -config <file> 28 Config file for V2Ray. Multiple assign is accepted. 29 30 -d, -confdir <dir> 31 A directory with config files. Multiple assign is accepted. 32 33 -r 34 Load confdir recursively. 35 36 -format <format> 37 Format of config input. (default "auto") 38 39 Examples: 40 41 {{.Exec}} {{.LongName}} -c config.json 42 {{.Exec}} {{.LongName}} -d path/to/dir 43 44 Use "{{.Exec}} help format-loader" for more information about format. 45 `, 46 Run: executeTest, 47 } 48 49 func executeTest(cmd *base.Command, args []string) { 50 setConfigFlags(cmd) 51 cmd.Flag.Parse(args) 52 printVersion() 53 configFiles = getConfigFilePath() 54 _, err := startV2Ray() 55 if err != nil { 56 base.Fatalf("Test failed: %s", err) 57 } 58 fmt.Println("Configuration OK.") 59 }