From bf6bfdd9306f3d285023472be137e5feb8bfba95 Mon Sep 17 00:00:00 2001 From: "maze.y2b@gmail.com" Date: Thu, 2 Dec 2021 18:06:14 +0800 Subject: [PATCH] [test] --- tunnel/tunnel.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index ba5ef9c0..c5973c85 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -20,13 +20,14 @@ import ( ) var ( - tcpQueue = make(chan C.ConnContext, 200) - udpQueue = make(chan *inbound.PacketAdapter, 200) - natTable = nat.New() - rules []C.Rule - proxies = make(map[string]C.Proxy) - providers map[string]provider.ProxyProvider - configMux sync.RWMutex + tcpQueue = make(chan C.ConnContext, 200) + udpQueue = make(chan *inbound.PacketAdapter, 200) + natTable = nat.New() + rules []C.Rule + proxies = make(map[string]C.Proxy) + providers map[string]provider.ProxyProvider + ruleProviders map[string]provider.RuleProvider + configMux sync.RWMutex // Outbound Rule mode = Rule @@ -57,9 +58,10 @@ func Rules() []C.Rule { } // UpdateRules handle update rules -func UpdateRules(newRules []C.Rule) { +func UpdateRules(newRules []C.Rule, rp map[string]provider.RuleProvider) { configMux.Lock() rules = newRules + ruleProviders = rp configMux.Unlock() } @@ -73,6 +75,10 @@ func Providers() map[string]provider.ProxyProvider { return providers } +func RuleProviders() map[string]provider.RuleProvider { + return ruleProviders +} + // UpdateProxies handle update proxies func UpdateProxies(newProxies map[string]C.Proxy, newProviders map[string]provider.ProxyProvider) { configMux.Lock()