From f022e9fffeeebd26cba365b6d779b0ca47b9f9a4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 29 Apr 2020 20:18:19 -0700 Subject: [PATCH] fix: a type switch nit --- autonat.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/autonat.go b/autonat.go index cfde8b2..46b6a93 100644 --- a/autonat.go +++ b/autonat.go @@ -188,7 +188,7 @@ func (as *AmbientAutoNAT) background() { } case e := <-subChan: - switch e.(type) { + switch e := e.(type) { case event.EvtLocalAddressesUpdated: if !lastAddrUpdated.Add(time.Second).After(time.Now()) { lastAddrUpdated = time.Now() @@ -197,13 +197,14 @@ func (as *AmbientAutoNAT) background() { } } case event.EvtPeerIdentificationCompleted: - peer = e.(event.EvtPeerIdentificationCompleted).Peer - if s, err := as.host.Peerstore().SupportsProtocols(peer, AutoNATProto); err == nil && len(s) > 0 { + if s, err := as.host.Peerstore().SupportsProtocols(e.Peer, AutoNATProto); err == nil && len(s) > 0 { currentStatus := as.status.Load().(autoNATResult) if currentStatus.Reachability == network.ReachabilityUnknown { - as.tryProbe(peer) + as.tryProbe(e.Peer) } } + default: + log.Errorf("unknown event type: %T", e) } // probe finished.