by schollz

schollz /peerdiscovery

Pure-Go library for cross-platform local peer discovery using UDP multicast :woman: :repeat: :woman:

441 Stars 32 Forks Last release: 17 days ago (v1.6.0) MIT License 68 Commits 13 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Code coverage Go Report Go Doc

Pure-go library for cross-platform thread-safe local peer discovery using UDP multicast. I needed to use peer discovery for croc and everything I tried had problems, so I made another one.


Make sure you have Go 1.5+.

go get -u


The following is a code to find the first peer on the local network and print it out.

discoveries, _ := peerdiscovery.Discover(peerdiscovery.Settings{Limit: 1})
for _, d := range discoveries {
    fmt.Printf("discovered '%s'\n", d.Address)

Here's the output when running on two computers. (Run these gifs in sync by hitting Ctl + F5).

Computer 1:

computer 1

Computer 2:

computer 1

For more examples, see the scanning example or the docs.


To test the peer discovery with just one host, one can launch multiple containers. The provided

will run the example code. Please make sure to enable Docker's IPv6 support if you are using IPv6 for peer discovery.
# Build the container, named peertest
$ docker build -t peertest .

Execute the following command in multiple terminals

$ docker run -t --rm peertest Scanning for 10 seconds to find LAN peers 100% |████████████████████████████████████████| [9s:0s]Found 1 other computers 0) '' with payload 'zqrecHipCO'


Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements


Thanks @geistesk for adding IPv6 support and a

func, and helping maintain! Thanks @Kunde21 for providing a bug fix and massively refactoring the code in a much better way. Thanks @robpre for finding and fixing bugs. Thanks @shvydky for adding dynamic payloads.



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.