diff options
author | Jakob Borg <jakob@nym.se> | 2014-05-14 15:26:05 -0300 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-05-14 15:26:10 -0300 |
commit | 8903825e020e51ed5cba5f105cdbad1988d3612d (patch) | |
tree | fc7b214f4ecf5bcbb120054600049f48b9ff257f /discover | |
parent | 81cd84add2a9f3f01dc8600b3361d588e9d4f49c (diff) |
Use UDP broadcasts instead of multicast for discovery
Diffstat (limited to 'discover')
-rw-r--r-- | discover/discover.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/discover/discover.go b/discover/discover.go index 6bfa95d809..ab53009e17 100644 --- a/discover/discover.go +++ b/discover/discover.go @@ -44,12 +44,16 @@ var ( const maxErrors = 30 func NewDiscoverer(id string, addresses []string) (*Discoverer, error) { + b, err := mc.NewBeacon(21025) + if err != nil { + return nil, err + } disc := &Discoverer{ myID: id, listenAddrs: addresses, localBcastIntv: 30 * time.Second, globalBcastIntv: 1800 * time.Second, - beacon: mc.NewBeacon("239.21.0.25", 21025), + beacon: b, registry: make(map[string][]string), } @@ -251,11 +255,11 @@ func (d *Discoverer) recvAnnouncements() { if pkt.This.ID != d.myID { n := d.registerNode(addr, pkt.This) newNode = newNode || n - } - for _, node := range pkt.Extra { - if node.ID != d.myID { - n := d.registerNode(nil, node) - newNode = newNode || n + for _, node := range pkt.Extra { + if node.ID != d.myID { + n := d.registerNode(nil, node) + newNode = newNode || n + } } } |