mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-20 14:52:22 +02:00
Stream table new columns
This commit is contained in:
@@ -329,7 +329,7 @@ enum ProviderStreamState {
|
||||
pub struct StreamDetails {
|
||||
pub stream: Option<BoxedProviderStream>,
|
||||
stream_info: ProviderStreamInfo,
|
||||
pub input_name: Option<String>,
|
||||
pub provider_name: Option<String>,
|
||||
pub grace_period_millis: u64,
|
||||
pub reconnect_flag: Option<Arc<AtomicOnceFlag>>,
|
||||
pub provider_connection_guard: Option<Arc<ProviderConnectionGuard>>,
|
||||
@@ -340,7 +340,7 @@ impl StreamDetails {
|
||||
Self {
|
||||
stream: Some(stream),
|
||||
stream_info: None,
|
||||
input_name: None,
|
||||
provider_name: None,
|
||||
grace_period_millis: default_grace_period_millis(),
|
||||
reconnect_flag: None,
|
||||
provider_connection_guard: None,
|
||||
@@ -484,6 +484,11 @@ async fn create_stream_response_details(
|
||||
&streaming_strategy.provider_stream_state,
|
||||
config_grace_period_millis,
|
||||
);
|
||||
let provider_name = streaming_strategy
|
||||
.provider_connection_guard
|
||||
.as_ref()
|
||||
.and_then(|guard| guard.get_provider_name());
|
||||
|
||||
match streaming_strategy.provider_stream_state {
|
||||
// custom stream means we display our own stream like connection exhausted, channel-unavailable...
|
||||
ProviderStreamState::Custom(provider_stream) => {
|
||||
@@ -491,7 +496,7 @@ async fn create_stream_response_details(
|
||||
StreamDetails {
|
||||
stream,
|
||||
stream_info,
|
||||
input_name: None,
|
||||
provider_name: provider_name.clone(),
|
||||
grace_period_millis,
|
||||
reconnect_flag: None,
|
||||
provider_connection_guard: streaming_strategy.provider_connection_guard.clone(),
|
||||
@@ -525,14 +530,6 @@ async fn create_stream_response_details(
|
||||
((None, None), None)
|
||||
};
|
||||
|
||||
// if we have no stream, we should release the provider
|
||||
if stream.is_none() {
|
||||
if let Some(guard) = streaming_strategy.provider_connection_guard.take() {
|
||||
drop(guard);
|
||||
}
|
||||
error!("Cant open stream {}", sanitize_sensitive_info(&request_url));
|
||||
}
|
||||
|
||||
if log_enabled!(log::Level::Debug) {
|
||||
if let Some((headers, status_code, response_url)) = stream_info.as_ref() {
|
||||
debug!(
|
||||
@@ -546,10 +543,18 @@ async fn create_stream_response_details(
|
||||
}
|
||||
}
|
||||
|
||||
// if we have no stream, we should release the provider
|
||||
if stream.is_none() {
|
||||
if let Some(guard) = streaming_strategy.provider_connection_guard.take() {
|
||||
drop(guard);
|
||||
}
|
||||
error!("Cant open stream {}", sanitize_sensitive_info(&request_url));
|
||||
}
|
||||
|
||||
StreamDetails {
|
||||
stream,
|
||||
stream_info,
|
||||
input_name: provider_name,
|
||||
provider_name,
|
||||
grace_period_millis,
|
||||
reconnect_flag,
|
||||
provider_connection_guard: streaming_strategy.provider_connection_guard.take(),
|
||||
@@ -770,7 +775,7 @@ pub async fn force_provider_stream_response(
|
||||
.await;
|
||||
stream_channel.shared = share_stream;
|
||||
let stream =
|
||||
ActiveClientStream::new(stream_details, app_state, user, connection_permission, addr, stream_channel)
|
||||
ActiveClientStream::new(stream_details, app_state, user, connection_permission, addr, stream_channel, req_headers)
|
||||
.await;
|
||||
|
||||
let (status_code, header_map) =
|
||||
@@ -834,7 +839,7 @@ pub async fn stream_response(
|
||||
let share_stream = is_stream_share_enabled(item_type, target);
|
||||
if share_stream {
|
||||
if let Some(value) =
|
||||
shared_stream_response(app_state, stream_url, addr, user, connection_permission, stream_channel.clone()).await
|
||||
shared_stream_response(app_state, stream_url, addr, user, connection_permission, stream_channel.clone(), req_headers).await
|
||||
{
|
||||
return value.into_response();
|
||||
}
|
||||
@@ -860,10 +865,7 @@ pub async fn stream_response(
|
||||
.stream_info
|
||||
.as_ref()
|
||||
.map(|(h, sc, response_url)| (h.clone(), *sc, response_url.clone()));
|
||||
let provider_name = stream_details
|
||||
.provider_connection_guard
|
||||
.as_ref()
|
||||
.and_then(|guard| guard.get_provider_name());
|
||||
let provider_name = stream_details.provider_name.clone();
|
||||
|
||||
let provider_guard = if share_stream {
|
||||
stream_details.provider_connection_guard.take()
|
||||
@@ -872,7 +874,7 @@ pub async fn stream_response(
|
||||
};
|
||||
stream_channel.shared = share_stream;
|
||||
let stream =
|
||||
ActiveClientStream::new(stream_details, app_state, user, connection_permission, addr, stream_channel)
|
||||
ActiveClientStream::new(stream_details, app_state, user, connection_permission, addr, stream_channel, req_headers)
|
||||
.await;
|
||||
let stream_resp = if share_stream {
|
||||
debug_if_enabled!(
|
||||
@@ -986,7 +988,8 @@ async fn shared_stream_response(
|
||||
addr: &str,
|
||||
user: &ProxyUserCredentials,
|
||||
connect_permission: UserConnectionPermission,
|
||||
mut stream_channel: StreamChannel
|
||||
mut stream_channel: StreamChannel,
|
||||
req_headers: &HeaderMap,
|
||||
) -> Option<impl IntoResponse> {
|
||||
if let Some(stream) =
|
||||
SharedStreamManager::subscribe_shared_stream(app_state, stream_url, Some(addr)).await
|
||||
@@ -1007,7 +1010,7 @@ async fn shared_stream_response(
|
||||
let stream_details = StreamDetails::from_stream(stream);
|
||||
stream_channel.shared = true;
|
||||
let stream =
|
||||
ActiveClientStream::new(stream_details, app_state, user, connect_permission, addr, stream_channel)
|
||||
ActiveClientStream::new(stream_details, app_state, user, connect_permission, addr, stream_channel, req_headers)
|
||||
.await
|
||||
.boxed();
|
||||
let mut response = axum::response::Response::builder().status(status_code);
|
||||
|
||||
Reference in New Issue
Block a user