Fix UPnP on Sony
This commit is contained in:
parent
a38480e876
commit
f4f82ed4b4
5 changed files with 47 additions and 17 deletions
|
|
@ -17,7 +17,8 @@ use std::str::FromStr;
|
|||
use std::time::Duration;
|
||||
use tokio::io::AsyncSeekExt;
|
||||
use tokio::net::TcpListener;
|
||||
use tracing::{debug, error_span, trace};
|
||||
use tower_http::trace::{DefaultOnFailure, DefaultOnResponse, OnFailure};
|
||||
use tracing::{debug, error_span, trace, Span};
|
||||
|
||||
use axum::Router;
|
||||
|
||||
|
|
@ -572,17 +573,33 @@ impl HttpApi {
|
|||
let app = app
|
||||
.layer(cors_layer)
|
||||
.layer(
|
||||
tower_http::trace::TraceLayer::new_for_http().make_span_with(|req: &Request| {
|
||||
let method = req.method();
|
||||
let uri = req.uri();
|
||||
if let Some(ConnectInfo(addr)) =
|
||||
req.extensions().get::<ConnectInfo<SocketAddr>>()
|
||||
{
|
||||
error_span!("request", %method, %uri, %addr)
|
||||
} else {
|
||||
error_span!("request", %method, %uri)
|
||||
}
|
||||
}),
|
||||
tower_http::trace::TraceLayer::new_for_http()
|
||||
.make_span_with(|req: &Request| {
|
||||
let method = req.method();
|
||||
let uri = req.uri();
|
||||
if let Some(ConnectInfo(addr)) =
|
||||
req.extensions().get::<ConnectInfo<SocketAddr>>()
|
||||
{
|
||||
error_span!("request", %method, %uri, %addr)
|
||||
} else {
|
||||
error_span!("request", %method, %uri)
|
||||
}
|
||||
})
|
||||
.on_request(|req: &Request, _: &Span| {
|
||||
if req.uri().path().starts_with("/upnp") {
|
||||
debug!(headers=?req.headers())
|
||||
}
|
||||
})
|
||||
.on_response(DefaultOnResponse::new().include_headers(true))
|
||||
.on_failure({
|
||||
let mut default = DefaultOnFailure::new();
|
||||
move |failure_class, latency, span: &Span| match failure_class {
|
||||
tower_http::classify::ServerErrorsFailureClass::StatusCode(
|
||||
StatusCode::NOT_IMPLEMENTED,
|
||||
) => {}
|
||||
_ => default.on_failure(failure_class, latency, span),
|
||||
}
|
||||
}),
|
||||
)
|
||||
.into_make_service_with_connect_info::<SocketAddr>();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@ use crate::{
|
|||
};
|
||||
|
||||
async fn description_xml(State(state): State<UnpnServerState>) -> impl IntoResponse {
|
||||
state.rendered_root_description.clone()
|
||||
(
|
||||
[(CONTENT_TYPE, CONTENT_TYPE_XML_UTF8)],
|
||||
state.rendered_root_description.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
async fn generate_content_directory_control_response(
|
||||
|
|
@ -94,7 +97,6 @@ async fn subscription(
|
|||
}
|
||||
|
||||
let (parts, _body) = request.into_parts();
|
||||
trace!(?parts.headers, "subscription request");
|
||||
let is_event = parts
|
||||
.headers
|
||||
.get(HeaderName::from_static("nt"))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@
|
|||
<minor>0</minor>
|
||||
</specVersion>
|
||||
<actionList>
|
||||
<action>
|
||||
<name>GetSystemUpdateID</name>
|
||||
<argumentList>
|
||||
<argument>
|
||||
<name>Id</name>
|
||||
<direction>out</direction>
|
||||
<relatedStateVariable>SystemUpdateID</relatedStateVariable>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</action>
|
||||
<action>
|
||||
<name>Browse</name>
|
||||
<argumentList>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
|
||||
<SCPDURL>{http_prefix}/scpd/ConnectionManager.xml</SCPDURL>
|
||||
<controlURL>{http_prefix}/control/ConnectionManager</controlURL>
|
||||
<eventSubURL>{http_prefix}/subscribe</eventSubURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
<presentationURL>/</presentationURL>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
use tokio::sync::{broadcast::error::RecvError, Notify};
|
||||
use tracing::{error_span, warn, Instrument};
|
||||
use tracing::{debug, error_span, warn, Instrument};
|
||||
|
||||
pub struct Subscription {
|
||||
pub url: url::Url,
|
||||
|
|
@ -142,7 +142,7 @@ impl UpnpServerStateInner {
|
|||
)
|
||||
.await
|
||||
{
|
||||
warn!(error=?e, "error updating UPNP subscription");
|
||||
debug!(error=?e, "error updating UPNP subscription");
|
||||
}
|
||||
}
|
||||
Err(RecvError::Lagged(by)) => {
|
||||
|
|
@ -158,7 +158,7 @@ impl UpnpServerStateInner {
|
|||
)
|
||||
.await
|
||||
{
|
||||
warn!(error=?e, "error updating UPNP subscription");
|
||||
debug!(error=?e, "error updating UPNP subscription");
|
||||
}
|
||||
}
|
||||
Err(RecvError::Closed) => return Ok(()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue