Skip to content

Commit 85a5bf2

Browse files
authored
Merge pull request #10341 from bitromortac/2511-fix-tor-healthcheck
server: prevent duplicate onion addresses in getinfo
2 parents c746aee + b513efc commit 85a5bf2

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
@@ -3399,6 +3399,18 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
33993399
modifier(&newNodeAnn)
34003400
}
34013401

3402+
// The modifiers may have added duplicate addresses, so we need to
3403+
// de-duplicate them here.
3404+
uniqueAddrs := map[string]struct{}{}
3405+
dedupedAddrs := make([]net.Addr, 0)
3406+
for _, addr := range newNodeAnn.Addresses {
3407+
if _, ok := uniqueAddrs[addr.String()]; !ok {
3408+
uniqueAddrs[addr.String()] = struct{}{}
3409+
dedupedAddrs = append(dedupedAddrs, addr)
3410+
}
3411+
}
3412+
newNodeAnn.Addresses = dedupedAddrs
3413+
34023414
// Sign a new update after applying all of the passed modifiers.
34033415
err := netann.SignNodeAnnouncement(
34043416
s.nodeSigner, s.identityKeyLoc, &newNodeAnn,

0 commit comments

Comments
 (0)