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:
committed by
Audrius Butkevicius
parent
aecd7c64ce
commit
7ebf58f1bc
@@ -504,6 +504,13 @@ func (s *Service) CommitConfiguration(from, to config.Configuration) bool {
|
||||
s.listenersMut.Lock()
|
||||
seen := make(map[string]struct{})
|
||||
for _, addr := range config.Wrap("", to).ListenAddresses() {
|
||||
if addr == "" {
|
||||
// We can get an empty address if there is an empty listener
|
||||
// element in the config, indicating no listeners should be
|
||||
// used. This is not an error.
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := s.listeners[addr]; ok {
|
||||
seen[addr] = struct{}{}
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user