mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 16:56:39 +00:00
Fix build
This commit is contained in:
@@ -434,12 +434,6 @@ func (m *Manager) UpdatePeerHostKeys(peerKeys []PeerHostKey) error {
|
||||
return fmt.Errorf("setup known_hosts file: %w", err)
|
||||
}
|
||||
|
||||
// Read existing entries
|
||||
existingEntries, err := m.readKnownHosts(knownHostsPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read existing known_hosts: %w", err)
|
||||
}
|
||||
|
||||
// Build new entries map for efficient lookup
|
||||
newEntries := make(map[string]string)
|
||||
for _, peerKey := range peerKeys {
|
||||
@@ -471,29 +465,6 @@ func (m *Manager) UpdatePeerHostKeys(peerKeys []PeerHostKey) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// readKnownHosts reads and returns all entries from the known_hosts file
|
||||
func (m *Manager) readKnownHosts(knownHostsPath string) ([]string, error) {
|
||||
file, err := os.Open(knownHostsPath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return []string{}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("open known_hosts file: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
var entries []string
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line != "" && !strings.HasPrefix(line, "#") {
|
||||
entries = append(entries, line)
|
||||
}
|
||||
}
|
||||
|
||||
return entries, scanner.Err()
|
||||
}
|
||||
|
||||
// formatKnownHostsEntry formats a peer host key as a known_hosts entry
|
||||
func (m *Manager) formatKnownHostsEntry(peerKey PeerHostKey) string {
|
||||
hostnames := m.getHostnameVariants(peerKey)
|
||||
|
||||
Reference in New Issue
Block a user