MCPcopy
hub / github.com/gdy666/lucky / EnableReverseProxySubRule

Function EnableReverseProxySubRule

module/reverseproxy/reverseproxy.go:142–173  ·  view source on GitHub ↗
(ruleKey, proxyKey string, enable bool)

Source from the content-addressed store, hash-verified

140}
141
142func EnableReverseProxySubRule(ruleKey, proxyKey string, enable bool) error {
143 config.ConfigureMutex.Lock()
144 defer config.ConfigureMutex.Unlock()
145 ruleIndex := -1
146
147 for i := range config.Configure.ReverseProxyRuleList {
148 if config.Configure.ReverseProxyRuleList[i].RuleKey == ruleKey {
149 ruleIndex = i
150 break
151 }
152 }
153 if ruleIndex == -1 {
154 return fmt.Errorf("开关反向代理子规则失败,ruleKey %s 未找到", ruleKey)
155 }
156
157 proxyIndex := -1
158 for i := range config.Configure.ReverseProxyRuleList[ruleIndex].ProxyList {
159 if config.Configure.ReverseProxyRuleList[ruleIndex].ProxyList[i].Key == proxyKey {
160 proxyIndex = i
161 break
162 }
163 }
164
165 if proxyIndex == -1 {
166 return fmt.Errorf("开关反向代理子规则失败,proxyKey %s 未找到", proxyKey)
167 }
168
169 config.Configure.ReverseProxyRuleList[ruleIndex].ProxyList[proxyIndex].Enable = enable
170
171 return config.Save()
172
173}
174
175func UpdateReverseProxyRulet(rule reverseproxyconf.ReverseProxyRule) error {
176 config.ConfigureMutex.Lock()

Callers

nothing calls this directly

Calls 1

SaveFunction · 0.92

Tested by

no test coverage detected