fix: config code merge

This commit is contained in:
wwqgtxx 2022-12-06 10:13:05 +08:00
parent b5b06ea49c
commit cd99b2e795
4 changed files with 56 additions and 58 deletions

View file

@ -30,7 +30,6 @@ import (
"github.com/Dreamacro/clash/dns"
L "github.com/Dreamacro/clash/listener"
LC "github.com/Dreamacro/clash/listener/config"
"github.com/Dreamacro/clash/listener/tunnel"
"github.com/Dreamacro/clash/log"
R "github.com/Dreamacro/clash/rules"
RP "github.com/Dreamacro/clash/rules/provider"
@ -53,8 +52,6 @@ type General struct {
GeodataLoader string `json:"geodata-loader"`
TCPConcurrent bool `json:"tcp-concurrent"`
EnableProcess bool `json:"enable-process"`
Tun LC.Tun `json:"tun"`
TuicServer LC.TuicServer `json:"tuic-server"`
Sniffing bool `json:"sniffing"`
EBpf EBpf `json:"-"`
}
@ -66,6 +63,8 @@ type Inbound struct {
RedirPort int `json:"redir-port"`
TProxyPort int `json:"tproxy-port"`
MixedPort int `json:"mixed-port"`
Tun LC.Tun `json:"tun"`
TuicServer LC.TuicServer `json:"tuic-server"`
ShadowSocksConfig string `json:"ss-config"`
VmessConfig string `json:"vmess-config"`
Authentication []string `json:"authentication"`
@ -157,7 +156,7 @@ type Config struct {
Listeners map[string]C.InboundListener
Providers map[string]providerTypes.ProxyProvider
RuleProviders map[string]providerTypes.RuleProvider
Tunnels []tunnel.Tunnel
Tunnels []LC.Tunnel
Sniffer *Sniffer
TLS *TLS
}
@ -248,7 +247,7 @@ type RawConfig struct {
Secret string `yaml:"secret"`
Interface string `yaml:"interface-name"`
RoutingMark int `yaml:"routing-mark"`
Tunnels []tunnel.Tunnel `yaml:"tunnels"`
Tunnels []LC.Tunnel `yaml:"tunnels"`
GeodataMode bool `yaml:"geodata-mode"`
GeodataLoader string `yaml:"geodata-loader"`
TCPConcurrent bool `yaml:"tcp-concurrent" json:"tcp-concurrent"`

View file

@ -29,7 +29,6 @@ import (
LC "github.com/Dreamacro/clash/listener/config"
"github.com/Dreamacro/clash/listener/inner"
"github.com/Dreamacro/clash/listener/tproxy"
T "github.com/Dreamacro/clash/listener/tunnel"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/tunnel"
)
@ -115,6 +114,8 @@ func GetGeneral() *config.General {
RedirPort: ports.RedirPort,
TProxyPort: ports.TProxyPort,
MixedPort: ports.MixedPort,
Tun: listener.GetTunConf(),
TuicServer: listener.GetTuicConf(),
ShadowSocksConfig: ports.ShadowSocksConfig,
VmessConfig: ports.VmessConfig,
Authentication: authenticator,
@ -125,8 +126,6 @@ func GetGeneral() *config.General {
LogLevel: log.Level(),
IPv6: !resolver.DisableIPv6,
GeodataLoader: G.LoaderName(),
Tun: listener.GetTunConf(),
TuicServer: listener.GetTuicConf(),
Interface: dialer.DefaultInterface.Load(),
Sniffing: tunnel.IsSniffing(),
TCPConcurrent: dialer.GetDial(),
@ -304,7 +303,7 @@ func updateSniffer(sniffer *config.Sniffer) {
}
}
func updateTunnels(tunnels []T.Tunnel) {
func updateTunnels(tunnels []LC.Tunnel) {
listener.PatchTunnel(tunnels, tunnel.TCPIn(), tunnel.UDPIn())
}

View file

@ -1,4 +1,4 @@
package tunnel
package config
import (
"fmt"

View file

@ -625,7 +625,7 @@ func ReCreateAutoRedir(ifaceNames []string, tcpIn chan<- C.ConnContext, _ chan<-
log.Infoln("Auto redirect proxy listening at: %s, attached tc ebpf program to interfaces %v", autoRedirListener.Address(), autoRedirProgram.RawNICs())
}
func PatchTunnel(tunnels []tunnel.Tunnel, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter) {
func PatchTunnel(tunnels []LC.Tunnel, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter) {
tunnelMux.Lock()
defer tunnelMux.Unlock()
@ -664,7 +664,7 @@ func PatchTunnel(tunnels []tunnel.Tunnel, tcpIn chan<- C.ConnContext, udpIn chan
newElm := lo.FlatMap(
tunnels,
func(tunnel tunnel.Tunnel, _ int) []addrProxy {
func(tunnel LC.Tunnel, _ int) []addrProxy {
return lo.Map(
tunnel.Network,
func(network string, _ int) addrProxy {