MCPcopy Create free account
hub / github.com/Driver-C/tryssh / UnsetAlias

Method UnsetAlias

pkg/control/alias.go:72–93  ·  view source on GitHub ↗

UnsetAlias removes the configured alias from all matching server entries.

()

Source from the content-addressed store, hash-verified

70
71// UnsetAlias removes the configured alias from all matching server entries.
72func (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.
96func NewAliasController(targetIP string, configuration *config.MainConfig, alias string) *AliasController {

Calls 4

InfofFunction · 0.92
WarnfFunction · 0.92
UpdateConfigFunction · 0.92
ErrorlnFunction · 0.92