Skip to content

Commit

Permalink
Update main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha authored Jan 9, 2025
1 parent d904e69 commit f2ef080
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/relay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
"github.com/multiformats/go-multiaddr"
"github.com/libp2p/go-libp2p/core/network"
)

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

h.Network().Notify(&network.NotifyBundle{
ConnectedF: func(n network.Network, conn network.Conn) {
fmt.Printf("Peer connected: %s\n", conn.RemotePeer().String())
},
DisconnectedF: func(n network.Network, conn network.Conn) {
fmt.Printf("Peer disconnected: %s\n", conn.RemotePeer().String())
},
})

select {}
}

0 comments on commit f2ef080

Please sign in to comment.