mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-01-27 03:04:21 +01:00
feat: filter non-SSH files from config parsing
- Skip README, .git, and documentation files during SSH config parsing - Add QuickHostExists for fast host validation without full parsing - Prevent errors when Include * encounters non-config files
This commit is contained in:
19
cmd/root.go
19
cmd/root.go
@@ -103,27 +103,18 @@ func runInteractiveMode() {
|
||||
}
|
||||
|
||||
func connectToHost(hostName string) {
|
||||
// Parse SSH configurations to verify host exists
|
||||
var hosts []config.SSHHost
|
||||
// Quick check if host exists without full parsing (optimized for connection)
|
||||
var hostFound bool
|
||||
var err error
|
||||
|
||||
if configFile != "" {
|
||||
hosts, err = config.ParseSSHConfigFile(configFile)
|
||||
hostFound, err = config.QuickHostExistsInFile(hostName, configFile)
|
||||
} else {
|
||||
hosts, err = config.ParseSSHConfig()
|
||||
hostFound, err = config.QuickHostExists(hostName)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading SSH config file: %v", err)
|
||||
}
|
||||
|
||||
// Check if host exists
|
||||
var hostFound bool
|
||||
for _, host := range hosts {
|
||||
if host.Name == hostName {
|
||||
hostFound = true
|
||||
break
|
||||
}
|
||||
log.Fatalf("Error checking SSH config: %v", err)
|
||||
}
|
||||
|
||||
if !hostFound {
|
||||
|
||||
Reference in New Issue
Block a user