-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
autonatv2: implement autonatv2 spec #2469
Conversation
5477354
to
fe5e13e
Compare
fe5e13e
to
7d524a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review. I might be missing something, but where is the logic which address to check next? Or is that left for the implementation of the address pipeline?
Yes, that part will go in the address pipeline. |
e09ef04
to
c55e2af
Compare
5bddfb0
to
acb1c88
Compare
6149b00
to
83babed
Compare
83babed
to
e080d99
Compare
e080d99
to
af0ac51
Compare
3ff9598
to
a3138cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass. I think this is looks good! I want to think about any vulnerabilities here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass. I think this is looks good! I want to think about any vulnerabilities here.
f212a0f
to
0aa1911
Compare
Can we default to having autonatv2 disabled initially? I want folks to opt-in to it at the start until we gain some more confidence with experience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple comments left. I think this is good after those are addressed and we change this to be opt-in.
1219f9e
to
cf8807b
Compare
p2p/protocol/autonatv2/client.go
Outdated
lenBuf = lenBuf[:n] | ||
|
||
for remain := numBytes; remain > 0; { | ||
_, err = w.Write(lenBuf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this overshoot the amount of data to dial? The old version did ddResp.Data = ddResp.Data[:end]
.
fwiw, I think extra allocs on the client side matter less than on the server side. I would be okay if the code path on the client side was straightforward at the expense of a couple extra allocs (what we had before was fine.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the suggestion to remove this on the client. We can always add this side later on when we start using this from rest of the code.
won't this overshoot the amount of data to dial?
I think this is okay. Servers should handle this case. It's only 4kB more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the spec if the client may send a bit more data.
898d51c
to
9667cd8
Compare
Closes: #4524 This is the implementation of the evolved AutoNAT protocol, named AutonatV2 as defined in the [spec](https://github.com/libp2p/specs/blob/03718ef0f2dea4a756a85ba716ee33f97e4a6d6c/autonat/autonat-v2.md). The stabilization PR for the spec can be found under libp2p/specs#538. The work on the Rust implementation can be found in the PR to my fork: umgefahren#1. The implementation has been smoke-tested with the Go implementation (PR: libp2p/go-libp2p#2469). The new protocol addresses shortcomings of the original AutoNAT protocol: - Since the server now always dials back over a newly allocated port, this made #4568 necessary; the client can be sure of the reachability state for other peers, even if the connection to the server was made through a hole punch. - The server can now test addresses different from the observed address (i.e., the connection to the server was made through a `p2p-circuit`). To mitigate against DDoS attacks, the client has to send more data to the server than the dial-back costs. Pull-Request: #5526.
Closes: libp2p#4524 This is the implementation of the evolved AutoNAT protocol, named AutonatV2 as defined in the [spec](https://github.com/libp2p/specs/blob/03718ef0f2dea4a756a85ba716ee33f97e4a6d6c/autonat/autonat-v2.md). The stabilization PR for the spec can be found under libp2p/specs#538. The work on the Rust implementation can be found in the PR to my fork: umgefahren#1. The implementation has been smoke-tested with the Go implementation (PR: libp2p/go-libp2p#2469). The new protocol addresses shortcomings of the original AutoNAT protocol: - Since the server now always dials back over a newly allocated port, this made libp2p#4568 necessary; the client can be sure of the reachability state for other peers, even if the connection to the server was made through a hole punch. - The server can now test addresses different from the observed address (i.e., the connection to the server was made through a `p2p-circuit`). To mitigate against DDoS attacks, the client has to send more data to the server than the dial-back costs. Pull-Request: libp2p#5526.
closes: #2422
Will add metrics for this in a separate PR.