Ensure all outbound calls honor the proxy (fix YouTube API bypass)

Two gaps let network calls escape the configured proxy:

1. NetworkClient::executeRequest read proxy_ without holding mutex_, while
   setProxy()/initialize() write it from other threads (init, config reload).
   A torn read of optional<ProxyConfig> (it holds std::string host/user/pass)
   could yield an empty host -> enabled()==false -> a silent DIRECT connection.
   yt-dlp/ffmpeg snapshot their proxy under their own mutexes, so only the
   HTTP path (YouTube Data API, URL shortener) was affected — matching the
   observed "YouTube API without proxy". Snapshot proxy_ under the lock.

2. Core::reloadConfig updated only the config copy + command manager; it never
   re-applied the proxy to the network stack, so editing the proxy and running
   !reloadconfig left every client on the old/no proxy. Add
   MusicManager::applyNetworkConfig() to push the proxy to the NetworkClient,
   the yt-dlp subprocess, and the ffmpeg AudioDecoder at once, and call it from
   both reloadConfig and updateConfig (which previously touched only the HTTP
   client). reloadConfig now also syncs the shared ConfigManager.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-24 21:37:46 +03:00
1 parent 499143050b
commit 583e4e752d
4 files changed
+68 -4

No files matched your search

+13 -2
View File
@@ -13,7 +13,10 @@ namespace Echoion::Core
Api::Result<void> NetworkClient::initialize(
const std::optional<Void::Net::ProxyConfig>& proxy)
{
proxy_ = proxy;
{
std::lock_guard<std::mutex> lock(mutex_);
proxy_ = proxy;
}
initialized_ = true;
Void::Log::info("NetworkClient", "{}", std::format("NetworkClient initialized (proxy: {})",
proxy.has_value() ? "enabled" : "disabled"));
@@ -26,7 +29,15 @@ namespace Echoion::Core
NetworkClient::executeRequest(const Void::Net::Request& req)
{
Void::Net::HttpClient client;
const auto active = proxy_;
// Snapshot the proxy under the lock. setProxy()/initialize() can run on
// other threads (config reload, init), and a torn read of the
// optional<ProxyConfig> (it holds std::string host/user/pass) could
// yield an empty host -> enabled()==false -> a silent direct connection.
std::optional<Void::Net::ProxyConfig> active;
{
std::lock_guard<std::mutex> lock(mutex_);
active = proxy_;
}
if (active && active->enabled()) {
client.set_proxy(*active);
}