|
|
@ -4,28 +4,60 @@ import ( |
|
|
|
"XProxy/cmd/config" |
|
|
|
"XProxy/cmd/process" |
|
|
|
log "github.com/sirupsen/logrus" |
|
|
|
"os" |
|
|
|
"strconv" |
|
|
|
) |
|
|
|
|
|
|
|
var version = "0.1.0" |
|
|
|
var version = "0.9.0" |
|
|
|
|
|
|
|
var v4RouteTable = 100 |
|
|
|
var v6RouteTable = 106 |
|
|
|
var v4TProxyPort = 7288 |
|
|
|
var v6TProxyPort = 7289 |
|
|
|
|
|
|
|
var exposeDir = "/xproxy" |
|
|
|
var configDir = "/etc/xproxy" |
|
|
|
var assetFile = "/assets.tar.xz" |
|
|
|
var assetDir = exposeDir + "/assets" |
|
|
|
var configFile = exposeDir + "/config.yml" |
|
|
|
var assetDir, exposeDir, configFile string |
|
|
|
|
|
|
|
var subProcess []*process.Process |
|
|
|
|
|
|
|
func xproxyInit() { |
|
|
|
// log format
|
|
|
|
// TODO: set log level
|
|
|
|
log.SetLevel(log.DebugLevel) |
|
|
|
// read tproxy port / route table num from env
|
|
|
|
log.SetFormatter(&log.TextFormatter{ |
|
|
|
FullTimestamp: true, |
|
|
|
TimestampFormat: "2006-01-02 15:04:05", |
|
|
|
}) |
|
|
|
if len(os.Args) > 1 && os.Args[1] == "--debug" { |
|
|
|
log.SetLevel(log.DebugLevel) |
|
|
|
} 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() { |
|
|
|