diff --git a/Makefile b/Makefile index 41bdad6..63dc90e 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,7 @@ CMD_DIR=$(shell pwd)/cmd VERSION=$(shell git describe --tags --long || echo "unknown version") BUILD_TIME=$(shell date -u) BUILD_TAGS='fakeDNS stats' -GOBUILD=go build -ldflags '-X "github.com/xjasonlyu/tun2socks/constant.Version=$(VERSION)" \ - -X "github.com/xjasonlyu/tun2socks/constant.BuildTime=$(BUILD_TIME)" \ - -w -s' +GOBUILD=go build -ldflags '-s -w -X "github.com/xjasonlyu/tun2socks/constant.Version=$(VERSION)"' all: build diff --git a/cmd/main.go b/cmd/main.go index 2e23e15..c7f9ca6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,6 +7,7 @@ import ( "net" "os" "os/signal" + "runtime" "strings" "syscall" "time" @@ -80,12 +81,18 @@ func init() { args.UdpTimeout = flag.Duration("udpTimeout", 30*time.Second, "UDP session timeout") } +func showVersion() { + version := strings.Split(C.Version, "-") + fmt.Printf("Go-tun2socks %s (%s)\n", version[0], version[1]) + fmt.Printf("%s/%s, %s, %s\n", runtime.GOOS, runtime.GOARCH, runtime.Version(), version[2]) +} + func main() { // Parse args flag.Parse() if *args.Version { - fmt.Println("Go-tun2socks", C.Version, C.BuildTime) + showVersion() os.Exit(0) } diff --git a/constant/version.go b/constant/version.go index 17a26f8..abe6b3b 100644 --- a/constant/version.go +++ b/constant/version.go @@ -1,6 +1,5 @@ package constant var ( - Version = "unknown version" - BuildTime = "unknown time" + Version = "version-build-tag" )