Skip to content

Commit

Permalink
hotfix(config/nordvpn): do not initialize wg addresses to an empty slice
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Apr 2, 2024
1 parent 4afbe93 commit 9821007
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/configuration/settings/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,18 @@ func (w *Wireguard) read(r *reader.Reader) (err error) {
w.Implementation = r.String("WIREGUARD_IMPLEMENTATION")

addressStrings := r.CSV("WIREGUARD_ADDRESSES", reader.RetroKeys("WIREGUARD_ADDRESS"))
w.Addresses = make([]netip.Prefix, len(addressStrings))
for i, addressString := range addressStrings {
// WARNING: do not initialize w.Addresses to an empty slice
// or the defaults for nordvpn will not work.
for _, addressString := range addressStrings {
if !strings.ContainsRune(addressString, '/') {
addressString += "/32"
}
addressString = strings.TrimSpace(addressString)
w.Addresses[i], err = netip.ParsePrefix(addressString)
address, err := netip.ParsePrefix(addressString)
if err != nil {
return fmt.Errorf("parsing address: %w", err)
}
w.Addresses = append(w.Addresses, address)
}

w.AllowedIPs, err = r.CSVNetipPrefixes("WIREGUARD_ALLOWED_IPS")
Expand Down

1 comment on commit 9821007

@vdrover
Copy link

@vdrover vdrover commented on 9821007 Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be included in the .39 release?

Please sign in to comment.