Skip to content

Commit

Permalink
Merge pull request #2 from libp2p/autonatv2-thomas-followup
Browse files Browse the repository at this point in the history
Follow-up commits for AutoNATv2
  • Loading branch information
umgefahren authored Dec 30, 2023
2 parents c51f8cc + 3181113 commit 88b1092
Show file tree
Hide file tree
Showing 17 changed files with 645 additions and 798 deletions.
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

0 comments on commit 88b1092

Please sign in to comment.