Browse Source

feat: fetch golang info from runtime

v1.x.x v1.0.1
dnomd343 2 years ago
parent
commit
2c6e14f3ee
  1. 3
      Dockerfile
  2. 8
      cmd/xproxy.go

3
Dockerfile

@ -35,8 +35,7 @@ FROM ${GOLANG_IMG} AS xproxy
COPY . /XProxy
WORKDIR /XProxy
RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -o xproxy -trimpath \
-ldflags "-X 'main.goVersion=$(go version)' -s -w" ./cmd/ && mv ./xproxy /tmp/
RUN env CGO_ENABLED=0 go build -v -o xproxy -trimpath -ldflags "-s -w" ./cmd/ && mv ./xproxy /tmp/
FROM alpine:3.16 AS asset
WORKDIR /tmp/

8
cmd/xproxy.go

@ -11,6 +11,7 @@ import (
"io"
"os"
"path"
"runtime"
"strconv"
)
@ -22,7 +23,6 @@ var v6TProxyPort = 7289
var configDir = "/etc/xproxy"
var assetFile = "/assets.tar.xz"
var goVersion string
var subProcess []*process.Process
var assetDir, exposeDir, configFile string
@ -53,8 +53,8 @@ func xproxyInit() {
isDebug := flag.Bool("debug", os.Getenv("DEBUG") == "true", "Enable debug mode")
configName := flag.String("config", xproxyConfig, "Config file name")
flag.Parse()
if *isVersion {
fmt.Printf("XProxy version %s (%s)\n", version, goVersion) // show version info and exit
if *isVersion { // show version info and exit
fmt.Printf("XProxy version %s (%s %s/%s)\n", version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
os.Exit(0)
}
@ -96,7 +96,7 @@ func main() {
}()
xproxyInit()
var settings config.Config
log.Infof("XProxy %s start (%s)", version, goVersion)
log.Infof("XProxy %s start (%s %s/%s)", version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
config.Load(configFile, &settings)
loadNetwork(&settings)
loadProxy(&settings)

Loading…
Cancel
Save