github.com/yaling888/clash@v1.53.0/constant/script.go (about) 1 package constant 2 3 const ScriptRuleGeoSiteTarget = "__WhateverTarget__" 4 5 var ( 6 scriptRuleProviders = map[string]Rule{} 7 GetScriptProxyProviders = defaultProxyProvidersGetter 8 9 scriptRuleProvidersBackup map[string]Rule 10 scriptProxyProvidersGetterBackup func() map[string][]Proxy 11 ) 12 13 type Matcher interface { 14 Name() string 15 Eval(metadata *Metadata) (string, error) 16 Match(metadata *Metadata) (bool, error) 17 } 18 19 func defaultProxyProvidersGetter() map[string][]Proxy { 20 return nil 21 } 22 23 func SetScriptRuleProviders(rp map[string]Rule) { 24 scriptRuleProviders = rp 25 } 26 27 func GetScriptRuleProviders() map[string]Rule { 28 return scriptRuleProviders 29 } 30 31 func BackupScriptState() { 32 scriptRuleProvidersBackup = scriptRuleProviders 33 scriptProxyProvidersGetterBackup = GetScriptProxyProviders 34 } 35 36 func RestoreScriptState() { 37 scriptRuleProviders = scriptRuleProvidersBackup 38 GetScriptProxyProviders = scriptProxyProvidersGetterBackup 39 40 scriptRuleProvidersBackup = nil 41 scriptProxyProvidersGetterBackup = nil 42 }