fix(custom): read wireguard presharedkey from peer section

This commit is contained in:
Quentin McGaw
2023-12-09 17:23:08 +00:00
parent 32d6453918
commit 657b4b787f
2 changed files with 13 additions and 17 deletions

View File

@@ -43,6 +43,17 @@ func (s *Source) readWireguard() (wireguard settings.Wireguard, err error) {
return wireguard, fmt.Errorf("getting interface section: %w", err)
}
peerSection, err := iniFile.GetSection("Peer")
if err == nil {
wireguard.PreSharedKey, err = parseINIWireguardKey(peerSection, "PresharedKey")
if err != nil {
return wireguard, fmt.Errorf("parsing peer section: %w", err)
}
} else if !regexINISectionNotExist.MatchString(err.Error()) {
// can never happen
return wireguard, fmt.Errorf("getting peer section: %w", err)
}
return wireguard, nil
}
@@ -53,11 +64,6 @@ func parseWireguardInterfaceSection(interfaceSection *ini.Section,
return err // error is already wrapped correctly
}
wireguard.PreSharedKey, err = parseINIWireguardKey(interfaceSection, "PresharedKey")
if err != nil {
return err // error is already wrapped correctly
}
wireguard.Addresses, err = parseINIWireguardAddress(interfaceSection)
if err != nil {
return err // error is already wrapped correctly