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
@@ -128,6 +128,36 @@ namespace Echoion::Core
|
||||
return {};
|
||||
}
|
||||
|
||||
void MusicManager::applyNetworkConfig(const Api::NetworkConfig& network)
|
||||
{
|
||||
// Push the (possibly changed) proxy to every outbound client. Passing
|
||||
// the optional straight through also clears the proxy everywhere when
|
||||
// it is disabled/removed in the config.
|
||||
const auto& proxy = network.proxy;
|
||||
const bool enabled = proxy.has_value() && proxy->enabled();
|
||||
|
||||
if (networkClient_) {
|
||||
networkClient_->setProxy(proxy);
|
||||
}
|
||||
if (youTubeClient_) {
|
||||
youTubeClient_->setProxyConfig(proxy);
|
||||
}
|
||||
if (audioDecoder_) {
|
||||
audioDecoder_->setProxyConfig(proxy);
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
Void::Log::info("MusicManager", "{}", std::format(
|
||||
"Network config re-applied: {} proxy {}:{}",
|
||||
(proxy->kind == Void::Net::ProxyConfig::Kind::Socks5) ? "SOCKS5"
|
||||
: "HTTP",
|
||||
proxy->host, proxy->port));
|
||||
} else {
|
||||
Void::Log::info("MusicManager", "{}",
|
||||
"Network config re-applied: proxy disabled");
|
||||
}
|
||||
}
|
||||
|
||||
void MusicManager::shutdown()
|
||||
{
|
||||
isPlaying_ = false;
|
||||
|
||||
Reference in new issue
Block a user