peer+server: log pubkey@addr

This commit is contained in:
Conner Fromknecht 2019-03-26 16:41:13 -07:00
parent 60467bef7b
commit 7358535725
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 15 additions and 14 deletions

@ -638,7 +638,7 @@ func (p *peer) Disconnect(reason error) {
// String returns the string representation of this peer.
func (p *peer) String() string {
return p.conn.RemoteAddr().String()
return fmt.Sprintf("%x@%s", p.pubKeyBytes, p.conn.RemoteAddr())
}
// readNextMessage reads, and returns the next message on the wire along with

@ -2161,9 +2161,9 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
// the new connection s.t there's only a single connection between us.
localPub := s.identityPriv.PubKey()
if !connectedPeer.inbound && !shouldDropLocalConnection(localPub, nodePub) {
srvrLog.Warnf("Received inbound connection from peer %x, "+
srvrLog.Warnf("Received inbound connection from peer %v, "+
"but already have outbound connection, dropping conn",
nodePub.SerializeCompressed())
connectedPeer)
conn.Close()
return
}
@ -2236,7 +2236,8 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
return
}
srvrLog.Infof("Established connection to: %v", conn.RemoteAddr())
srvrLog.Infof("Established connection to: %x@%v", pubStr,
conn.RemoteAddr())
if connReq != nil {
// A successful connection was returned by the connmgr.
@ -2268,9 +2269,9 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
// the new connection s.t there's only a single connection between us.
localPub := s.identityPriv.PubKey()
if connectedPeer.inbound && shouldDropLocalConnection(localPub, nodePub) {
srvrLog.Warnf("Established outbound connection to peer %x, "+
srvrLog.Warnf("Established outbound connection to peer %v, "+
"but already have inbound connection, dropping conn",
nodePub.SerializeCompressed())
connectedPeer)
if connReq != nil {
s.connMgr.Remove(connReq.ID())
}
@ -2355,8 +2356,8 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
addr := conn.RemoteAddr()
pubKey := brontideConn.RemotePub()
srvrLog.Infof("Finalizing connection to %x, inbound=%v",
pubKey.SerializeCompressed(), inbound)
srvrLog.Infof("Finalizing connection to %x@%s, inbound=%v",
pubKey.SerializeCompressed(), addr, inbound)
peerAddr := &lnwire.NetAddress{
IdentityKey: pubKey,
@ -2473,7 +2474,7 @@ func (s *server) peerInitializer(p *peer) {
defer s.mu.Unlock()
// Check if there are listeners waiting for this peer to come online.
srvrLog.Debugf("Notifying that peer %x is online", p.PubKey())
srvrLog.Debugf("Notifying that peer %v is online", p)
for _, peerChan := range s.peerConnectedListeners[pubStr] {
select {
case peerChan <- p:
@ -2527,8 +2528,7 @@ func (s *server) peerTerminationWatcher(p *peer, ready chan struct{}) {
// TODO(roasbeef): instead add a PurgeInterfaceLinks function?
links, err := p.server.htlcSwitch.GetLinksByInterface(p.pubKeyBytes)
if err != nil && err != htlcswitch.ErrNoLinksFound {
srvrLog.Errorf("Unable to get channel links for %x: %v",
p.PubKey(), err)
srvrLog.Errorf("Unable to get channel links for %v: %v", p, err)
}
for _, link := range links {
@ -2540,7 +2540,7 @@ func (s *server) peerTerminationWatcher(p *peer, ready chan struct{}) {
// If there were any notification requests for when this peer
// disconnected, we can trigger them now.
srvrLog.Debugf("Notifying that peer %x is offline", p.PubKey())
srvrLog.Debugf("Notifying that peer %x is offline", p)
pubStr := string(pubKey.SerializeCompressed())
for _, offlineChan := range s.peerDisconnectedListeners[pubStr] {
close(offlineChan)
@ -2736,13 +2736,14 @@ func (s *server) ConnectToPeer(addr *lnwire.NetAddress, perm bool) error {
// connection.
if reqs, ok := s.persistentConnReqs[targetPub]; ok {
srvrLog.Warnf("Already have %d persistent connection "+
"requests for %v, connecting anyway.", len(reqs), addr)
"requests for %x@%v, connecting anyway.", len(reqs),
targetPub, addr)
}
// If there's not already a pending or active connection to this node,
// then instruct the connection manager to attempt to establish a
// persistent connection to the peer.
srvrLog.Debugf("Connecting to %v", addr)
srvrLog.Debugf("Connecting to %x@%v", targetPub, addr)
if perm {
connReq := &connmgr.ConnReq{
Addr: addr,