mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
fix(audio): set User-Agent header, add debug fetch logging
Set psysonic/<version> as User-Agent on the audio reqwest::Client to prevent reverse proxies (nginx, Caddy, Traefik) from blocking requests with a 403. Add #[cfg(debug_assertions)] logging in fetch_data to show the exact URL, status, content-type and server header — useful for diagnosing proxy-related 403s reported by users. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Generated
+1
-1
@@ -3397,7 +3397,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "psysonic"
|
name = "psysonic"
|
||||||
version = "1.34.6"
|
version = "1.34.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"biquad",
|
"biquad",
|
||||||
"discord-rich-presence",
|
"discord-rich-presence",
|
||||||
|
|||||||
@@ -1684,6 +1684,7 @@ pub fn create_engine() -> (AudioEngine, std::thread::JoinHandle<()>) {
|
|||||||
http_client: reqwest::Client::builder()
|
http_client: reqwest::Client::builder()
|
||||||
.timeout(Duration::from_secs(30))
|
.timeout(Duration::from_secs(30))
|
||||||
.use_rustls_tls()
|
.use_rustls_tls()
|
||||||
|
.user_agent(format!("psysonic/{}", env!("CARGO_PKG_VERSION")))
|
||||||
.build()
|
.build()
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
eq_gains: Arc::new(std::array::from_fn(|_| AtomicU32::new(0f32.to_bits()))),
|
eq_gains: Arc::new(std::array::from_fn(|_| AtomicU32::new(0f32.to_bits()))),
|
||||||
@@ -1769,6 +1770,24 @@ async fn fetch_data(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let response = state.http_client.get(url).send().await.map_err(|e| e.to_string())?;
|
let response = state.http_client.get(url).send().await.map_err(|e| e.to_string())?;
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
let status = response.status();
|
||||||
|
let ct = response.headers()
|
||||||
|
.get(reqwest::header::CONTENT_TYPE)
|
||||||
|
.and_then(|v| v.to_str().ok())
|
||||||
|
.unwrap_or("-");
|
||||||
|
let server_hdr = response.headers()
|
||||||
|
.get("server")
|
||||||
|
.and_then(|v| v.to_str().ok())
|
||||||
|
.unwrap_or("-");
|
||||||
|
// Strip auth params from URL before logging.
|
||||||
|
let safe_url = url.split('?').next().unwrap_or(url);
|
||||||
|
eprintln!(
|
||||||
|
"[audio] fetch {} → {} | content-type: {} | server: {}",
|
||||||
|
safe_url, status, ct, server_hdr
|
||||||
|
);
|
||||||
|
}
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
if state.generation.load(Ordering::SeqCst) != gen {
|
if state.generation.load(Ordering::SeqCst) != gen {
|
||||||
return Ok(None); // superseded
|
return Ok(None); // superseded
|
||||||
|
|||||||
Reference in New Issue
Block a user