mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
fix confdir env startup priority
This commit is contained in:
parent
3f6ef26a00
commit
94ea326d89
21
main/main.go
21
main/main.go
@ -47,6 +47,9 @@ func fileExists(file string) bool {
|
||||
}
|
||||
|
||||
func dirExists(file string) bool {
|
||||
if file == "" {
|
||||
return false
|
||||
}
|
||||
info, err := os.Stat(file)
|
||||
return err == nil && info.IsDir()
|
||||
}
|
||||
@ -65,8 +68,18 @@ func readConfDir(dirPath string) {
|
||||
|
||||
func getConfigFilePath() (cmdarg.Arg, error) {
|
||||
if dirExists(configDir) {
|
||||
log.Println("Using confdir from arg:", configDir)
|
||||
readConfDir(configDir)
|
||||
} else {
|
||||
if envConfDir := platform.GetConfDirPath(); dirExists(envConfDir) {
|
||||
log.Println("Using confdir from env:", envConfDir)
|
||||
readConfDir(envConfDir)
|
||||
if len(configFiles) > 0 {
|
||||
return configFiles, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(configFiles) > 0 {
|
||||
return configFiles, nil
|
||||
}
|
||||
@ -84,14 +97,6 @@ func getConfigFilePath() (cmdarg.Arg, error) {
|
||||
return cmdarg.Arg{configFile}, nil
|
||||
}
|
||||
|
||||
if envConfDir := platform.GetConfDirPath(); dirExists(envConfDir) {
|
||||
log.Println("Using confdir from env: ", envConfDir)
|
||||
readConfDir(envConfDir)
|
||||
if len(configFiles) > 0 {
|
||||
return configFiles, nil
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Using config from STDIN")
|
||||
return cmdarg.Arg{"stdin:"}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user