mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
lib/upnp: Correct the result deduplication mechanism (fixes #3578)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3618
This commit is contained in:
parent
6d3160b0ab
commit
3cabecda04
@ -108,19 +108,21 @@ func Discover(renewal, timeout time.Duration) []nat.Device {
|
||||
close(resultChan)
|
||||
}()
|
||||
|
||||
seenResults := make(map[string]bool)
|
||||
nextResult:
|
||||
for result := range resultChan {
|
||||
for _, existingResult := range results {
|
||||
if existingResult.ID() == result.ID() {
|
||||
if seenResults[result.ID()] {
|
||||
l.Debugf("Skipping duplicate result %s with services:", result.uuid)
|
||||
for _, service := range result.services {
|
||||
l.Debugf("* [%s] %s", service.ID, service.URL)
|
||||
}
|
||||
continue nextResult
|
||||
}
|
||||
}
|
||||
|
||||
result := result // Reallocate as we need to keep a pointer
|
||||
results = append(results, &result)
|
||||
seenResults[result.ID()] = true
|
||||
|
||||
l.Debugf("UPnP discovery result %s with services:", result.uuid)
|
||||
for _, service := range result.services {
|
||||
l.Debugf("* [%s] %s", service.ID, service.URL)
|
||||
|
Loading…
Reference in New Issue
Block a user