TryCopy attempts to copy files to/from the target server, first using cached credentials and then by trying all credential combinations.
(user string, concurrency int, recursive bool, sshTimeout time.Duration)
| 61 | // TryCopy attempts to copy files to/from the target server, first using cached |
| 62 | // credentials and then by trying all credential combinations. |
| 63 | func (cc *ScpController) TryCopy(user string, concurrency int, recursive bool, sshTimeout time.Duration) { |
| 64 | cc.sshTimeout = sshTimeout |
| 65 | cc.concurrency = concurrency |
| 66 | cc.recursive = recursive |
| 67 | |
| 68 | if host, path, ok := parseRemotePath(cc.source); ok { |
| 69 | cc.destIP = config.ResolveAlias(host, cc.configuration) |
| 70 | cc.source = formatRemotePath(cc.destIP, path) |
| 71 | } else if host, path, ok := parseRemotePath(cc.destination); ok { |
| 72 | cc.destIP = config.ResolveAlias(host, cc.configuration) |
| 73 | cc.destination = formatRemotePath(cc.destIP, path) |
| 74 | } else { |
| 75 | utils.Errorln("Unable to determine SCP direction: no valid remote path found in source or destination") |
| 76 | return |
| 77 | } |
| 78 | var targetServer *config.ServerListConfig |
| 79 | targetServer, cc.cacheIndex, cc.cacheIsFound = config.SelectServerCache(user, cc.destIP, cc.configuration) |
| 80 | |
| 81 | if cc.cacheIsFound { |
| 82 | utils.Infof("The cache for %s is found, which will be used to try.\n", cc.destIP) |
| 83 | cc.tryCopyWithCache(user, targetServer) |
| 84 | } else { |
| 85 | utils.Warnf("The cache for %s could not be found. Start trying to login.\n\n", cc.destIP) |
| 86 | cc.tryCopyWithoutCache(user) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func (cc *ScpController) tryCopyWithCache(user string, targetServer *config.ServerListConfig) { |
| 91 | lan := &launcher.ScpLauncher{ |