(key string)
| 164 | } |
| 165 | |
| 166 | func 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 | |
| 189 | func EnablePortForwardsRuleByKey(key string, enable bool) error { |
| 190 | config.ConfigureMutex.Lock() |
nothing calls this directly
no test coverage detected