From f8f7d0b0c71766d49b35fde8046a09eb2bb9a01f Mon Sep 17 00:00:00 2001 From: Julien Viard de Galbert Date: Tue, 6 Jul 2021 10:22:43 +0200 Subject: [PATCH] add skip on error --- pkg/wireguard/conf.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/wireguard/conf.go b/pkg/wireguard/conf.go index 92d50c8..f1b328b 100644 --- a/pkg/wireguard/conf.go +++ b/pkg/wireguard/conf.go @@ -519,8 +519,10 @@ func ParseDump(buf []byte) *Conf { iface = new(Interface) iface.PrivateKey = []byte(values[0]) - port, _ = strconv.ParseUint(values[2], 10, 32) - iface.ListenPort = uint32(port) + port, err = strconv.ParseUint(values[2], 10, 32) + if err == nil { + iface.ListenPort = uint32(port) + } c.Interface = iface // Next lines are Peers @@ -549,8 +551,10 @@ func ParseDump(buf []byte) *Conf { } if values[7] != dumpOff { - i, _ = strconv.Atoi(values[7]) - peer.PersistentKeepalive = i + i, err = strconv.Atoi(values[7]) + if err == nil { + peer.PersistentKeepalive = i + } } c.Peers = append(c.Peers, peer) peer = nil