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

Method TryCopy

pkg/control/scp.go:63–88  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

61// TryCopy attempts to copy files to/from the target server, first using cached
62// credentials and then by trying all credential combinations.
63func (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
90func (cc *ScpController) tryCopyWithCache(user string, targetServer *config.ServerListConfig) {
91 lan := &launcher.ScpLauncher{

Calls 9

tryCopyWithCacheMethod · 0.95
tryCopyWithoutCacheMethod · 0.95
ResolveAliasFunction · 0.92
ErrorlnFunction · 0.92
SelectServerCacheFunction · 0.92
InfofFunction · 0.92
WarnfFunction · 0.92
parseRemotePathFunction · 0.85
formatRemotePathFunction · 0.85