Skip to content

Commit f2ef080

Browse files
authored
Update main.go
1 parent d904e69 commit f2ef080

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/relay/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/libp2p/go-libp2p/core/peer"
1313
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
1414
"github.com/multiformats/go-multiaddr"
15+
"github.com/libp2p/go-libp2p/core/network"
1516
)
1617

1718
// ReadIdentity reads a private key from the given path and returns it.
@@ -85,5 +86,14 @@ func main() {
8586
fmt.Printf("Listening on %s/p2p/%s\n", addr, h.ID().String())
8687
}
8788

89+
h.Network().Notify(&network.NotifyBundle{
90+
ConnectedF: func(n network.Network, conn network.Conn) {
91+
fmt.Printf("Peer connected: %s\n", conn.RemotePeer().String())
92+
},
93+
DisconnectedF: func(n network.Network, conn network.Conn) {
94+
fmt.Printf("Peer disconnected: %s\n", conn.RemotePeer().String())
95+
},
96+
})
97+
8898
select {}
8999
}

0 commit comments

Comments
 (0)