mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-14 18:09:05 +00:00
core/core.go: Replace "Custom" with vcs info if available (#5665)
https://github.com/XTLS/Xray-core/pull/5665#issuecomment-3890500863
This commit is contained in:
@@ -12,6 +12,7 @@ package core
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/serial"
|
"github.com/xtls/xray-core/common/serial"
|
||||||
)
|
)
|
||||||
@@ -28,6 +29,34 @@ var (
|
|||||||
intro = "A unified platform for anti-censorship."
|
intro = "A unified platform for anti-censorship."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Manually injected
|
||||||
|
if build != "Custom" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info, ok := debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var isDirty bool
|
||||||
|
var foundBuild bool
|
||||||
|
for _, setting := range info.Settings {
|
||||||
|
switch setting.Key {
|
||||||
|
case "vcs.revision":
|
||||||
|
if len(setting.Value) < 7 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
build = setting.Value[:7]
|
||||||
|
foundBuild = true
|
||||||
|
case "vcs.modified":
|
||||||
|
isDirty = setting.Value == "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if isDirty && foundBuild {
|
||||||
|
build += "-dirty"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Version returns Xray's version as a string, in the form of "x.y.z" where x, y and z are numbers.
|
// Version returns Xray's version as a string, in the form of "x.y.z" where x, y and z are numbers.
|
||||||
// ".z" part may be omitted in regular releases.
|
// ".z" part may be omitted in regular releases.
|
||||||
func Version() string {
|
func Version() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user