diff --git a/CHANGELOG.md b/CHANGELOG.md index 02096de..f316e4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,13 +15,14 @@ The following emojis are used to highlight certain changes: ### Added - ### Changed ### Removed ### Fixed +- Fix a bug whereby, cached peers with private multiaddrs were returned in `/routing/v1/providers` responses, as they were not passing through `sanitizeRouter`. + ### Security ## [v0.7.0] diff --git a/server.go b/server.go index 4052c81..65b46ee 100644 --- a/server.go +++ b/server.go @@ -246,7 +246,8 @@ func getCombinedRouting(endpoints []string, dht routing.Routing, cachedAddrBook var dhtRouter router if cachedAddrBook != nil { - dhtRouter = NewCachedRouter(sanitizeRouter{libp2pRouter{routing: dht}}, cachedAddrBook) + cachedRouter := NewCachedRouter(libp2pRouter{routing: dht}, cachedAddrBook) + dhtRouter = sanitizeRouter{cachedRouter} } else { dhtRouter = sanitizeRouter{libp2pRouter{routing: dht}} } diff --git a/server_cached_router.go b/server_cached_router.go index c66c6aa..ae93588 100644 --- a/server_cached_router.go +++ b/server_cached_router.go @@ -48,6 +48,7 @@ const ( ) // cachedRouter wraps a router with the cachedAddrBook to retrieve cached addresses for peers without multiaddrs in FindProviders +// it will also dispatch a FindPeer when a provider has no multiaddrs using the cacheFallbackIter type cachedRouter struct { router cachedAddrBook *cachedAddrBook