ClassifySSHError determines the type of SSH error for reporting
(err error)
| 715 | |
| 716 | // ClassifySSHError determines the type of SSH error for reporting |
| 717 | func ClassifySSHError(err error) SSHRetryStatus { |
| 718 | if err == nil { |
| 719 | return SSHStatusSuccess |
| 720 | } |
| 721 | if IsKeyParseError(err) { |
| 722 | return SSHStatusKeyParse |
| 723 | } |
| 724 | if IsAuthError(err) { |
| 725 | return SSHStatusAuth |
| 726 | } |
| 727 | if IsNetworkError(err) { |
| 728 | return SSHStatusDialing |
| 729 | } |
| 730 | msg := strings.ToLower(err.Error()) |
| 731 | if messageContainsAny(msg, "handshake", "kex", "connection reset") { |
| 732 | return SSHStatusHandshake |
| 733 | } |
| 734 | return SSHStatusUnexpected |
| 735 | } |
| 736 | |
| 737 | func messageContainsAny(msg string, substrings ...string) bool { |
| 738 | for _, sub := range substrings { |
no test coverage detected