Browse Source

Chore: move all to version

pull/133/head
xjasonlyu 3 years ago
parent
commit
7ac97016fe
  1. 8
      internal/debug/debug.go
  2. 7
      internal/version/debug.go
  3. 2
      internal/version/debug_on.go
  4. 2
      internal/version/module.go
  5. 4
      internal/version/version.go
  6. 6
      stats/server.go

8
internal/debug/debug.go

@ -1,8 +0,0 @@
// Package debug indicates if the debug tag is enabled at build time.
package debug
var _debug = false
func Debug() bool {
return _debug
}

7
internal/version/debug.go

@ -0,0 +1,7 @@
package version
var _debug = false
func Debug() bool {
return _debug
}

2
internal/debug/debug_on.go → internal/version/debug_on.go

@ -1,6 +1,6 @@
//go:build debug
package debug
package version
func init() {
_debug = true

2
internal/module/module.go → internal/version/module.go

@ -1,4 +1,4 @@
package module
package version
import (
"runtime/debug"

4
internal/version/version.go

@ -4,8 +4,6 @@ import (
"fmt"
"runtime"
"strings"
"github.com/xjasonlyu/tun2socks/v2/internal/debug"
)
const Name = "tun2socks"
@ -25,7 +23,7 @@ func versionize(s string) string {
}
func String() string {
if !debug.Debug() {
if !Debug() {
return fmt.Sprintf("%s-%s", Name, versionize(Version))
}
return fmt.Sprintf("%s-%s (debug)", Name, versionize(Version))

6
stats/server.go

@ -8,8 +8,6 @@ import (
"strings"
"time"
"github.com/xjasonlyu/tun2socks/v2/internal/debug"
"github.com/xjasonlyu/tun2socks/v2/internal/module"
V "github.com/xjasonlyu/tun2socks/v2/internal/version"
"github.com/xjasonlyu/tun2socks/v2/log"
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic"
@ -217,7 +215,7 @@ func version(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, render.M{
"version": V.Version,
"commit": V.GitCommit,
"debug": debug.Debug(),
"modules": module.Info(),
"debug": V.Debug(),
"modules": V.Info(),
})
}

Loading…
Cancel
Save