This commit is contained in:
maze.y2b@gmail.com 2021-12-02 18:06:14 +08:00
parent c7b257b188
commit bf6bfdd930

View file

@ -20,13 +20,14 @@ import (
) )
var ( var (
tcpQueue = make(chan C.ConnContext, 200) tcpQueue = make(chan C.ConnContext, 200)
udpQueue = make(chan *inbound.PacketAdapter, 200) udpQueue = make(chan *inbound.PacketAdapter, 200)
natTable = nat.New() natTable = nat.New()
rules []C.Rule rules []C.Rule
proxies = make(map[string]C.Proxy) proxies = make(map[string]C.Proxy)
providers map[string]provider.ProxyProvider providers map[string]provider.ProxyProvider
configMux sync.RWMutex ruleProviders map[string]provider.RuleProvider
configMux sync.RWMutex
// Outbound Rule // Outbound Rule
mode = Rule mode = Rule
@ -57,9 +58,10 @@ func Rules() []C.Rule {
} }
// UpdateRules handle update rules // UpdateRules handle update rules
func UpdateRules(newRules []C.Rule) { func UpdateRules(newRules []C.Rule, rp map[string]provider.RuleProvider) {
configMux.Lock() configMux.Lock()
rules = newRules rules = newRules
ruleProviders = rp
configMux.Unlock() configMux.Unlock()
} }
@ -73,6 +75,10 @@ func Providers() map[string]provider.ProxyProvider {
return providers return providers
} }
func RuleProviders() map[string]provider.RuleProvider {
return ruleProviders
}
// UpdateProxies handle update proxies // UpdateProxies handle update proxies
func UpdateProxies(newProxies map[string]C.Proxy, newProviders map[string]provider.ProxyProvider) { func UpdateProxies(newProxies map[string]C.Proxy, newProviders map[string]provider.ProxyProvider) {
configMux.Lock() configMux.Lock()