mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-08 02:00:43 +08:00
update version output
This commit is contained in:
4
Makefile
4
Makefile
@@ -4,9 +4,7 @@ CMD_DIR=$(shell pwd)/cmd
|
|||||||
VERSION=$(shell git describe --tags --long || echo "unknown version")
|
VERSION=$(shell git describe --tags --long || echo "unknown version")
|
||||||
BUILD_TIME=$(shell date -u)
|
BUILD_TIME=$(shell date -u)
|
||||||
BUILD_TAGS='fakeDNS stats'
|
BUILD_TAGS='fakeDNS stats'
|
||||||
GOBUILD=go build -ldflags '-X "github.com/xjasonlyu/tun2socks/constant.Version=$(VERSION)" \
|
GOBUILD=go build -ldflags '-s -w -X "github.com/xjasonlyu/tun2socks/constant.Version=$(VERSION)"'
|
||||||
-X "github.com/xjasonlyu/tun2socks/constant.BuildTime=$(BUILD_TIME)" \
|
|
||||||
-w -s'
|
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -80,12 +81,18 @@ func init() {
|
|||||||
args.UdpTimeout = flag.Duration("udpTimeout", 30*time.Second, "UDP session timeout")
|
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() {
|
func main() {
|
||||||
// Parse args
|
// Parse args
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *args.Version {
|
if *args.Version {
|
||||||
fmt.Println("Go-tun2socks", C.Version, C.BuildTime)
|
showVersion()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package constant
|
package constant
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Version = "unknown version"
|
Version = "version-build-tag"
|
||||||
BuildTime = "unknown time"
|
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user