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

fix: relative /rtc & remove sensitive logs #220

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.

11 changes: 9 additions & 2 deletions livekit-api/src/signal_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ impl SignalClient {
"http"
})
.unwrap();
ws_url.set_path("/rtc/validate");

if let Ok(mut segs) = ws_url.path_segments_mut() {
segs.extend(&["rtc", "validate"]);
}

if let Ok(res) = reqwest::get(ws_url.as_str()).await {
let status = res.status();
Expand Down Expand Up @@ -299,7 +302,11 @@ fn is_queuable(signal: &proto::signal_request::Message) -> bool {

fn get_livekit_url(url: &str, token: &str, options: &SignalOptions) -> SignalResult<url::Url> {
let mut lk_url = url::Url::parse(url)?;
lk_url.set_path("/rtc");

if let Ok(mut segs) = lk_url.path_segments_mut() {
segs.push("rtc");
}

lk_url
.query_pairs_mut()
.append_pair("sdk", "rust")
Expand Down
23 changes: 22 additions & 1 deletion livekit-api/src/signal_client/signal_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use tokio::sync::{mpsc, oneshot};
use tokio::task::JoinHandle;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
use url::form_urlencoded;

type WebSocket = WebSocketStream<MaybeTlsStream<TcpStream>>;

Expand Down Expand Up @@ -59,7 +60,27 @@ impl SignalStream {
Self,
mpsc::UnboundedReceiver<Box<proto::signal_response::Message>>,
)> {
log::info!("connecting to SignalClient: {}", url);
{
// Don't log sensitive info
let mut url = url.clone();
let filtered_pairs: Vec<_> = url
.query_pairs()
.filter(|(key, _)| key != "access_token")
.map(|(k, v)| (k.into_owned(), v.into_owned()))
.collect();

{
let mut query_pairs = url.query_pairs_mut();
query_pairs.clear();
for (key, value) in filtered_pairs {
query_pairs.append_pair(&key, &value);
}

query_pairs.append_pair("access_token", "...");
}

log::info!("connecting to {}", url);
}

// Automatically switch to websocket scheme when using http
if url.scheme() == "https" {
Expand Down
Loading