croc/vendor/github.com/schollz/peerdiscovery
Zack Scholl 3e5aa91f34 re-vendor 2018-06-25 11:59:56 -07:00
..
examples re-vendor 2018-06-25 11:59:56 -07:00
.gitignore re-vendor 2018-06-24 08:23:05 -06:00
.travis.yml re-vendor 2018-06-24 08:23:05 -06:00
LICENSE re-vendor 2018-06-24 08:23:05 -06:00
README.md re-vendor 2018-06-24 08:23:05 -06:00
peerdiscovery.go re-vendor 2018-06-24 08:23:05 -06:00
peerdiscovery_test.go re-vendor 2018-06-25 11:59:56 -07:00

peerdiscovery

travis go report card coverage godocs

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.

Install

Make sure you have Go 1.5+.

go get -u github.com/schollz/peerdiscovery

Usage

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.

Contributing

Pull requests are welcome. Feel free to...

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

License

MIT