File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments