Skip to content

Commit 77a8147

Browse files
authored
fix: filter public ips (#97)
* fix: only return public ips in fallback iter * fix: sanitize last to ensure we only return public ips * docs: add coment about cached router * Revert "fix: only return public ips in fallback iter" This reverts commit bb2fd4c. * docs: update changelog --------- Co-authored-by: Daniel N <2color@users.noreply.github.com>
1 parent c6c2f28 commit 77a8147

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ The following emojis are used to highlight certain changes:
1515

1616
### Added
1717

18-
1918
### Changed
2019

2120
### Removed
2221

2322
### Fixed
2423

24+
- Fix a bug whereby, cached peers with private multiaddrs were returned in `/routing/v1/providers` responses, as they were not passing through `sanitizeRouter`.
25+
2526
### Security
2627

2728
## [v0.7.0]

server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ func getCombinedRouting(endpoints []string, dht routing.Routing, cachedAddrBook
246246
var dhtRouter router
247247

248248
if cachedAddrBook != nil {
249-
dhtRouter = NewCachedRouter(sanitizeRouter{libp2pRouter{routing: dht}}, cachedAddrBook)
249+
cachedRouter := NewCachedRouter(libp2pRouter{routing: dht}, cachedAddrBook)
250+
dhtRouter = sanitizeRouter{cachedRouter}
250251
} else {
251252
dhtRouter = sanitizeRouter{libp2pRouter{routing: dht}}
252253
}

server_cached_router.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
)
4949

5050
// cachedRouter wraps a router with the cachedAddrBook to retrieve cached addresses for peers without multiaddrs in FindProviders
51+
// it will also dispatch a FindPeer when a provider has no multiaddrs using the cacheFallbackIter
5152
type cachedRouter struct {
5253
router
5354
cachedAddrBook *cachedAddrBook

0 commit comments

Comments
 (0)