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

Function PortForwardsRuleListDelete

module/portforward/portforward.go:166–187  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

164}
165
166func PortForwardsRuleListDelete(key string) error {
167 config.ConfigureMutex.Lock()
168 defer config.ConfigureMutex.Unlock()
169
170 index := -1
171
172 for i := range config.Configure.PortForwardsRuleList {
173 if config.Configure.PortForwardsRuleList[i].Key == key {
174 index = i
175 break
176 }
177 }
178
179 if index == -1 {
180 return fmt.Errorf("找不到需要删除的端口转发规则")
181 }
182
183 config.Configure.PortForwardsRuleList[index].StopAllProxys()
184
185 config.Configure.PortForwardsRuleList = DeletePortForwardsRuleListSlice(config.Configure.PortForwardsRuleList, index)
186 return config.Save()
187}
188
189func EnablePortForwardsRuleByKey(key string, enable bool) error {
190 config.ConfigureMutex.Lock()

Callers

nothing calls this directly

Calls 3

SaveFunction · 0.92
StopAllProxysMethod · 0.45

Tested by

no test coverage detected