diff --git a/p2p/net/conn/dial.go b/p2p/net/conn/dial.go index 820c4ec57..aabb4b508 100644 --- a/p2p/net/conn/dial.go +++ b/p2p/net/conn/dial.go @@ -60,7 +60,6 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) ( c2, err := newSecureConn(ctx, d.PrivateKey, c) if err != nil { - logdial["error"] = err errOut = err c.Close() return diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go index 4621fb1a6..216493b34 100644 --- a/p2p/net/swarm/swarm_dial.go +++ b/p2p/net/swarm/swarm_dial.go @@ -266,17 +266,18 @@ func (s *Swarm) gatedDialAttempt(ctx context.Context, p peer.ID) (*Conn, error) // dial is the actual swarm's dial logic, gated by Dial. func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) { var logdial = lgbl.Dial("swarm", s.LocalPeer(), p, nil, nil) - defer log.EventBegin(ctx, "swarmDialDo", logdial).Done() if p == s.local { log.Event(ctx, "swarmDialDoDialSelf", logdial) return nil, ErrDialToSelf } + defer log.EventBegin(ctx, "swarmDialDo", logdial).Done() + logdial["dial"] = "failure" // start off with failure. set to "success" at the end. sk := s.peers.PrivKey(s.local) + logdial["encrypted"] = (sk != nil) // log wether this will be an encrypted dial or not. if sk == nil { - // may be fine for sk to be nil, just log. + // fine for sk to be nil, just log. log.Debug("Dial not given PrivateKey, so WILL NOT SECURE conn.") - log.Event(ctx, "swarmDialDoInsecure", logdial) } // get our own addrs. try dialing out from our listener addresses (reusing ports) @@ -298,7 +299,9 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) { remoteAddrs = addrutil.Subtract(remoteAddrs, s.peers.Addresses(s.local)) log.Debugf("%s swarm dialing %s -- remote:%s local:%s", s.local, p, remoteAddrs, s.ListenAddresses()) if len(remoteAddrs) == 0 { - return nil, errors.New("peer has no addresses") + err := errors.New("peer has no addresses") + logdial["error"] = err + return nil, err } // open connection to peer @@ -316,20 +319,21 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) { // try to get a connection to any addr connC, err := s.dialAddrs(ctx, d, p, remoteAddrs) if err != nil { + logdial["error"] = err return nil, err } + logdial["netconn"] = lgbl.NetConn(connC) // ok try to setup the new connection. defer log.EventBegin(ctx, "swarmDialDoSetup", logdial, lgbl.NetConn(connC)).Done() swarmC, err := dialConnSetup(ctx, s, connC) if err != nil { - log.Debug("Dial newConnSetup failed. disconnecting.") - log.Event(ctx, "swarmDialDoSetupFailed", logdial, lgbl.NetConn(connC), lgbl.Error(err)) + logdial["error"] = err connC.Close() // close the connection. didn't work out :( return nil, err } - log.Event(ctx, "swarmDialDoSuccess", logdial, lgbl.NetConn(connC)) + logdial["dial"] = "success" return swarmC, nil } @@ -428,8 +432,6 @@ func dialConnSetup(ctx context.Context, s *Swarm, connC conn.Conn) (*Conn, error // ok try to setup the new connection. (newConnSetup will add to group) swarmC, err := s.newConnSetup(ctx, psC) if err != nil { - log.Debug("Dial newConnSetup failed. disconnecting.") - log.Event(ctx, "dialFailureDisconnect", lgbl.NetConn(connC), lgbl.Error(err)) psC.Close() // we need to make sure psC is Closed. return nil, err } diff --git a/util/eventlog/loggables/loggables.go b/util/eventlog/loggables/loggables.go index 77ed607f7..991a927b8 100644 --- a/util/eventlog/loggables/loggables.go +++ b/util/eventlog/loggables/loggables.go @@ -37,7 +37,6 @@ func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap { m["subsystem"] = sys if lid != "" { m["localPeer"] = func() interface{} { return lid.Pretty() } - _ = m["localPeer"].(func() interface{}) } if laddr != nil { m["localAddr"] = func() interface{} { return laddr.String() }