diff options
author | Jakob Borg <jakob@nym.se> | 2014-01-26 14:28:41 +0100 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-01-26 14:45:03 +0100 |
commit | 81d5d1d4a607ed5e611f93bdb54b36a785962edf (patch) | |
tree | 2a5e082e660e5b20abd3076680d534f153787449 /discover | |
parent | ea5ef28c5af6ba47bd0bf9c2d10b1547ee503f15 (diff) |
Rework config/flags (fixes #13)v0.5.0
Diffstat (limited to 'discover')
-rw-r--r-- | discover/discover.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/discover/discover.go b/discover/discover.go index fa638e770d..d914494d1d 100644 --- a/discover/discover.go +++ b/discover/discover.go @@ -100,7 +100,6 @@ type Discoverer struct { MyID string ListenPort int BroadcastIntv time.Duration - ExtListenPort int ExtBroadcastIntv time.Duration conn *net.UDPConn @@ -114,7 +113,7 @@ type Discoverer struct { // When we hit this many errors in succession, we stop. const maxErrors = 30 -func NewDiscoverer(id string, port int, extPort int, extServer string) (*Discoverer, error) { +func NewDiscoverer(id string, port int, extServer string) (*Discoverer, error) { local4 := &net.UDPAddr{IP: net.IP{0, 0, 0, 0}, Port: AnnouncementPort} conn, err := net.ListenUDP("udp4", local4) if err != nil { @@ -125,7 +124,6 @@ func NewDiscoverer(id string, port int, extPort int, extServer string) (*Discove MyID: id, ListenPort: port, BroadcastIntv: 30 * time.Second, - ExtListenPort: extPort, ExtBroadcastIntv: 1800 * time.Second, conn: conn, @@ -138,7 +136,7 @@ func NewDiscoverer(id string, port int, extPort int, extServer string) (*Discove if disc.ListenPort > 0 { disc.sendAnnouncements() } - if len(disc.extServer) > 0 && disc.ExtListenPort > 0 { + if len(disc.extServer) > 0 { disc.sendExtAnnouncements() } @@ -153,13 +151,13 @@ func (d *Discoverer) sendAnnouncements() { } func (d *Discoverer) sendExtAnnouncements() { - extIP, err := net.ResolveUDPAddr("udp", d.extServer+":22025") + extIP, err := net.ResolveUDPAddr("udp", d.extServer) if err != nil { log.Printf("discover/external: %v; no external announcements", err) return } - buf := EncodePacket(Packet{AnnouncementMagic, uint16(d.ExtListenPort), d.MyID, nil}) + buf := EncodePacket(Packet{AnnouncementMagic, uint16(22000), d.MyID, nil}) go d.writeAnnouncements(buf, extIP, d.ExtBroadcastIntv) } @@ -213,7 +211,7 @@ func (d *Discoverer) recvAnnouncements() { } func (d *Discoverer) externalLookup(node string) (string, bool) { - extIP, err := net.ResolveUDPAddr("udp", d.extServer+":22025") + extIP, err := net.ResolveUDPAddr("udp", d.extServer) if err != nil { log.Printf("discover/external: %v; no external lookup", err) return "", false |