fix build crash

This commit is contained in:
Jason
2019-08-14 21:43:38 +08:00
parent 899e154c92
commit 944292048f
3 changed files with 7 additions and 7 deletions
+5 -3
View File
@@ -4,15 +4,17 @@ CMD_DIR=$(shell pwd)/cmd
VERSION=$(shell git describe --tags --long || echo "unknown version")
BUILD_TIME=$(shell date -u)
BUILD_TAGS='fakeDNS stats'
BUILD_LDFLAGS='-s -w -X "github.com/xjasonlyu/tun2socks/constant.Version=$(VERSION)" -X "github.com/xjasonlyu/tun2socks/constant.BuildTime=$(BUILD_TIME)"'
GOBUILD=go build -ldflags -X "github.com/xjasonlyu/tun2socks/constant.Version=$(VERSION)" \
-X "github.com/xjasonlyu/tun2socks/constant.BuildTime=$(BUILD_TIME)" \
-s -w
all: build
build:
cd $(CMD_DIR) && go build -ldflags $(BUILD_LDFLAGS) -v -tags $(BUILD_TAGS) -o $(BUILD_DIR)/$(NAME)
cd $(CMD_DIR) && $(GOBUILD) -v -tags $(BUILD_TAGS) -o $(BUILD_DIR)/$(NAME)
debug:
cd $(CMD_DIR) && go build -ldflags $(BUILD_LDFLAGS) -v -tags $(BUILD_TAGS) -race -o $(BUILD_DIR)/$(NAME)
cd $(CMD_DIR) && $(GOBUILD) -v -tags $(BUILD_TAGS) -race -o $(BUILD_DIR)/$(NAME)
clean:
rm -rf $(BUILD_DIR)
-1
View File
@@ -18,7 +18,6 @@ func init() {
// Set stats variables
session.ServeAddr = *args.StatsAddr
session.StatsVersion = version
// Start session stater
sessionStater.Start()
+2 -3
View File
@@ -12,6 +12,7 @@ import (
"github.com/xjasonlyu/tun2socks/common/log"
"github.com/xjasonlyu/tun2socks/common/queue"
"github.com/xjasonlyu/tun2socks/common/stats"
C "github.com/xjasonlyu/tun2socks/constant"
)
const maxCompletedSessions = 100
@@ -19,8 +20,6 @@ const maxCompletedSessions = 100
var (
ServeAddr = "localhost:6001"
ServePath = "/stats/session/plain"
StatsVersion = ""
)
type simpleSessionStater struct {
@@ -87,7 +86,7 @@ table, th, td {
text-align: right;
padding: 4;
}</style><title>Go-tun2socks Sessions</title></head>`)
_, _ = fmt.Fprintf(w, "<h2>Go-tun2socks %s</h2>", StatsVersion)
_, _ = fmt.Fprintf(w, "<h2>Go-tun2socks %s</h2>", C.Version)
_, _ = fmt.Fprintf(w, "<h3>Now: %s ; Uptime: %s</h3>", now(), uptime())
_, _ = fmt.Fprintf(w, "<p>Active sessions %d</p>", len(activeSessions))
tablePrint(w, activeSessions)