Skip to content

Commit e9c542b

Browse files
authored
circuitv2: don't check ASN for private addrs (#2611)
1 parent f4b7369 commit e9c542b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

p2p/protocol/circuitv2/relay/constraints.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ func (c *constraints) AddReservation(p peer.ID, a ma.Multiaddr) error {
7474

7575
var asnReservations []time.Time
7676
var asn string
77-
if ip.To4() == nil {
77+
// Only public addresses have an ASN. Skip checking ASN for private addresses as
78+
// initialising the ASN store is a costly operation. Skipping this check reduces a lot of
79+
// flakiness in tests
80+
if ip.To4() == nil && manet.IsPublicAddr(a) {
7881
asn, _ = asnutil.Store.AsnForIPv6(ip)
7982
if asn != "" {
8083
asnReservations = c.asns[asn]

0 commit comments

Comments
 (0)