Browse Source

update: xproxy init

v1.x.x
dnomd343 2 years ago
parent
commit
fe695ff34a
  1. 46
      cmd/xproxy.go

46
cmd/xproxy.go

@ -4,28 +4,60 @@ import (
"XProxy/cmd/config" "XProxy/cmd/config"
"XProxy/cmd/process" "XProxy/cmd/process"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"os"
"strconv"
) )
var version = "0.1.0" var version = "0.9.0"
var v4RouteTable = 100 var v4RouteTable = 100
var v6RouteTable = 106 var v6RouteTable = 106
var v4TProxyPort = 7288 var v4TProxyPort = 7288
var v6TProxyPort = 7289 var v6TProxyPort = 7289
var exposeDir = "/xproxy"
var configDir = "/etc/xproxy" var configDir = "/etc/xproxy"
var assetFile = "/assets.tar.xz" var assetFile = "/assets.tar.xz"
var assetDir = exposeDir + "/assets" var assetDir, exposeDir, configFile string
var configFile = exposeDir + "/config.yml"
var subProcess []*process.Process var subProcess []*process.Process
func xproxyInit() { func xproxyInit() {
// log format log.SetFormatter(&log.TextFormatter{
// TODO: set log level FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05",
})
if len(os.Args) > 1 && os.Args[1] == "--debug" {
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)
// read tproxy port / route table num from env } else {
log.SetLevel(log.InfoLevel)
}
if os.Getenv("IPV4_TABLE") != "" {
v4RouteTable, _ = strconv.Atoi(os.Getenv("IPV4_TABLE"))
}
if os.Getenv("IPV6_TABLE") != "" {
v6RouteTable, _ = strconv.Atoi(os.Getenv("IPV6_TABLE"))
}
if os.Getenv("IPV4_TPROXY") != "" {
v4TProxyPort, _ = strconv.Atoi(os.Getenv("IPV4_TPROXY"))
}
if os.Getenv("IPV6_TPROXY") != "" {
v6TProxyPort, _ = strconv.Atoi(os.Getenv("IPV6_TPROXY"))
}
log.Debugf("IPv4 Route Table -> %d", v4RouteTable)
log.Debugf("IPv6 Route Table -> %d", v6RouteTable)
log.Debugf("IPv4 TProxy Port -> %d", v4TProxyPort)
log.Debugf("IPv6 TProxy Port -> %d", v6TProxyPort)
exposeDir = "/xproxy" // default folder
if os.Getenv("EXPOSE_DIR") != "" {
exposeDir = os.Getenv("EXPOSE_DIR")
}
assetDir = exposeDir + "/assets"
configFile = exposeDir + "/config.yml"
log.Debugf("Expose folder -> %s", exposeDir)
log.Debugf("Assets folder -> %s", assetDir)
log.Debugf("Config file -> %s", configFile)
} }
func main() { func main() {

Loading…
Cancel
Save