@cryptotaxi247 / kubo / commits / 81e7c2b84

log(secio): session loggable for event

Juan Batiz-Benet committed Jan 30, 2015 at 22:35 UTC 81e7c2b84ecc86a6dbd30610ccc77ccdb3e18a6d
1 file changed +9 -2
p2p/crypto/secio/protocol.go
+9 -2
@@ -46,6 +46,14 @@ type secureSession struct {
46 sharedSecret []byte
47 }
48
49 +func (s *secureSession) Loggable() map[string]interface{} {
50 + m := make(map[string]interface{})
51 + m["localPeer"] = s.localPeer.Pretty()
52 + m["remotePeer"] = s.remotePeer.Pretty()
53 + m["established"] = (s.secure != nil)
54 + return m
55 +}
56 +
57 func newSecureSession(local peer.ID, key ci.PrivKey) (*secureSession, error) {
58 s := &secureSession{localPeer: local, localKey: key}
59
@@ -80,7 +88,7 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
88 return err
89 }
90
83 - defer log.EventBegin(ctx, "secureHandshake", s.localPeer).Done()
91 + defer log.EventBegin(ctx, "secureHandshake", s).Done()
92
93 s.local.permanentPubKey = s.localKey.GetPublic()
94 myPubKeyBytes, err := s.local.permanentPubKey.Bytes()
@@ -292,6 +300,5 @@ func (s *secureSession) handshake(ctx context.Context, insecure io.ReadWriter) e
300 }
301
302 // Whew! ok, that's all folks.
295 - log.Event(ctx, "secureHandshakeFinish", s.localPeer, s.remotePeer)
303 return nil
304 }