Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8c705554f |
@@ -85,31 +85,17 @@ impl crate::proxy::Proxy {
|
|||||||
description: "Could not start stream".to_string(),
|
description: "Could not start stream".to_string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Validate single-use stream token
|
// Validate single-use stream token via the shared helper so this
|
||||||
|
// handler and its unit tests exercise the same code path.
|
||||||
let provided_token = req.query::<String>("token").unwrap_or_default();
|
let provided_token = req.query::<String>("token").unwrap_or_default();
|
||||||
{
|
if let Err(msg) = super::validate_stream_token(&self, &provided_token).await {
|
||||||
let mut token_guard = self.stream_token.write().await;
|
error!("Stream token validation failed: {msg}");
|
||||||
match token_guard.take() {
|
return Err(AppError {
|
||||||
Some(expected) if expected == provided_token => {
|
status_code: StatusCode::UNAUTHORIZED,
|
||||||
// Token consumed successfully (single-use)
|
description: msg,
|
||||||
info!("Stream token validated and consumed");
|
});
|
||||||
}
|
|
||||||
Some(_) => {
|
|
||||||
error!("Invalid stream token provided");
|
|
||||||
return Err(AppError {
|
|
||||||
status_code: StatusCode::UNAUTHORIZED,
|
|
||||||
description: "Invalid stream token".to_string(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
error!("Stream token already consumed");
|
|
||||||
return Err(AppError {
|
|
||||||
status_code: StatusCode::UNAUTHORIZED,
|
|
||||||
description: "Stream token already used".to_string(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
info!("Stream token validated and consumed");
|
||||||
|
|
||||||
info!("WebTransport connection initiated");
|
info!("WebTransport connection initiated");
|
||||||
let (wt_stream_send, wt_stream_recv, wt_datagram_send) = match setup_webtransport(req).await
|
let (wt_stream_send, wt_stream_recv, wt_datagram_send) = match setup_webtransport(req).await
|
||||||
|
|||||||
Reference in New Issue
Block a user