Copied and modified from https://github.com/libp2p/go-libp2p-examples.