(req dto.ProxyUpdate)
| 273 | } |
| 274 | |
| 275 | func (u *SettingService) UpdateProxy(req dto.ProxyUpdate) error { |
| 276 | if req.ProxyType == "https" || req.ProxyType == "http" { |
| 277 | req.ProxyUrl = req.ProxyType + "://" + req.ProxyUrl |
| 278 | } |
| 279 | if err := checkProxy(req); err != nil { |
| 280 | return err |
| 281 | } |
| 282 | if err := settingRepo.Update("ProxyUrl", req.ProxyUrl); err != nil { |
| 283 | return err |
| 284 | } |
| 285 | if err := settingRepo.Update("ProxyType", req.ProxyType); err != nil { |
| 286 | return err |
| 287 | } |
| 288 | if err := settingRepo.Update("ProxyPort", req.ProxyPort); err != nil { |
| 289 | return err |
| 290 | } |
| 291 | if err := settingRepo.Update("ProxyUser", req.ProxyUser); err != nil { |
| 292 | return err |
| 293 | } |
| 294 | pass, _ := encrypt.StringEncrypt(req.ProxyPasswd) |
| 295 | if err := settingRepo.Update("ProxyPasswd", pass); err != nil { |
| 296 | return err |
| 297 | } |
| 298 | if err := settingRepo.Update("ProxyPasswdKeep", req.ProxyPasswdKeep); err != nil { |
| 299 | return err |
| 300 | } |
| 301 | if err := xpack.MultiNodeProvider.ProxyDocker(loadDockerProxy(req)); err != nil { |
| 302 | return err |
| 303 | } |
| 304 | syncScope := constant.SyncSystemProxy |
| 305 | if req.WithDockerRestart { |
| 306 | syncScope = constant.SyncSystemProxyWithRestartDocker |
| 307 | } |
| 308 | if err := xpack.MultiNodeProvider.Sync(syncScope); err != nil { |
| 309 | global.LOG.Errorf("sync proxy to node failed, err: %v", err) |
| 310 | } |
| 311 | return nil |
| 312 | } |
| 313 | |
| 314 | func (u *SettingService) UpdatePort(port uint) error { |
| 315 | if common.ScanPort(int(port)) { |
nothing calls this directly
no test coverage detected