From d9fe6f72ac9368537f1ee915d9851d6d215b7599 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 24 Sep 2022 17:05:44 +0100 Subject: [PATCH] Lint tweaks --- src/core/core.go | 4 ++-- src/core/link.go | 15 +++++++-------- src/core/link_tcp.go | 2 +- src/core/link_tls.go | 2 +- src/core/link_unix.go | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/core/core.go b/src/core/core.go index 4cc08ad..5cfcc7a 100644 --- a/src/core/core.go +++ b/src/core/core.go @@ -127,7 +127,7 @@ func (c *Core) _addPeerLoop() { func (c *Core) Stop() { phony.Block(c, func() { c.log.Infoln("Stopping...") - c._close() + _ = c._close() c.log.Infoln("Stopped") }) } @@ -135,7 +135,7 @@ func (c *Core) Stop() { // This function is unsafe and should only be ran by the core actor. func (c *Core) _close() error { c.cancel() - _ = c.links.shutdown() + c.links.shutdown() err := c.PacketConn.Close() if c.addPeerTimer != nil { c.addPeerTimer.Stop() diff --git a/src/core/link.go b/src/core/link.go index 939bb25..26e4466 100644 --- a/src/core/link.go +++ b/src/core/link.go @@ -82,23 +82,22 @@ func (l *links) init(c *Core) error { return nil } -func (l *links) shutdown() error { +func (l *links) shutdown() { phony.Block(l.tcp, func() { for l := range l.tcp._listeners { - l.Close() + _ = l.Close() } }) phony.Block(l.tls, func() { for l := range l.tls._listeners { - l.Close() + _ = l.Close() } }) phony.Block(l.unix, func() { for l := range l.unix._listeners { - l.Close() + _ = l.Close() } }) - return nil } func (l *links) isConnectedTo(info linkInfo) bool { @@ -216,7 +215,7 @@ func (l *links) create(conn net.Conn, name string, info linkInfo, incoming, forc } func (intf *link) handler() error { - defer intf.conn.Close() + defer intf.conn.Close() // nolint:errcheck // Don't connect to this link more than once. if intf.links.isConnectedTo(intf.info) { @@ -249,7 +248,7 @@ func (intf *link) handler() error { if _, err = io.ReadFull(intf.conn, metaBytes); err != nil { return fmt.Errorf("read handshake: %w", err) } - if err := intf.conn.SetDeadline(time.Time{}); err != nil { + if err = intf.conn.SetDeadline(time.Time{}); err != nil { return fmt.Errorf("failed to clear handshake deadline: %w", err) } meta = version_metadata{} @@ -294,7 +293,7 @@ func (intf *link) handler() error { if intf.incoming && !intf.force && !isallowed { intf.links.core.log.Warnf("%s connection from %s forbidden: AllowedEncryptionPublicKeys does not contain key %s", strings.ToUpper(intf.info.linkType), intf.info.remote, hex.EncodeToString(meta.key)) - intf.close() + _ = intf.close() return fmt.Errorf("forbidden connection") } diff --git a/src/core/link_tcp.go b/src/core/link_tcp.go index fcac8b4..c5a73c9 100644 --- a/src/core/link_tcp.go +++ b/src/core/link_tcp.go @@ -89,7 +89,7 @@ func (l *linkTCP) listen(url *url.URL, sintf string) (*Listener, error) { l.core.log.Errorln("Failed to create inbound link:", err) } } - listener.Close() + _ = listener.Close() close(entry.closed) l.core.log.Printf("TCP listener stopped on %s", listener.Addr()) }() diff --git a/src/core/link_tls.go b/src/core/link_tls.go index e6ffd5a..1e932b6 100644 --- a/src/core/link_tls.go +++ b/src/core/link_tls.go @@ -112,7 +112,7 @@ func (l *linkTLS) listen(url *url.URL, sintf string) (*Listener, error) { l.core.log.Errorln("Failed to create inbound link:", err) } } - tlslistener.Close() + _ = tlslistener.Close() close(entry.closed) l.core.log.Printf("TLS listener stopped on %s", listener.Addr()) }() diff --git a/src/core/link_unix.go b/src/core/link_unix.go index d63c1d9..e71f936 100644 --- a/src/core/link_unix.go +++ b/src/core/link_unix.go @@ -79,7 +79,7 @@ func (l *linkUNIX) listen(url *url.URL, _ string) (*Listener, error) { l.core.log.Errorln("Failed to create inbound link:", err) } } - listener.Close() + _ = listener.Close() close(entry.closed) l.core.log.Printf("UNIX listener stopped on %s", listener.Addr()) }()