MCPcopy Create free account
hub / github.com/Mister-leo/fssh / LoadAllHostConfigs

Function LoadAllHostConfigs

internal/sshconfig/writer.go:128–162  ·  view source on GitHub ↗

LoadAllHostConfigs loads all host configurations

()

Source from the content-addressed store, hash-verified

126
127// LoadAllHostConfigs loads all host configurations
128func LoadAllHostConfigs() (map[string]*HostConfig, error) {
129 lines, err := readSSHConfigLines()
130 if err != nil {
131 return nil, err
132 }
133
134 configs := make(map[string]*HostConfig)
135 i := 0
136 for i < len(lines) {
137 line := strings.TrimSpace(lines[i])
138 if strings.HasPrefix(strings.ToLower(line), "host ") {
139 // Find end of this host block
140 start := i
141 end := i + 1
142 for end < len(lines) {
143 nextLine := strings.TrimSpace(lines[end])
144 if strings.HasPrefix(strings.ToLower(nextLine), "host ") {
145 break
146 }
147 end++
148 }
149
150 // Parse this host block
151 cfg, err := parseHostBlock(lines, start, end)
152 if err == nil {
153 configs[cfg.Name] = cfg
154 }
155 i = end
156 } else {
157 i++
158 }
159 }
160
161 return configs, nil
162}
163
164// --- Helper functions ---
165

Callers 1

LoadHostConfigsFunction · 0.85

Calls 2

readSSHConfigLinesFunction · 0.85
parseHostBlockFunction · 0.85

Tested by

no test coverage detected