libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.53k stars 944 forks source link

libp2p-websocket: replace /wss with /tls/ws #2449

Closed tomaka closed 1 year ago

tomaka commented 2 years ago

According to the multiaddr spec, the /wss specifier is deprecated and /tls/ws should be preferred. libp2p-websocket only supports /wss.

(I've taken the liberty to mark this as "easy", as it's just about interpreting the multiaddr)

jochasinga commented 2 years ago

Shouldn't this change be made on the multiaddr crate too?

mxinden commented 2 years ago

Shouldn't this change be made on the multiaddr crate too?

Should be done via https://github.com/multiformats/rust-multiaddr/pull/48/.

jochasinga commented 2 years ago

I can tackle this @mxinden @tomaka.

jochasinga commented 2 years ago

Looks to me like even /wss scheme isn't supported currently? Keep getting MultiaddrNotSupported("/ip6/::1/tcp/0/wss") running test.

Since multiformats/rust-multiaddr#48 added tls support, will this be just upgrading libp2p-websocket to use it?

jochasinga commented 2 years ago

Does this test case for rust-multiaddr make sense @tomaka?


// rust-multiaddr/src/from_url.rs

#[test]
fn normal_usage_wss() {
    let addr = from_url("wss://127.0.0.1:8000").unwrap();
    assert_eq!(addr, "/ip4/127.0.0.1/tcp/8000/tls/ws".parse().unwrap());
    assert_eq!(addr, "/ip4/127.0.0.1/tcp/8000/wss".parse().unwrap());
}

Basically, when parsing a multiaddress, when a tls is found, we peek to see if the next one is "ws" and write that off as Protocol::Wss(..).

tomaka commented 2 years ago

I don't think it's a good idea to make /tls/ws and /wss equal. This is too magic and could lead to violated assumptions. In my opinion the only change needed is making libp2p-websocket support /tls/ws.

navasvarela commented 1 year ago

Hello everyone, are there any updates on TLS support for websockets?

thomaseizinger commented 1 year ago

Hello everyone, are there any updates on TLS support for websockets?

Support is there and there is an example in the docs! This ticket is only about the deprecated multiaddr component.

navasvarela commented 1 year ago

Hello everyone, are there any updates on TLS support for websockets?

Support is there and there is an example in the docs! This ticket is only about the deprecated multiaddr component.

Thank you! Would you be able to point me to the example?

thomaseizinger commented 1 year ago

Hello everyone, are there any updates on TLS support for websockets?

Support is there and there is an example in the docs! This ticket is only about the deprecated multiaddr component.

Thank you! Would you be able to point me to the example?

See https://docs.rs/libp2p-websocket/latest/libp2p_websocket/struct.WsConfig.html#examples. It is a bit hard to discover. We are in the process of making the APIs of our crates more consistent, see https://github.com/libp2p/rust-libp2p/issues/2217. Help in doing that for libp2p-websocket would be appreciated :)

thomaseizinger commented 1 year ago

Closing in favor of https://github.com/multiformats/rust-multiaddr/issues/100.