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

AutoNAT: return E_DIAL_REFUSED instead of E_DIAL_ERROR of when skipping dial #1482

Closed
wants to merge 4 commits into from

Conversation

elenaf9
Copy link
Contributor

@elenaf9 elenaf9 commented May 11, 2022

Discussed in libp2p/specs#411:
When skipping a dial as a server, we should return E_DIAL_REFUSED instead of E_DIAL_ERROR because we never actually tried to dial the client.

Copy link
Contributor

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

I think we should leave a comment here too: https://github.com/libp2p/go-libp2p/blob/master/p2p/host/autonat/client.go#L79 since it's used there by the client.

@elenaf9
Copy link
Contributor Author

elenaf9 commented May 13, 2022

I think we should leave a comment here too: https://github.com/libp2p/go-libp2p/blob/master/p2p/host/autonat/client.go#L79 since it's used there by the client.

But there it only checks if there is an error, not what type of error it is. Shouldn't we then rather put that comment on the DialBack function itself, or here:

a, err := cli.DialBack(ctx, pi.ID)
var result autoNATResult
switch {
case err == nil:
log.Debugf("Dialback through %s successful; public address is %s", pi.ID.Pretty(), a.String())
result.Reachability = network.ReachabilityPublic
result.address = a
case IsDialError(err):
log.Debugf("Dialback through %s failed", pi.ID.Pretty())
result.Reachability = network.ReachabilityPrivate
default:
result.Reachability = network.ReachabilityUnknown
}
select {
case as.observations <- result:
case <-as.ctx.Done():
return
}
}
where the type of error is checked?

@MarcoPolo
Copy link
Contributor

MarcoPolo commented May 13, 2022

But there it only checks if there is an error, not what type of error it is. Shouldn't we then rather put that comment on the DialBack function itself, or here:


where the type of error is checked?

I think that makes sense. I’d like to cover the case where someone in the future looks at this code and thinks “Hmm, if I check for dial refused I can do something clever” and doesn’t know that older peers will almost always return dial error. As long as that case is covered, I’m happy :)

@marten-seemann
Copy link
Contributor

@elenaf9 Are you planning to address @MarcoPolo's comments? Would be great if we could this fix into the next release!

@elenaf9
Copy link
Contributor Author

elenaf9 commented May 19, 2022

@elenaf9 Are you planning to address @MarcoPolo's comments? Would be great if we could this fix into the next release!

Yes, will add something later today or tomorrow. Sorry for the delay.

@marten-seemann
Copy link
Contributor

Replaced by the (rebased and squashed) #1527.

@elenaf9 elenaf9 deleted the autonat/skip-dial-error branch May 26, 2022 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants