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

Follow-up commits for AutoNATv2 #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
663055e
Format code
thomaseizinger Dec 30, 2023
ba232cb
Alphabetically sort members list
thomaseizinger Dec 30, 2023
22b96b3
Undo changes to global-only transport
thomaseizinger Dec 30, 2023
a19d7c8
Make deprecation warning work
thomaseizinger Dec 30, 2023
46b8e84
Avoid diff in v1
thomaseizinger Dec 30, 2023
037aa99
Undo behaviour change in v1
thomaseizinger Dec 30, 2023
230ad08
Rename client config fields
thomaseizinger Dec 30, 2023
7cbf413
Streamline creation of `peer_info` state
thomaseizinger Dec 30, 2023
16b4d7c
Rewrite pending nonce handling
thomaseizinger Dec 30, 2023
fdc0c2d
A server might not support autonat on every connection
thomaseizinger Dec 30, 2023
a78c265
Prefer early-exit over `else`
thomaseizinger Dec 30, 2023
8f6c27a
Use shorthand field logging syntax
thomaseizinger Dec 30, 2023
170270a
Fix variable name
thomaseizinger Dec 30, 2023
589cf6c
Improve log message
thomaseizinger Dec 30, 2023
feea82f
Log error using `fmt::Display`
thomaseizinger Dec 30, 2023
8b0a544
Remove `server` field from `InternalStatusUpdate`
thomaseizinger Dec 30, 2023
86849e5
Loop instead of repeating code
thomaseizinger Dec 30, 2023
372d88d
Remove set that we never write to
thomaseizinger Dec 30, 2023
a2fcadd
Remove superflous tests
thomaseizinger Dec 30, 2023
90d7d07
Handle tick reset next to polling
thomaseizinger Dec 30, 2023
2a6ad94
Rewrite generation of dial requests
thomaseizinger Dec 30, 2023
b2d147f
Add docs and additional log statements for no candidates
thomaseizinger Dec 30, 2023
7e3da61
Add more docs and rename protocol name constants
thomaseizinger Dec 30, 2023
e2fe41d
Inline `DialBack` struct
thomaseizinger Dec 30, 2023
1e1aeca
Simplify handling of closed connection
thomaseizinger Dec 30, 2023
d5724c1
ConnectionIds are unique, meaning we can always just insert
thomaseizinger Dec 30, 2023
de91c55
Remove handling of `DialFailure`
thomaseizinger Dec 30, 2023
3719440
Disable connection for future autonat requests on error
thomaseizinger Dec 30, 2023
7b6d354
Remove unnecessary trait implementations
thomaseizinger Dec 30, 2023
8ce2a01
Add comment
thomaseizinger Dec 30, 2023
42ac03c
Rewrite dial-request to always index by nonce
thomaseizinger Dec 30, 2023
3181113
Reset TestStatus on errors
thomaseizinger Dec 30, 2023
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
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"core",
"examples/autonat",
"examples/autonatv2",
"examples/browser-webrtc",
"examples/chat",
"examples/dcutr",
Expand Down Expand Up @@ -46,9 +47,9 @@ members = [
"protocols/rendezvous",
"protocols/request-response",
"protocols/upnp",
"swarm",
"swarm-derive",
"swarm-test",
"swarm",
"transports/dns",
"transports/noise",
"transports/plaintext",
Expand All @@ -57,12 +58,12 @@ members = [
"transports/tcp",
"transports/tls",
"transports/uds",
"transports/webrtc",
"transports/webrtc-websys",
"transports/webrtc",
"transports/websocket-websys",
"transports/websocket",
"transports/webtransport-websys",
"transports/websocket-websys",
"wasm-tests/webtransport-tests", "examples/autonatv2",
"wasm-tests/webtransport-tests",
]
resolver = "2"

Expand Down
462 changes: 220 additions & 242 deletions core/src/transport/global_only.rs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions protocols/autonat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ pub mod v1;
pub mod v2;

#[cfg(feature = "v1")]
#[deprecated(since = "0.13.0", note = "Please use `v1` module instead.")]
#[allow(deprecated)]
pub use v1::*;


7 changes: 4 additions & 3 deletions protocols/autonat/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
//! Implementation of the [AutoNAT](https://github.com/libp2p/specs/blob/master/autonat/README.md) protocol.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![deprecated(note = "Please use `v2` module instead.")]

mod behaviour;
mod protocol;
pub(crate) mod behaviour;
pub(crate) mod protocol;

pub use self::{
behaviour::{
Expand All @@ -34,7 +35,7 @@ pub use self::{
};
pub use libp2p_request_response::{InboundFailure, OutboundFailure};

mod proto {
pub(crate) mod proto {
#![allow(unreachable_pub)]
include!("v1/generated/mod.rs");
pub(crate) use self::structs::{mod_Message::*, Message};
Expand Down
4 changes: 2 additions & 2 deletions protocols/autonat/src/v1/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
mod as_client;
mod as_server;

use crate::v1::protocol::{AutoNatCodec, DialRequest, DialResponse, ResponseError};
use crate::v1::DEFAULT_PROTOCOL_NAME;
use crate::protocol::{AutoNatCodec, DialRequest, DialResponse, ResponseError};
use crate::DEFAULT_PROTOCOL_NAME;
use as_client::AsClient;
pub use as_client::{OutboundProbeError, OutboundProbeEvent};
use as_server::AsServer;
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/src/v1/behaviour/as_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use crate::v1::ResponseError;
use crate::ResponseError;

use super::{
Action, AutoNatCodec, Config, DialRequest, DialResponse, Event, HandleInnerEvent, NatStatus,
Expand Down
1 change: 0 additions & 1 deletion protocols/autonat/src/v1/behaviour/as_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ impl<'a> HandleInnerEvent for AsServer<'a> {
NonZeroU8::new(1).expect("1 > 0"),
)
.addresses(addrs)
.allocate_new_port()
.build(),
},
])
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/src/v1/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use crate::v1::proto;
use crate::proto;
use async_trait::async_trait;
use asynchronous_codec::{FramedRead, FramedWrite};
use futures::io::{AsyncRead, AsyncWrite};
Expand Down
4 changes: 2 additions & 2 deletions protocols/autonat/src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mod global_only;
pub(crate) mod protocol;
pub mod server;

pub(crate) const REQUEST_PROTOCOL_NAME: StreamProtocol =
pub(crate) const DIAL_REQUEST_PROTOCOL: StreamProtocol =
StreamProtocol::new("/libp2p/autonat/2/dial-request");
pub(crate) const DIAL_BACK_PROTOCOL_NAME: StreamProtocol =
pub(crate) const DIAL_BACK_PROTOCOL: StreamProtocol =
StreamProtocol::new("/libp2p/autonat/2/dial-back");

type Nonce = u64;
Loading
Loading