mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
optimize: more friendly prompt and accurate judge for the asset path
This commit is contained in:
1 parent
8985975ba7
commit
293fb8a0db
2 files changed
+26
-4
No files matched your search
@@ -18,20 +18,42 @@ import (
|
||||
"v2ray.com/core/common/strmatcher"
|
||||
)
|
||||
|
||||
type assetCandidate struct {
|
||||
path string
|
||||
v2rayCore bool
|
||||
}
|
||||
|
||||
func GetV2rayLocationAsset() (s string) {
|
||||
var candidates = []string{`/usr/local/share/v2ray`, `/usr/share/v2ray`, `/usr/local/share/xray`, `/usr/share/xray`}
|
||||
var candidates = []assetCandidate{
|
||||
{`/usr/local/share/v2ray`, true},
|
||||
{`/usr/share/v2ray`, true},
|
||||
{`/usr/local/share/xray`, false},
|
||||
{`/usr/share/xray`, false},
|
||||
}
|
||||
var is bool
|
||||
if ver, err := where.GetV2rayServiceVersion(); err == nil {
|
||||
if is, err = common.VersionGreaterEqual(ver, "4.27.1"); is {
|
||||
for _, c := range candidates {
|
||||
if _, err := os.Stat(c); os.IsNotExist(err) {
|
||||
if ver == "UnknownClient" {
|
||||
// xray, etc.
|
||||
if c.v2rayCore {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
// v2ray
|
||||
if !c.v2rayCore {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(c.path); os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
s = c
|
||||
s = c.path
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// old version of v2ray
|
||||
if s == "" {
|
||||
//maybe v2ray working directory
|
||||
v2rayPath, err := where.GetV2rayBinPath()
|
||||
|
||||
@@ -112,7 +112,7 @@ func RestartV2rayService() (err error) {
|
||||
}
|
||||
|
||||
if time.Since(startTime) > 15*time.Second {
|
||||
return newError("v2ray-core does not start normally, there may be a problem of the configuration file or the required port is occupied")
|
||||
return newError("v2ray-core does not start normally, check the log for more information")
|
||||
}
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user