Fix discovery in the absence of listen addresses (fixes #4418)

This makes it OK to not have any listeners working. Specifically,

- We don't complain about an empty listener address
- We don't complain about not having anything to announce to global
  discovery servers
- We don't send local discovery packets when there is nothing to
  announce.

The last point also fixes a thing where the list of addresses for local
discovery was set at startup time and never refreshed.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4517
This commit is contained in:
Jakob Borg
2017-11-17 09:12:35 +00:00
committed by Audrius Butkevicius
parent aecd7c64ce
commit 7ebf58f1bc
5 changed files with 51 additions and 17 deletions

View File

@@ -208,8 +208,10 @@ func (c *globalClient) sendAnnouncement(timer *time.Timer) {
}
if len(ann.Addresses) == 0 {
c.setError(errors.New("nothing to announce"))
l.Debugln("Nothing to announce")
// There are legitimate cases for not having anything to announce,
// yet still using global discovery for lookups. Do not error out
// here.
c.setError(nil)
timer.Reset(announceErrorRetryInterval)
return
}