Skip to content

Commit

Permalink
fix(torii-relay): remove tls for ws (#2361)
Browse files Browse the repository at this point in the history
fix: remove tls for ws
  • Loading branch information
glihm authored Aug 29, 2024
1 parent a2fb8ce commit 13cee86
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions crates/torii/libp2p/src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::io::Read;
use std::net::Ipv4Addr;
use std::path::Path;
use std::str::FromStr;
Expand Down Expand Up @@ -95,21 +94,13 @@ impl<P: Provider + Sync> Relay<P> {
})
.expect("Failed to create WebRTC transport")
.with_other_transport(|key| {
let mut transport = websocket::WsConfig::new(
let transport = websocket::WsConfig::new(
dns::tokio::Transport::system(tcp::tokio::Transport::new(
tcp::Config::default(),
))
.unwrap(),
);

let rcgen_cert =
rcgen::generate_simple_self_signed(vec!["localhost".to_string()]).unwrap();
let priv_key = websocket::tls::PrivateKey::new(rcgen_cert.key_pair.serialize_der());
let bytes: Result<Vec<_>, _> = rcgen_cert.cert.der().bytes().collect();
let cert = websocket::tls::Certificate::new(bytes.unwrap());
transport
.set_tls_config(websocket::tls::Config::new(priv_key, vec![cert]).unwrap());

transport
.upgrade(Version::V1)
.authenticate(noise::Config::new(key).unwrap())
Expand Down Expand Up @@ -168,10 +159,10 @@ impl<P: Provider + Sync> Relay<P> {
.with(Protocol::WebRTCDirect);
swarm.listen_on(listen_addr_webrtc.clone())?;

// WSS
// WS
let listen_addr_wss = Multiaddr::from(Ipv4Addr::UNSPECIFIED)
.with(Protocol::Tcp(port_websocket))
.with(Protocol::Wss("/".to_string().into()));
.with(Protocol::Ws("/".to_string().into()));
swarm.listen_on(listen_addr_wss.clone())?;

// Clients will send their messages to the "message" topic
Expand Down

0 comments on commit 13cee86

Please sign in to comment.