Browse Source

update: remove ip forward options

v1.x.x
dnomd343 2 years ago
parent
commit
4b30576312
  1. 19
      src/config.go
  2. 2
      src/load.go
  3. 10
      src/main.go

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

2
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" {

10
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")
}

Loading…
Cancel
Save