|
@@ -13,6 +13,7 @@ import (
|
|
|
|
|
|
"github.com/syncthing/syncthing/lib/protocol"
|
|
|
"github.com/syncthing/syncthing/lib/sync"
|
|
|
+ "github.com/syncthing/syncthing/lib/util"
|
|
|
"github.com/thejerf/suture"
|
|
|
)
|
|
|
|
|
@@ -165,12 +166,17 @@ func (m *cachingMux) Cache() map[protocol.DeviceID]CacheEntry {
|
|
|
|
|
|
m.mut.RLock()
|
|
|
for i := range m.finders {
|
|
|
- // Each finder[i] has a corresponding cache at cache[i]. Go through it
|
|
|
- // and populate the total, if it's newer than what's already in there.
|
|
|
- // We skip any negative cache entries.
|
|
|
+ // Each finder[i] has a corresponding cache at cache[i]. Go through
|
|
|
+ // it and populate the total, appending any addresses and keeping
|
|
|
+ // the newest "when" time. We skip any negative cache entries.
|
|
|
for k, v := range m.caches[i].Cache() {
|
|
|
- if v.found && v.when.After(res[k].when) {
|
|
|
- res[k] = v
|
|
|
+ if v.found {
|
|
|
+ cur := res[k]
|
|
|
+ if v.when.After(cur.when) {
|
|
|
+ cur.when = v.when
|
|
|
+ }
|
|
|
+ cur.Addresses = append(cur.Addresses, v.Addresses...)
|
|
|
+ res[k] = cur
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -178,13 +184,23 @@ func (m *cachingMux) Cache() map[protocol.DeviceID]CacheEntry {
|
|
|
// finder is a global discovery client, it will have no cache. If it's
|
|
|
// a local discovery client, this will be it's current state.
|
|
|
for k, v := range m.finders[i].Cache() {
|
|
|
- if v.found && v.when.After(res[k].when) {
|
|
|
- res[k] = v
|
|
|
+ if v.found {
|
|
|
+ cur := res[k]
|
|
|
+ if v.when.After(cur.when) {
|
|
|
+ cur.when = v.when
|
|
|
+ }
|
|
|
+ cur.Addresses = append(cur.Addresses, v.Addresses...)
|
|
|
+ res[k] = cur
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
m.mut.RUnlock()
|
|
|
|
|
|
+ for k, v := range res {
|
|
|
+ v.Addresses = util.UniqueStrings(v.Addresses)
|
|
|
+ res[k] = v
|
|
|
+ }
|
|
|
+
|
|
|
return res
|
|
|
}
|
|
|
|