Skip to content

Commit 0aa757b

Browse files
authored
Merge pull request #10398 from bitromortac/backport/2511-fix-tor-healthcheck
backport: server: prevent duplicate onion addresses in getinfo
2 parents f8b5cb0 + 7bf9f30 commit 0aa757b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

docs/release-notes/release-notes-0.20.1.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
* [Fix a case where resolving the
2828
to_local/to_remote output](https://github.com/lightningnetwork/lnd/pull/10387)
2929
might take too long.
30-
30+
31+
* Fix a bug where [repeated network
32+
addresses](https://github.com/lightningnetwork/lnd/pull/10341) were added to
33+
the node announcement and `getinfo` output.
34+
3135
# New Features
3236

3337
## Functional Enhancements
@@ -62,4 +66,5 @@
6266

6367
# Contributors (Alphabetical Order)
6468

69+
* bitromortac
6570
* Ziggie

server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,6 +3378,18 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
33783378
modifier(&newNodeAnn)
33793379
}
33803380

3381+
// The modifiers may have added duplicate addresses, so we need to
3382+
// de-duplicate them here.
3383+
uniqueAddrs := map[string]struct{}{}
3384+
dedupedAddrs := make([]net.Addr, 0)
3385+
for _, addr := range newNodeAnn.Addresses {
3386+
if _, ok := uniqueAddrs[addr.String()]; !ok {
3387+
uniqueAddrs[addr.String()] = struct{}{}
3388+
dedupedAddrs = append(dedupedAddrs, addr)
3389+
}
3390+
}
3391+
newNodeAnn.Addresses = dedupedAddrs
3392+
33813393
// Sign a new update after applying all of the passed modifiers.
33823394
err := netann.SignNodeAnnouncement(
33833395
s.nodeSigner, s.identityKeyLoc, &newNodeAnn,

0 commit comments

Comments
 (0)