Unify environment var readers

This commit is contained in:
yuhan6665 2023-10-28 17:24:54 -04:00
parent e241e5bda6
commit 4f05e0ac2b
9 changed files with 32 additions and 23 deletions

View file

@ -17,15 +17,13 @@ func LineSeparator() string {
}
func GetToolLocation(file string) string {
const name = "xray.location.tool"
toolPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir)
toolPath := NewEnvFlag(UnixToolLocation).GetValue(getExecutableDir)
return filepath.Join(toolPath, file)
}
// GetAssetLocation searches for `file` in certain locations
func GetAssetLocation(file string) string {
const name = "xray.location.asset"
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
assetPath := NewEnvFlag(UnixAssetLocation).GetValue(getExecutableDir)
defPath := filepath.Join(assetPath, file)
for _, p := range []string{
defPath,

View file

@ -84,3 +84,17 @@ func GetConfDirPath() string {
configPath := NewEnvFlag(name).GetValue(func() string { return "" })
return configPath
}
const (
UnixToolLocation = "xray.location.tool"
UnixAssetLocation = "xray.location.asset"
UseReadV = "xray.buf.readv"
UseFreedomSplice = "xray.buf.splice"
UseVmessPadding = "xray.vmess.padding"
UseCone = "xray.cone.disabled"
BrowserDialerAddress = "xray.browser.dialer"
XUDPLog = "xray.xudp.show"
XUDPBaseKey = "xray.xudp.basekey"
)