Consume Void::Net directly in NetworkClient and callers

Delete NetworkClient's to_void_method/to_void_proxy/to_api_response bridge
and the Api::RetryConfig member; the client builds Void::Net::Request, sends
via Void::Net::HttpClient, returns Void::Net::Response, and retries via an
internal Void::Retry policy + retryable-status list.

Call sites updated to Void::Net member names: isSuccess()->ok(),
statusCode->status, getHeader()->header() (optional<string_view>),
isRedirect()->status range check; proxy isValid()->enabled(),
requiresAuth()->has_auth(), isSocks5()->kind == Kind::Socks5. Proxy fields
flow through YtDlpManager/AudioDecoder/MusicManager unchanged in spelling.
On-disk proxy shape is now Void::Net::ProxyConfig (kind: None/Http/Socks5);
config.example.json updated and proxy round-trip verified. Build green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-23 13:49:26 +03:00
1 parent 3af9aecbec
commit 9d56a6ff01
12 files changed
+158 -223

No files matched your search

+21 -21
View File
@@ -72,21 +72,21 @@ namespace Echoion::Core
}
void YouTubeClient::setProxyConfig(
const std::optional<Api::ProxyConfig>& proxy)
const std::optional<Void::Net::ProxyConfig>& proxy)
{
if (ytDlpManager_) {
ytDlpManager_->setProxyConfig(proxy);
}
std::lock_guard<std::mutex> lock(configMutex_);
if (proxy.has_value() && proxy->isValid()) {
if (proxy.has_value() && proxy->enabled()) {
ECHOION_LOG_INFO(
std::format("YouTubeClient proxy configured: {}:{}",
proxy->host, proxy->port));
}
}
std::optional<Api::ProxyConfig> YouTubeClient::getProxyConfig() const
std::optional<Void::Net::ProxyConfig> YouTubeClient::getProxyConfig() const
{
if (ytDlpManager_) {
return ytDlpManager_->getProxyConfig();
@@ -413,8 +413,8 @@ namespace Echoion::Core
// Use shared promise so detached thread can safely complete
auto responsePromise =
std::make_shared<std::promise<Api::Result<Api::HttpResponse>>>();
std::future<Api::Result<Api::HttpResponse>> responseFuture =
std::make_shared<std::promise<Api::Result<Void::Net::Response>>>();
std::future<Api::Result<Void::Net::Response>> responseFuture =
responsePromise->get_future();
std::thread apiThread(
@@ -444,7 +444,7 @@ namespace Echoion::Core
ECHOION_LOG_DEBUG("API request thread joined");
// Get the response
Api::Result<Api::HttpResponse> response;
Api::Result<Void::Net::Response> response;
try {
response = responseFuture.get();
} catch (const std::exception& e) {
@@ -457,17 +457,17 @@ namespace Echoion::Core
// Log response status
if (response) {
ECHOION_LOG_DEBUG(
std::format("API response status: {}", response->statusCode));
std::format("API response status: {}", response->status));
} else {
ECHOION_LOG_WARNING(std::format("API request failed: {}",
response.error().message));
}
if (!response || !response->isSuccess()) {
if (!response || !response->ok()) {
return Api::fail(
Api::ErrorCode::NetworkError,
std::format("YouTube API search failed: {}",
response ? std::to_string(response->statusCode)
response ? std::to_string(response->status)
: "no response"));
}
@@ -600,8 +600,8 @@ namespace Echoion::Core
// Execute with timeout (5 seconds) to avoid blocking
// Use shared promise so detached thread can safely complete
auto responsePromise =
std::make_shared<std::promise<Api::Result<Api::HttpResponse>>>();
std::future<Api::Result<Api::HttpResponse>> responseFuture =
std::make_shared<std::promise<Api::Result<Void::Net::Response>>>();
std::future<Api::Result<Void::Net::Response>> responseFuture =
responsePromise->get_future();
std::thread durationThread(
@@ -624,7 +624,7 @@ namespace Echoion::Core
durationThread.join();
Api::Result<Api::HttpResponse> response;
Api::Result<Void::Net::Response> response;
try {
response = responseFuture.get();
} catch (const std::exception& e) {
@@ -633,7 +633,7 @@ namespace Echoion::Core
return;
}
if (!response || !response->isSuccess()) {
if (!response || !response->ok()) {
ECHOION_LOG_WARNING(
"Failed to fetch video durations from YouTube API");
return;
@@ -986,7 +986,7 @@ namespace Echoion::Core
std::string apiUrl = buildPlaylistApiUrl(playlistId, pageToken);
auto response = networkClient_->get(apiUrl);
if (!response || !response->isSuccess()) {
if (!response || !response->ok()) {
ECHOION_LOG_WARNING(
"YouTube API request failed, falling back to yt-dlp");
break; // Fall back to yt-dlp
@@ -1235,7 +1235,7 @@ namespace Echoion::Core
ECHOION_LOG_DEBUG(
std::format("Following redirect for: {}", url_str));
std::vector<Api::HttpHeader> headers = {
std::vector<Void::Net::Header> headers = {
{"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36"}};
@@ -1245,22 +1245,22 @@ namespace Echoion::Core
if (response) {
// Check if we got a redirect
if (response->isRedirect()) {
auto location = response->getHeader("location");
if (response->status >= 300 && response->status < 400) {
auto location = response->header("location");
if (location.has_value()) {
ECHOION_LOG_DEBUG(
std::format("Redirected to: {}", *location));
url_str = *location;
url_str = std::string(*location);
}
} else if (response->isSuccess()) {
} else if (response->ok()) {
// Some shorteners might return the target in the body or we
// might need to look at the URL after any automatic
// redirect following Try to extract from current URL or
// response
auto finalUrl = response->getHeader(
auto finalUrl = response->header(
"x-final-url"); // Some clients add this
if (finalUrl.has_value()) {
url_str = *finalUrl;
url_str = std::string(*finalUrl);
}
}
}