2020-11-25 19:01:53 +08:00
|
|
|
// Package core provides an entry point to use Xray core functionalities.
|
|
|
|
|
//
|
|
|
|
|
// Xray makes it possible to accept incoming network connections with certain
|
|
|
|
|
// protocol, process the data, and send them through another connection with
|
|
|
|
|
// the same or a difference protocol on demand.
|
|
|
|
|
//
|
|
|
|
|
// It may be configured to work with multiple protocols at the same time, and
|
|
|
|
|
// uses the internal router to tunnel through different inbound and outbound
|
|
|
|
|
// connections.
|
|
|
|
|
package core
|
|
|
|
|
|
|
|
|
|
import (
|
2023-02-15 16:07:12 +00:00
|
|
|
"fmt"
|
2020-11-25 19:01:53 +08:00
|
|
|
"runtime"
|
2026-02-12 22:00:15 +08:00
|
|
|
"runtime/debug"
|
2020-11-25 19:01:53 +08:00
|
|
|
|
2020-12-04 09:36:16 +08:00
|
|
|
"github.com/xtls/xray-core/common/serial"
|
2020-11-25 19:01:53 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
2026-01-13 15:32:01 +00:00
|
|
|
Version_x byte = 26
|
2026-02-02 09:35:31 +00:00
|
|
|
Version_y byte = 2
|
2026-02-06 09:42:41 +00:00
|
|
|
Version_z byte = 6
|
2023-02-15 16:07:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
2020-11-25 19:01:53 +08:00
|
|
|
build = "Custom"
|
|
|
|
|
codename = "Xray, Penetrates Everything."
|
|
|
|
|
intro = "A unified platform for anti-censorship."
|
|
|
|
|
)
|
|
|
|
|
|
2026-02-12 22:00:15 +08:00
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-25 19:01:53 +08:00
|
|
|
// 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.
|
|
|
|
|
func Version() string {
|
2023-02-15 16:07:12 +00:00
|
|
|
return fmt.Sprintf("%v.%v.%v", Version_x, Version_y, Version_z)
|
2020-11-25 19:01:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VersionStatement returns a list of strings representing the full version info.
|
|
|
|
|
func VersionStatement() []string {
|
|
|
|
|
return []string{
|
|
|
|
|
serial.Concat("Xray ", Version(), " (", codename, ") ", build, " (", runtime.Version(), " ", runtime.GOOS, "/", runtime.GOARCH, ")"),
|
|
|
|
|
intro,
|
|
|
|
|
}
|
|
|
|
|
}
|