fix: custom timeout only for "server add"

This commit is contained in:
2024-06-25 16:13:57 +02:00
parent 7b7e1bfa97
commit 1fe601cd16
4 changed files with 43 additions and 15 deletions

View File

@ -144,6 +144,11 @@ of your ~/.ssh/config. Checks for a valid online domain will be skipped:
name = internal.ValidateDomain(c)
}
// NOTE(d1): reasonable 5 second timeout for connections which can't
// succeed. The connection is attempted twice, so this results in 10
// seconds.
timeout := client.WithTimeout(5)
if local {
created, err := createServerDir(name)
if err != nil {
@ -152,7 +157,7 @@ of your ~/.ssh/config. Checks for a valid online domain will be skipped:
logrus.Debugf("attempting to create client for %s", name)
if _, err := client.New(name); err != nil {
if _, err := client.New(name, timeout); err != nil {
cleanUp(name)
logrus.Fatal(err)
}
@ -184,9 +189,8 @@ of your ~/.ssh/config. Checks for a valid online domain will be skipped:
}
logrus.Debugf("attempting to create client for %s", name)
if _, err := client.New(name); err != nil {
if _, err := client.New(name, timeout); err != nil {
cleanUp(name)
logrus.Debugf("failed to construct client for %s, saw %s", name, err.Error())
logrus.Fatal(sshPkg.Fatal(name, err))
}