mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-01 01:26:03 +03:00
Refine environment var
Address some review comments
This commit is contained in:
parent
999bdc58d3
commit
11b61b02c8
@ -17,13 +17,13 @@ func LineSeparator() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetToolLocation(file string) string {
|
func GetToolLocation(file string) string {
|
||||||
toolPath := NewEnvFlag(UnixToolLocation).GetValue(getExecutableDir)
|
toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir)
|
||||||
return filepath.Join(toolPath, file)
|
return filepath.Join(toolPath, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetLocation searches for `file` in certain locations
|
// GetAssetLocation searches for `file` in certain locations
|
||||||
func GetAssetLocation(file string) string {
|
func GetAssetLocation(file string) string {
|
||||||
assetPath := NewEnvFlag(UnixAssetLocation).GetValue(getExecutableDir)
|
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
|
||||||
defPath := filepath.Join(assetPath, file)
|
defPath := filepath.Join(assetPath, file)
|
||||||
for _, p := range []string{
|
for _, p := range []string{
|
||||||
defPath,
|
defPath,
|
||||||
|
@ -7,6 +7,24 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PluginLocation = "xray.location.plugin"
|
||||||
|
ConfigLocation = "xray.location.config"
|
||||||
|
ConfdirLocation = "xray.location.confdir"
|
||||||
|
ToolLocation = "xray.location.tool"
|
||||||
|
AssetLocation = "xray.location.asset"
|
||||||
|
|
||||||
|
UseReadV = "xray.buf.readv"
|
||||||
|
UseFreedomSplice = "xray.buf.splice"
|
||||||
|
UseVmessPadding = "xray.vmess.padding"
|
||||||
|
UseCone = "xray.cone.disabled"
|
||||||
|
|
||||||
|
BufferSize = "xray.ray.buffer.size"
|
||||||
|
BrowserDialerAddress = "xray.browser.dialer"
|
||||||
|
XUDPLog = "xray.xudp.show"
|
||||||
|
XUDPBaseKey = "xray.xudp.basekey"
|
||||||
|
)
|
||||||
|
|
||||||
type EnvFlag struct {
|
type EnvFlag struct {
|
||||||
Name string
|
Name string
|
||||||
AltName string
|
AltName string
|
||||||
@ -67,34 +85,17 @@ func getExecutableSubDir(dir string) func() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetPluginDirectory() string {
|
func GetPluginDirectory() string {
|
||||||
const name = "xray.location.plugin"
|
pluginDir := NewEnvFlag(PluginLocation).GetValue(getExecutableSubDir("plugins"))
|
||||||
pluginDir := NewEnvFlag(name).GetValue(getExecutableSubDir("plugins"))
|
|
||||||
return pluginDir
|
return pluginDir
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConfigurationPath() string {
|
func GetConfigurationPath() string {
|
||||||
const name = "xray.location.config"
|
configPath := NewEnvFlag(ConfigLocation).GetValue(getExecutableDir)
|
||||||
configPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
|
||||||
return filepath.Join(configPath, "config.json")
|
return filepath.Join(configPath, "config.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConfDirPath reads "xray.location.confdir"
|
// GetConfDirPath reads "xray.location.confdir"
|
||||||
func GetConfDirPath() string {
|
func GetConfDirPath() string {
|
||||||
const name = "xray.location.confdir"
|
configPath := NewEnvFlag(ConfdirLocation).GetValue(func() string { return "" })
|
||||||
configPath := NewEnvFlag(name).GetValue(func() string { return "" })
|
|
||||||
return configPath
|
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"
|
|
||||||
)
|
|
||||||
|
@ -15,14 +15,12 @@ func LineSeparator() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetToolLocation(file string) string {
|
func GetToolLocation(file string) string {
|
||||||
const name = "xray.location.tool"
|
toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir)
|
||||||
toolPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir)
|
|
||||||
return filepath.Join(toolPath, file+".exe")
|
return filepath.Join(toolPath, file+".exe")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetLocation searches for `file` in the excutable dir
|
// GetAssetLocation searches for `file` in the excutable dir
|
||||||
func GetAssetLocation(file string) string {
|
func GetAssetLocation(file string) string {
|
||||||
const name = "xray.location.asset"
|
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
|
||||||
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
|
||||||
return filepath.Join(assetPath, file)
|
return filepath.Join(assetPath, file)
|
||||||
}
|
}
|
||||||
|
@ -83,12 +83,8 @@ func ManagerType() interface{} {
|
|||||||
var defaultBufferSize int32
|
var defaultBufferSize int32
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
const key = "xray.ray.buffer.size"
|
|
||||||
const defaultValue = -17
|
const defaultValue = -17
|
||||||
size := platform.EnvFlag{
|
size := platform.NewEnvFlag(platform.BufferSize).GetValueAsInt(defaultValue)
|
||||||
Name: key,
|
|
||||||
AltName: platform.NormalizeEnvName(key),
|
|
||||||
}.GetValueAsInt(defaultValue)
|
|
||||||
|
|
||||||
switch size {
|
switch size {
|
||||||
case 0:
|
case 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user