Skip to content

Commit

Permalink
fix: filter public ips (#97)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
2color and 2color authored Dec 20, 2024
1 parent c6c2f28 commit 77a8147
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
Expand Down
1 change: 1 addition & 0 deletions server_cached_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77a8147

Please sign in to comment.