diff --git a/cmd/config/decode.go b/cmd/config/decode.go index fe31904..ce3654d 100644 --- a/cmd/config/decode.go +++ b/cmd/config/decode.go @@ -88,7 +88,14 @@ func decodeIPv6(rawConfig *yamlConfig, config *Config) { func decodeProxy(rawConfig *yamlConfig, config *Config) { config.Proxy = rawConfig.Proxy + if config.Proxy.Core == "" { + config.Proxy.Core = "xray" // use xray in default + } + if config.Proxy.Core != "xray" && config.Proxy.Core != "v2ray" && config.Proxy.Core != "sagray" { + log.Warningf("Unknown core type -> %s", config.Proxy.Core) + } log.Debugf("Proxy log level -> %s", config.Proxy.Log) + log.Debugf("Core type -> %s", config.Proxy.Core) log.Debugf("Http inbounds -> %v", config.Proxy.Http) log.Debugf("Socks5 inbounds -> %v", config.Proxy.Socks) log.Debugf("Add-on inbounds -> %v", config.Proxy.AddOn) diff --git a/cmd/controller.go b/cmd/controller.go index 979b280..7bbdd58 100644 --- a/cmd/controller.go +++ b/cmd/controller.go @@ -58,7 +58,15 @@ func runScript(settings *config.Config) { } func runProxy(settings *config.Config) { - runProcess("xray", "-confdir", configDir) + if settings.Proxy.Core == "xray" { // xray-core + runProcess("xray", "-confdir", configDir) + } else if settings.Proxy.Core == "v2ray" { // v2fly-core + runProcess("v2ray", "-confdir", configDir) + } else if settings.Proxy.Core == "sagray" { // sager-core + runProcess("sagray", "run", "-confdir", configDir) + } else { + log.Panicf("Unknown core type -> %s", settings.Proxy.Core) + } } func runRadvd(settings *config.Config) { diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 554a7b9..6d448cc 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -6,6 +6,7 @@ import ( type Config struct { Log string `yaml:"log" json:"json"` + Core string `yaml:"core" json:"core"` Http map[string]int `yaml:"http" json:"http"` Socks map[string]int `yaml:"socks" json:"socks"` AddOn []interface{} `yaml:"addon" json:"addon"` @@ -30,6 +31,9 @@ func loadInbounds(config *Config) string { DestOverride: []string{"http", "tls", "quic"}, DomainsExcluded: config.Sniff.Exclude, } + if config.Core == "v2ray" { // PATCH: v2fly-core v4 not support quic sniff + sniff.DestOverride = sniff.DestOverride[:len(sniff.DestOverride)-1] + } var inbounds []interface{} inbounds = append(inbounds, loadTProxyConfig("tproxy", config.V4TProxyPort, sniff)) inbounds = append(inbounds, loadTProxyConfig("tproxy6", config.V6TProxyPort, sniff))