add timeout

This commit is contained in:
shoopea 2022-04-16 21:09:06 +08:00
parent fd62711571
commit cddb2223e9
2 changed files with 11 additions and 5 deletions

View File

@ -90,6 +90,7 @@ func (c *Config) Load() error {
ssh.PublicKeys(s.signer), ssh.PublicKeys(s.signer),
}, },
HostKeyCallback: ssh.InsecureIgnoreHostKey(), HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Timeout: 5 * time.Second,
} }
s.client, err = ssh.Dial("tcp", v.Addr, s.config) s.client, err = ssh.Dial("tcp", v.Addr, s.config)
@ -97,7 +98,6 @@ func (c *Config) Load() error {
if *debugFlag { if *debugFlag {
log.Printf("Config.Load : ssh.Dial(%s) : %s", k, err) log.Printf("Config.Load : ssh.Dial(%s) : %s", k, err)
} }
return err
} else { } else {
v.online = true v.online = true
session, err := s.client.NewSession() session, err := s.client.NewSession()
@ -168,6 +168,9 @@ func (c *Config) Load() error {
if _, ok := cfg.Box[before.Box()]; !ok { if _, ok := cfg.Box[before.Box()]; !ok {
return fmt.Errorf("No box defined for before : %s", string(before)) return fmt.Errorf("No box defined for before : %s", string(before))
} }
if !cfg.Box[before.Box()].online {
return fmt.Errorf("Before box offline for app : %s", app.Name)
}
} }
for val, after := range app.After { for val, after := range app.After {
_, err = regexp.Compile(val) _, err = regexp.Compile(val)
@ -183,6 +186,9 @@ func (c *Config) Load() error {
if _, ok := cfg.Box[after.Box()]; !ok { if _, ok := cfg.Box[after.Box()]; !ok {
return fmt.Errorf("No box defined for after : %s", string(after)) return fmt.Errorf("No box defined for after : %s", string(after))
} }
if !cfg.Box[after.Box()].online {
return fmt.Errorf("After box offline for app : %s", app.Name)
}
} }
} }

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "762c538" var githash = "fd62711"
var buildstamp = "2022-04-16_12:55:05" var buildstamp = "2022-04-16_13:08:54"
var commits = "29" var commits = "30"
var version = "762c538-b29 - 2022-04-16_12:55:05" var version = "fd62711-b30 - 2022-04-16_13:08:54"