mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-03 15:05:25 +00:00
Lint tweaks
This commit is contained in:
parent
d24d3fa047
commit
d9fe6f72ac
@ -127,7 +127,7 @@ func (c *Core) _addPeerLoop() {
|
|||||||
func (c *Core) Stop() {
|
func (c *Core) Stop() {
|
||||||
phony.Block(c, func() {
|
phony.Block(c, func() {
|
||||||
c.log.Infoln("Stopping...")
|
c.log.Infoln("Stopping...")
|
||||||
c._close()
|
_ = c._close()
|
||||||
c.log.Infoln("Stopped")
|
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.
|
// This function is unsafe and should only be ran by the core actor.
|
||||||
func (c *Core) _close() error {
|
func (c *Core) _close() error {
|
||||||
c.cancel()
|
c.cancel()
|
||||||
_ = c.links.shutdown()
|
c.links.shutdown()
|
||||||
err := c.PacketConn.Close()
|
err := c.PacketConn.Close()
|
||||||
if c.addPeerTimer != nil {
|
if c.addPeerTimer != nil {
|
||||||
c.addPeerTimer.Stop()
|
c.addPeerTimer.Stop()
|
||||||
|
@ -82,23 +82,22 @@ func (l *links) init(c *Core) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *links) shutdown() error {
|
func (l *links) shutdown() {
|
||||||
phony.Block(l.tcp, func() {
|
phony.Block(l.tcp, func() {
|
||||||
for l := range l.tcp._listeners {
|
for l := range l.tcp._listeners {
|
||||||
l.Close()
|
_ = l.Close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
phony.Block(l.tls, func() {
|
phony.Block(l.tls, func() {
|
||||||
for l := range l.tls._listeners {
|
for l := range l.tls._listeners {
|
||||||
l.Close()
|
_ = l.Close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
phony.Block(l.unix, func() {
|
phony.Block(l.unix, func() {
|
||||||
for l := range l.unix._listeners {
|
for l := range l.unix._listeners {
|
||||||
l.Close()
|
_ = l.Close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *links) isConnectedTo(info linkInfo) bool {
|
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 {
|
func (intf *link) handler() error {
|
||||||
defer intf.conn.Close()
|
defer intf.conn.Close() // nolint:errcheck
|
||||||
|
|
||||||
// Don't connect to this link more than once.
|
// Don't connect to this link more than once.
|
||||||
if intf.links.isConnectedTo(intf.info) {
|
if intf.links.isConnectedTo(intf.info) {
|
||||||
@ -249,7 +248,7 @@ func (intf *link) handler() error {
|
|||||||
if _, err = io.ReadFull(intf.conn, metaBytes); err != nil {
|
if _, err = io.ReadFull(intf.conn, metaBytes); err != nil {
|
||||||
return fmt.Errorf("read handshake: %w", err)
|
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)
|
return fmt.Errorf("failed to clear handshake deadline: %w", err)
|
||||||
}
|
}
|
||||||
meta = version_metadata{}
|
meta = version_metadata{}
|
||||||
@ -294,7 +293,7 @@ func (intf *link) handler() error {
|
|||||||
if intf.incoming && !intf.force && !isallowed {
|
if intf.incoming && !intf.force && !isallowed {
|
||||||
intf.links.core.log.Warnf("%s connection from %s forbidden: AllowedEncryptionPublicKeys does not contain key %s",
|
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))
|
strings.ToUpper(intf.info.linkType), intf.info.remote, hex.EncodeToString(meta.key))
|
||||||
intf.close()
|
_ = intf.close()
|
||||||
return fmt.Errorf("forbidden connection")
|
return fmt.Errorf("forbidden connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
l.core.log.Errorln("Failed to create inbound link:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listener.Close()
|
_ = listener.Close()
|
||||||
close(entry.closed)
|
close(entry.closed)
|
||||||
l.core.log.Printf("TCP listener stopped on %s", listener.Addr())
|
l.core.log.Printf("TCP listener stopped on %s", listener.Addr())
|
||||||
}()
|
}()
|
||||||
|
@ -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)
|
l.core.log.Errorln("Failed to create inbound link:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tlslistener.Close()
|
_ = tlslistener.Close()
|
||||||
close(entry.closed)
|
close(entry.closed)
|
||||||
l.core.log.Printf("TLS listener stopped on %s", listener.Addr())
|
l.core.log.Printf("TLS listener stopped on %s", listener.Addr())
|
||||||
}()
|
}()
|
||||||
|
@ -79,7 +79,7 @@ func (l *linkUNIX) listen(url *url.URL, _ string) (*Listener, error) {
|
|||||||
l.core.log.Errorln("Failed to create inbound link:", err)
|
l.core.log.Errorln("Failed to create inbound link:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listener.Close()
|
_ = listener.Close()
|
||||||
close(entry.closed)
|
close(entry.closed)
|
||||||
l.core.log.Printf("UNIX listener stopped on %s", listener.Addr())
|
l.core.log.Printf("UNIX listener stopped on %s", listener.Addr())
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user