fix(custom): read wireguard presharedkey from peer section
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user