(user string)
| 102 | } |
| 103 | |
| 104 | func (cc *ScpController) tryCopyWithoutCache(user string) { |
| 105 | combinations := config.GenerateCombination(cc.destIP, user, cc.configuration) |
| 106 | launchers := launcher.NewScpLaunchersByCombinations(combinations, cc.source, cc.destination, |
| 107 | cc.recursive, cc.sshTimeout) |
| 108 | connectors := make([]launcher.Connector, len(launchers)) |
| 109 | for i, l := range launchers { |
| 110 | connectors[i] = l |
| 111 | } |
| 112 | hitLaunchers := ConcurrencyTryToConnect(cc.concurrency, connectors) |
| 113 | if len(hitLaunchers) > 0 { |
| 114 | utils.Infoln("Login succeeded. The cache will be added.") |
| 115 | hitLauncher := hitLaunchers[0].(*launcher.ScpLauncher) |
| 116 | newServerCache := launcher.GetConfigFromSSHConnector(&hitLauncher.SSHConnector) |
| 117 | if cc.cacheIsFound { |
| 118 | newServerCache.Alias = cc.configuration.ServerLists[cc.cacheIndex].Alias |
| 119 | utils.Infoln("The old cache will be deleted.") |
| 120 | cc.configuration.ServerLists = append( |
| 121 | cc.configuration.ServerLists[:cc.cacheIndex], cc.configuration.ServerLists[cc.cacheIndex+1:]...) |
| 122 | } |
| 123 | cc.configuration.ServerLists = append(cc.configuration.ServerLists, *newServerCache) |
| 124 | if err := config.UpdateConfig(cc.configuration); err == nil { |
| 125 | utils.Infoln("Cache added.") |
| 126 | if cc.sshTimeout > sshClientTimeoutWhenLogin { |
| 127 | hitLauncher.SSHTimeout = cc.sshTimeout |
| 128 | } else { |
| 129 | hitLauncher.SSHTimeout = sshClientTimeoutWhenLogin |
| 130 | } |
| 131 | if !hitLauncher.Launch() { |
| 132 | utils.Errorf("Login failed.\n") |
| 133 | } |
| 134 | } else { |
| 135 | utils.Errorf("Cache added failed.\n\n") |
| 136 | } |
| 137 | } else { |
| 138 | utils.Errorf("There is no password combination that can log in.\n") |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | // NewScpController creates a new ScpController for the given source, destination, and configuration. |
| 143 | func NewScpController(source string, destination string, configuration *config.MainConfig) *ScpController { |
no test coverage detected