From 2d17a18f0832acd2dafce5feafc8ba0c403f0b5e Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Sat, 20 Aug 2022 00:57:37 +0800 Subject: [PATCH] update: compile with go version --- Dockerfile | 3 ++- cmd/network/dns.go | 24 ++++++++++++------------ cmd/xproxy.go | 6 +++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee4dc61..50ab3fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,8 @@ RUN ls /tmp/*ray | xargs -P0 -n1 upx -9 FROM golang:1.18-alpine3.16 AS xproxy COPY . /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/ RUN upx -9 /tmp/xproxy diff --git a/cmd/network/dns.go b/cmd/network/dns.go index f81f37f..dd8aba1 100644 --- a/cmd/network/dns.go +++ b/cmd/network/dns.go @@ -1,19 +1,19 @@ package network import ( - "XProxy/cmd/common" - log "github.com/sirupsen/logrus" + "XProxy/cmd/common" + log "github.com/sirupsen/logrus" ) func loadDns(dns []string) { - if len(dns) == 0 { // without dns server - log.Info("Using system DNS server") - return - } - log.Infof("Setting up DNS server -> %v", dns) - dnsConfig := "" - for _, dnsAddr := range dns { - dnsConfig += "nameserver " + dnsAddr + "\n" - } - common.WriteFile("/etc/resolv.conf", dnsConfig, true) + if len(dns) == 0 { // without dns server + log.Info("Using system DNS server") + return + } + log.Infof("Setting up DNS server -> %v", dns) + dnsConfig := "" + for _, dnsAddr := range dns { + dnsConfig += "nameserver " + dnsAddr + "\n" + } + common.WriteFile("/etc/resolv.conf", dnsConfig, true) } diff --git a/cmd/xproxy.go b/cmd/xproxy.go index 16c6a2b..72129cf 100644 --- a/cmd/xproxy.go +++ b/cmd/xproxy.go @@ -10,8 +10,7 @@ import ( "strconv" ) -var version = "0.9.1" - +var version = "0.9.2" var v4RouteTable = 100 var v6RouteTable = 106 var v4TProxyPort = 7288 @@ -19,6 +18,7 @@ var v6TProxyPort = 7289 var configDir = "/etc/xproxy" var assetFile = "/assets.tar.xz" +var goVersion string var subProcess []*process.Process var assetDir, exposeDir, configFile string @@ -71,7 +71,7 @@ func main() { xproxyInit() var settings config.Config - log.Infof("XProxy %s start", version) + log.Infof("XProxy %s start (%s)", version, goVersion) config.Load(configFile, &settings) loadNetwork(&settings) loadProxy(&settings)