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

chore(websocket): change name convention #5873

Merged
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ libp2p-upnp = { version = "0.4.0", path = "protocols/upnp" }
libp2p-webrtc = { version = "0.9.0-alpha", path = "transports/webrtc" }
libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.45.0", path = "transports/websocket" }
libp2p-websocket = { version = "0.45.1", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" }
libp2p-webtransport-websys = { version = "0.5.0", path = "transports/webtransport-websys" }
libp2p-yamux = { version = "0.47.0", path = "muxers/yamux" }
Expand Down
2 changes: 1 addition & 1 deletion libp2p/src/builder/phase/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! impl_websocket_builder {
{
let security_upgrade = security_upgrade.into_security_upgrade(&self.keypair)
.map_err(WebsocketErrorInner::SecurityUpgrade)?;
let websocket_transport = libp2p_websocket::WsConfig::new(
let websocket_transport = libp2p_websocket::Config::new(
$dnsTcp.await.map_err(WebsocketErrorInner::Dns)?,
)
.upgrade(libp2p_core::upgrade::Version::V1Lazy)
Expand Down
2 changes: 1 addition & 1 deletion transports/pnet/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn can_establish_connection_tcp() {
#[tokio::test]
async fn can_establish_connection_websocket() {
can_establish_connection_inner_with_timeout(
|| libp2p_websocket::WsConfig::new(libp2p_tcp::tokio::Transport::default()),
|| libp2p_websocket::Config::new(libp2p_tcp::tokio::Transport::default()),
"/ip4/127.0.0.1/tcp/0/ws".parse().unwrap(),
)
.await
Expand Down
4 changes: 4 additions & 0 deletions transports/websocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.45.1
- Rename types to match naming convention in [discussion 2174](https://github.com/libp2p/rust-libp2p/discussions/2174).
See [PR 5873](https://github.com/libp2p/rust-libp2p/pull/5873).

## 0.45.0

- fix: Return `Error::InvalidMultiaddr` when dialed to a `/dnsaddr` address
Expand Down
2 changes: 1 addition & 1 deletion transports/websocket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-websocket"
edition = "2021"
rust-version = { workspace = true }
description = "WebSocket transport for libp2p"
version = "0.45.0"
version = "0.45.1"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
12 changes: 6 additions & 6 deletions transports/websocket/src/framed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ const MAX_DATA_SIZE: usize = 256 * 1024 * 1024;

/// A Websocket transport whose output type is a [`Stream`] and [`Sink`] of
/// frame payloads which does not implement [`AsyncRead`] or
/// [`AsyncWrite`]. See [`crate::WsConfig`] if you require the latter.
/// [`AsyncWrite`]. See [`crate::Config`] if you require the latter.
#[derive(Debug)]
pub struct WsConfig<T> {
pub struct Config<T> {
transport: Arc<Mutex<T>>,
max_data_size: usize,
tls_config: tls::Config,
Expand All @@ -62,13 +62,13 @@ pub struct WsConfig<T> {
listener_protos: HashMap<ListenerId, WsListenProto<'static>>,
}

impl<T> WsConfig<T>
impl<T> Config<T>
where
T: Send,
{
/// Create a new websocket transport based on another transport.
pub fn new(transport: T) -> Self {
WsConfig {
Config {
transport: Arc::new(Mutex::new(transport)),
max_data_size: MAX_DATA_SIZE,
tls_config: tls::Config::client(),
Expand Down Expand Up @@ -108,7 +108,7 @@ where

type TlsOrPlain<T> = future::Either<future::Either<client::TlsStream<T>, server::TlsStream<T>>, T>;

impl<T> Transport for WsConfig<T>
impl<T> Transport for Config<T>
where
T: Transport + Send + Unpin + 'static,
T::Error: Send + 'static,
Expand Down Expand Up @@ -242,7 +242,7 @@ where
}
}

impl<T> WsConfig<T>
impl<T> Config<T>
where
T: Transport + Send + Unpin + 'static,
T::Error: Send + 'static,
Expand Down
23 changes: 11 additions & 12 deletions transports/websocket/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ use rw_stream_sink::RwStreamSink;
/// # #[async_std::main]
/// # async fn main() {
///
/// let mut transport = websocket::WsConfig::new(
/// let mut transport = websocket::Config::new(
/// dns::async_std::Transport::system(tcp::async_io::Transport::new(tcp::Config::default()))
/// .await
/// .unwrap(),
Expand Down Expand Up @@ -117,7 +117,7 @@ use rw_stream_sink::RwStreamSink;
/// # async fn main() {
///
/// let mut transport =
/// websocket::WsConfig::new(tcp::async_io::Transport::new(tcp::Config::default()));
/// websocket::Config::new(tcp::async_io::Transport::new(tcp::Config::default()));
///
/// let id = transport
/// .listen_on(
Expand All @@ -135,15 +135,15 @@ use rw_stream_sink::RwStreamSink;
/// # }
/// ```
#[derive(Debug)]
pub struct WsConfig<T: Transport>
pub struct Config<T: Transport>
where
T: Transport,
T::Output: AsyncRead + AsyncWrite + Send + Unpin + 'static,
{
transport: libp2p_core::transport::map::Map<framed::WsConfig<T>, WrapperFn<T::Output>>,
transport: libp2p_core::transport::map::Map<framed::Config<T>, WrapperFn<T::Output>>,
}

impl<T: Transport> WsConfig<T>
impl<T: Transport> Config<T>
where
T: Transport + Send + Unpin + 'static,
T::Error: Send + 'static,
Expand All @@ -161,8 +161,7 @@ where
/// > the inner transport.
pub fn new(transport: T) -> Self {
Self {
transport: framed::WsConfig::new(transport)
.map(wrap_connection as WrapperFn<T::Output>),
transport: framed::Config::new(transport).map(wrap_connection as WrapperFn<T::Output>),
}
}

Expand Down Expand Up @@ -195,7 +194,7 @@ where
}
}

impl<T> Transport for WsConfig<T>
impl<T> Transport for Config<T>
where
T: Transport + Send + Unpin + 'static,
T::Error: Send + 'static,
Expand Down Expand Up @@ -236,7 +235,7 @@ where
}
}

/// Type alias corresponding to `framed::WsConfig::Dial` and `framed::WsConfig::ListenerUpgrade`.
/// Type alias corresponding to `framed::Config::Dial` and `framed::Config::ListenerUpgrade`.
pub type InnerFuture<T, E> = BoxFuture<'static, Result<Connection<T>, Error<E>>>;

/// Function type that wraps a websocket connection (see. `wrap_connection`).
Expand Down Expand Up @@ -310,7 +309,7 @@ mod tests {
use libp2p_identity::PeerId;
use libp2p_tcp as tcp;

use super::WsConfig;
use super::Config;

#[test]
fn dialer_connects_to_listener_ipv4() {
Expand All @@ -324,8 +323,8 @@ mod tests {
futures::executor::block_on(connect(a))
}

fn new_ws_config() -> WsConfig<tcp::async_io::Transport> {
WsConfig::new(tcp::async_io::Transport::new(tcp::Config::default()))
fn new_ws_config() -> Config<tcp::async_io::Transport> {
Config::new(tcp::async_io::Transport::new(tcp::Config::default()))
}

async fn connect(listen_addr: Multiaddr) {
Expand Down
Loading