Lint tweaks

This commit is contained in:
Neil Alexander 2022-09-24 17:05:44 +01:00
parent d24d3fa047
commit d9fe6f72ac
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
5 changed files with 12 additions and 13 deletions

View File

@ -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()

View File

@ -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")
}

View File

@ -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())
}()

View File

@ -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())
}()

View File

@ -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())
}()