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:
1 parent
499143050b
commit
583e4e752d
4 files changed
+68
-4
No files matched your search
+18
-2
@@ -830,8 +830,11 @@ namespace Echoion::Core
|
||||
commandManager_->setServerConfig(config);
|
||||
}
|
||||
|
||||
// Re-apply the network proxy from config (idempotent store).
|
||||
if (networkClient_) {
|
||||
// Re-apply network settings to every outbound client (NetworkClient,
|
||||
// yt-dlp, ffmpeg), not just the HTTP client.
|
||||
if (musicManager_) {
|
||||
musicManager_->applyNetworkConfig(config.network);
|
||||
} else if (networkClient_) {
|
||||
networkClient_->setProxy(config.network.proxy);
|
||||
}
|
||||
|
||||
@@ -898,12 +901,25 @@ namespace Echoion::Core
|
||||
// Update local config
|
||||
config_ = *configResult;
|
||||
|
||||
// Keep the shared ConfigManager in sync so components that read through
|
||||
// it (cookies, API key, etc.) see the reloaded values.
|
||||
configManager_.updateConfig(config_, false);
|
||||
|
||||
// Update components with new config
|
||||
if (commandManager_) {
|
||||
commandManager_->setPrefix(config_.bot.commandPrefix);
|
||||
commandManager_->setServerConfig(config_);
|
||||
}
|
||||
|
||||
// Re-apply network settings so a proxy edit actually reaches every
|
||||
// outbound client (HTTP NetworkClient, yt-dlp, ffmpeg) — not just the
|
||||
// config copy. Without this the YouTube API kept using the old/no proxy.
|
||||
if (musicManager_) {
|
||||
musicManager_->applyNetworkConfig(config_.network);
|
||||
} else if (networkClient_) {
|
||||
networkClient_->setProxy(config_.network.proxy);
|
||||
}
|
||||
|
||||
Void::Log::info("Core", "{}", "Configuration reloaded from disk");
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user