Browse Source

update: compile with go version

v1.x.x
dnomd343 2 years ago
parent
commit
2d17a18f08
  1. 3
      Dockerfile
  2. 6
      cmd/xproxy.go

3
Dockerfile

@ -30,7 +30,8 @@ RUN ls /tmp/*ray | xargs -P0 -n1 upx -9
FROM golang:1.18-alpine3.16 AS xproxy FROM golang:1.18-alpine3.16 AS xproxy
COPY . /XProxy COPY . /XProxy
WORKDIR /XProxy WORKDIR /XProxy
RUN env CGO_ENABLED=0 go build -v -o xproxy -trimpath -ldflags "-s -w" ./cmd/ && mv ./xproxy /tmp/ RUN env CGO_ENABLED=0 go build -v -o xproxy -trimpath \
-ldflags "-X 'main.goVersion=$(go version)' -s -w" ./cmd/ && mv ./xproxy /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/xproxy RUN upx -9 /tmp/xproxy

6
cmd/xproxy.go

@ -10,8 +10,7 @@ import (
"strconv" "strconv"
) )
var version = "0.9.1" var version = "0.9.2"
var v4RouteTable = 100 var v4RouteTable = 100
var v6RouteTable = 106 var v6RouteTable = 106
var v4TProxyPort = 7288 var v4TProxyPort = 7288
@ -19,6 +18,7 @@ var v6TProxyPort = 7289
var configDir = "/etc/xproxy" var configDir = "/etc/xproxy"
var assetFile = "/assets.tar.xz" var assetFile = "/assets.tar.xz"
var goVersion string
var subProcess []*process.Process var subProcess []*process.Process
var assetDir, exposeDir, configFile string var assetDir, exposeDir, configFile string
@ -71,7 +71,7 @@ func main() {
xproxyInit() xproxyInit()
var settings config.Config var settings config.Config
log.Infof("XProxy %s start", version) log.Infof("XProxy %s start (%s)", version, goVersion)
config.Load(configFile, &settings) config.Load(configFile, &settings)
loadNetwork(&settings) loadNetwork(&settings)
loadProxy(&settings) loadProxy(&settings)

Loading…
Cancel
Save