Browse Source

update: compile with go version

v1.x.x
dnomd343 2 years ago
parent
commit
2d17a18f08
  1. 3
      Dockerfile
  2. 24
      cmd/network/dns.go
  3. 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
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

24
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)
}

6
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)

Loading…
Cancel
Save