Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circuitv2: don't check ASN for private addrs #2611

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion p2p/protocol/circuitv2/relay/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ func (c *constraints) AddReservation(p peer.ID, a ma.Multiaddr) error {

var asnReservations []time.Time
var asn string
if ip.To4() == nil {
// Only public addresses have an ASN. Skip checking ASN for private addresses as
// initialising the ASN store is a costly operation. Skipping this check reduces a lot of
// flakiness in tests
if ip.To4() == nil && manet.IsPublicAddr(a) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment would be helpful, explaining why we skip this for private addresses.

asn, _ = asnutil.Store.AsnForIPv6(ip)
if asn != "" {
asnReservations = c.asns[asn]
Expand Down