UnsetAlias removes the configured alias from all matching server entries.
()
| 70 | |
| 71 | // UnsetAlias removes the configured alias from all matching server entries. |
| 72 | func (ac *AliasController) UnsetAlias() bool { |
| 73 | var beUnsetCount int |
| 74 | for index, server := range ac.configuration.ServerLists { |
| 75 | if server.Alias == ac.alias { |
| 76 | ac.configuration.ServerLists[index].Alias = "" |
| 77 | utils.Infof( |
| 78 | "The server %s@%s:%s's alias \"%s\" will be unset.\n", |
| 79 | server.User, server.IP, server.Port, ac.alias) |
| 80 | beUnsetCount++ |
| 81 | } |
| 82 | } |
| 83 | if beUnsetCount == 0 { |
| 84 | utils.Warnf("No matching alias: %s\n", ac.alias) |
| 85 | return false |
| 86 | } |
| 87 | if err := config.UpdateConfig(ac.configuration); err == nil { |
| 88 | utils.Infof("%d cache information has been changed.\n", beUnsetCount) |
| 89 | return true |
| 90 | } |
| 91 | utils.Errorln("Main config update failed.") |
| 92 | return false |
| 93 | } |
| 94 | |
| 95 | // NewAliasController creates a new AliasController for the given target IP, configuration, and alias. |
| 96 | func NewAliasController(targetIP string, configuration *config.MainConfig, alias string) *AliasController { |