diff --git a/.env.example b/.env.example index 49d95b5..a75f854 100644 --- a/.env.example +++ b/.env.example @@ -217,3 +217,8 @@ MATOMO_SITE_ID="" TIMEZONE="UTC" DEBUG=false SHOW_ERRORS=false + +# User-Agent sent with every outbound request this server makes (Genius, +# Last.fm, LRCLIB, custom now-playing feeds). Override this per deployment if +# you run more than one station and want each to identify itself distinctly. +OUTBOUND_USER_AGENT="radio/2026.07 (+https://git.dou.bet/iamdoubz/radio)" diff --git a/api/_bootstrap.php b/api/_bootstrap.php index df2a24f..e142d20 100644 --- a/api/_bootstrap.php +++ b/api/_bootstrap.php @@ -51,7 +51,7 @@ function http_get($url, $timeout = 5, $headers = []) { CURLOPT_TIMEOUT => (int) $timeout, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, - CURLOPT_USERAGENT => 'radio-site/1.0 (+https://github.com)', + CURLOPT_USERAGENT => cfg('runtime.user_agent'), ]); if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); @@ -67,7 +67,7 @@ function http_get($url, $timeout = 5, $headers = []) { $ctx = stream_context_create([ 'http' => [ 'timeout' => (int) $timeout, - 'header' => implode("\r\n", $headers), + 'header' => implode("\r\n", array_merge(['User-Agent: ' . cfg('runtime.user_agent')], $headers)), 'ignore_errors' => true, ], 'ssl' => ['verify_peer' => true, 'verify_peer_name' => true], diff --git a/config.php b/config.php index a665fc7..274d064 100644 --- a/config.php +++ b/config.php @@ -257,6 +257,10 @@ if (!defined('RADIO_CONFIG_LOADED')) { 'timezone' => radio_env('TIMEZONE', 'UTC'), 'debug' => radio_env_bool('DEBUG', false), 'show_errors' => radio_env_bool('SHOW_ERRORS', false), + // Sent with every outbound request this server makes (Genius, + // Last.fm, LRCLIB, custom now-playing feeds). Override per + // deployment so multiple stations identify themselves distinctly. + 'user_agent' => radio_env('OUTBOUND_USER_AGENT', 'radio/2026.07 (+https://git.dou.bet/iamdoubz/radio)'), ], ];