Skip to content

Commit b7e2226

Browse files
committed
[FAB-3755] Gossip:Add remote peer endpoint to ConnInfo
In gossip we have the following struct that can be extracted from a point-to-point message: type ConnectionInfo struct { ID common.PKIidType Auth *AuthInfo Identity api.PeerIdentityType } In the logs we write the ID of the peer but it's a byte slice, and doesn't tell much about the peer. On the other hand, when a remote peer connects to a peer, we extract its endpoint anyway. I added the endpoint to the struct and added an assignment at the handshake time. Change-Id: If29abda09f2b066332099a45328c26027641215b Signed-off-by: Yacov Manevich <[email protected]>
1 parent 5a27382 commit b7e2226

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

gossip/comm/comm_impl.go

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ func (c *commImpl) authenticateRemotePeer(stream stream) (*proto.ConnectionInfo,
465465
connInfo := &proto.ConnectionInfo{
466466
ID: receivedMsg.PkiId,
467467
Identity: receivedMsg.Cert,
468+
Endpoint: remoteAddress,
468469
}
469470

470471
// if TLS is enabled and detected, verify remote peer

gossip/gossip/channel/channel.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,11 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) {
380380
}
381381
orgID := gc.GetOrgOfPeer(msg.GetConnectionInfo().ID)
382382
if len(orgID) == 0 {
383-
gc.logger.Debug("Couldn't find org identity of peer", msg.GetConnectionInfo().ID)
383+
gc.logger.Debug("Couldn't find org identity of peer", msg.GetConnectionInfo())
384384
return
385385
}
386386
if !gc.IsOrgInChannel(orgID) {
387-
gc.logger.Warning("Point to point message came from", msg.GetConnectionInfo().ID,
387+
gc.logger.Warning("Point to point message came from", msg.GetConnectionInfo(),
388388
", org(", string(orgID), ") but it's not eligible for the channel", string(gc.chainID))
389389
return
390390
}

gossip/gossip/gossip_impl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (g *gossipServiceImpl) handleMessage(m proto.ReceivedMessage) {
339339

340340
msg := m.GetGossipMessage()
341341

342-
g.logger.Debug("Entering,", m.GetConnectionInfo().ID, "sent us", msg)
342+
g.logger.Debug("Entering,", m.GetConnectionInfo(), "sent us", msg)
343343
defer g.logger.Debug("Exiting")
344344

345345
if !g.validateMsg(m) {

protos/gossip/extensions.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,18 @@ type ConnectionInfo struct {
336336
ID common.PKIidType
337337
Auth *AuthInfo
338338
Identity api.PeerIdentityType
339+
Endpoint string
339340
}
340341

341-
func (connInfo *ConnectionInfo) IsAuthenticated() bool {
342-
return connInfo.Auth != nil
342+
// String returns a string representation of this ConnectionInfo
343+
func (c *ConnectionInfo) String() string {
344+
return fmt.Sprintf("%s %v", c.Endpoint, c.ID)
345+
}
346+
347+
// IsAuthenticated returns whether the connection to the remote peer
348+
// was authenticated when the handshake took place
349+
func (c *ConnectionInfo) IsAuthenticated() bool {
350+
return c.Auth != nil
343351
}
344352

345353
// AuthInfo represents the authentication

0 commit comments

Comments
 (0)