1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-26 20:15:26 -05:00

use external config converter first, and then fallback to the internal one

This commit is contained in:
Darien Raymond
2017-11-11 22:29:00 +01:00
parent 901d13ca76
commit 268d7264e8
4 changed files with 63 additions and 10 deletions

View File

@@ -45,14 +45,16 @@ func NormalizeEnvName(name string) string {
return strings.Replace(strings.ToUpper(strings.TrimSpace(name)), ".", "_", -1)
}
func getExecutableDir() string {
exec, err := os.Executable()
if err != nil {
return ""
}
return filepath.Dir(exec)
}
func GetAssetLocation(file string) string {
const name = "v2ray.location.asset"
assetPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(func() string {
exec, err := os.Executable()
if err != nil {
return ""
}
return filepath.Dir(exec)
})
assetPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir)
return filepath.Join(assetPath, file)
}