From 4b305763125bc86ea6bf8afdee82a9aa1be6810a Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Mon, 15 Aug 2022 20:20:14 +0800 Subject: [PATCH] update: remove ip forward options --- src/config.go | 19 ++++++++----------- src/load.go | 2 +- src/main.go | 10 ++-------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/config.go b/src/config.go index d1cca44..8f108e1 100644 --- a/src/config.go +++ b/src/config.go @@ -14,13 +14,10 @@ var dnsServer []string var v4Gateway string var v4Address string -var v4Forward bool - var v6Gateway string var v6Address string -var v6Forward bool -type netConfig struct { +type NetConfig struct { Gateway string `yaml:"gateway"` // network gateway Address string `yaml:"address"` // network address Forward bool `yaml:"forward"` // enabled net forward @@ -37,8 +34,8 @@ type Config struct { Network struct { DNS []string `yaml:"dns"` // system dns server ByPass []string `yaml:"bypass"` // cidr bypass list - IPv4 netConfig `yaml:"ipv4"` // ipv4 network configure - IPv6 netConfig `yaml:"ipv6"` // ipv6 network configure + IPv4 NetConfig `yaml:"ipv4"` // ipv4 network configure + IPv6 NetConfig `yaml:"ipv6"` // ipv6 network configure } } @@ -102,10 +99,6 @@ func loadConfig(rawConfig []byte) { log.Info("IPv4 bypass CIDR -> ", v4Bypass) log.Info("IPv6 bypass CIDR -> ", v6Bypass) - v4Forward = config.Network.IPv4.Forward - v6Forward = config.Network.IPv6.Forward - log.Infof("IP forward -> IPv4 = %v | IPv6 = %v", v4Forward, v6Forward) - v4Address = config.Network.IPv4.Address v4Gateway = config.Network.IPv4.Gateway if v4Address != "" && !isIPv4(v4Address, true) { @@ -126,10 +119,14 @@ func loadConfig(rawConfig []byte) { } log.Infof("IPv6 -> address = %s | gateway = %s", v6Address, v6Gateway) + enableSniff = config.Proxy.Sniff + log.Infof("Connection sniff -> %v", enableSniff) + enableRedirect = config.Proxy.Redirect + log.Infof("Connection redirect -> %v", enableRedirect) httpInbounds = config.Proxy.Http log.Infof("Http inbounds -> %v", httpInbounds) socksInbounds = config.Proxy.Socks - log.Infof("Socks inbounds -> %v", socksInbounds) + log.Infof("Socks5 inbounds -> %v", socksInbounds) addOnInbounds = config.Proxy.AddOn log.Infof("Add-on inbounds -> %v", addOnInbounds) } diff --git a/src/load.go b/src/load.go index bb954b8..bc43081 100644 --- a/src/load.go +++ b/src/load.go @@ -214,7 +214,7 @@ func loadProxy(configDir string, exposeDir string) { inboundsObject.Inbounds = append(inboundsObject.Inbounds, addon) } inboundsConfig, _ := json.MarshalIndent(inboundsObject, "", " ") // json encode - saveConfig(configDir, "inbounds", string(inboundsConfig), true) + saveConfig(configDir, "inbounds", string(inboundsConfig)+"\n", true) for _, configFile := range listFolder(exposeDir+"/config", ".json") { if configFile == "log.json" || configFile == "inbounds.json" { diff --git a/src/main.go b/src/main.go index a35f7d4..41cc999 100644 --- a/src/main.go +++ b/src/main.go @@ -9,9 +9,8 @@ var logLevel = "warning" var v4TProxyPort = 7288 var v6TProxyPort = 7289 -var enableSniff = false -var enableRedirect = true - +var enableSniff bool +var enableRedirect bool var httpInbounds map[string]int var socksInbounds map[string]int var addOnInbounds []interface{} @@ -25,10 +24,5 @@ func main() { panic(err) } loadConfig(content) - - //fmt.Println(httpInbounds) - //fmt.Println(socksInbounds) - //fmt.Println(addOnInbounds) loadProxy("/etc/xproxy/config", "/xproxy") - }