mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 19:30:26 +08:00
RealPing: properly proxy IPv6 address
This commit is contained in:
parent
19db69a288
commit
8d3ee69957
@ -1 +1 @@
|
|||||||
5896
|
5897
|
||||||
|
@ -157,10 +157,13 @@ namespace Qv2ray::components::latency::realping
|
|||||||
data.failedCount = 0;
|
data.failedCount = 0;
|
||||||
data.worst = 0;
|
data.worst = 0;
|
||||||
data.avg = 0;
|
data.avg = 0;
|
||||||
|
struct sockaddr_in addr{};
|
||||||
|
const auto &ip = GlobalConfig.inboundConfig.listenip.toStdString();
|
||||||
|
bool is_ipv4 = (uv_ip4_addr(ip.c_str(), 0, &addr) == 0);
|
||||||
|
const auto &proxy_ip = is_ipv4 ? GlobalConfig.inboundConfig.listenip : "[" + GlobalConfig.inboundConfig.listenip + "]";
|
||||||
auto local_proxy_address =
|
auto local_proxy_address =
|
||||||
(!GlobalConfig.inboundConfig.useHTTP ?
|
(!GlobalConfig.inboundConfig.useHTTP ? "socks5://" + proxy_ip + ":" + QSTRN(GlobalConfig.inboundConfig.socksSettings.port) :
|
||||||
"socks5://" + GlobalConfig.inboundConfig.listenip + ":" + QSTRN(GlobalConfig.inboundConfig.socksSettings.port) :
|
"http://" + proxy_ip + ":" + QSTRN(GlobalConfig.inboundConfig.httpSettings.port))
|
||||||
"http://" + GlobalConfig.inboundConfig.listenip + ":" + QSTRN(GlobalConfig.inboundConfig.httpSettings.port))
|
|
||||||
.toStdString();
|
.toStdString();
|
||||||
auto curlMultiHandle = curl_multi_init();
|
auto curlMultiHandle = curl_multi_init();
|
||||||
auto globalInfo = std::make_shared<RealPingGlobalInfo>(
|
auto globalInfo = std::make_shared<RealPingGlobalInfo>(
|
||||||
@ -185,8 +188,9 @@ namespace Qv2ray::components::latency::realping
|
|||||||
curl_easy_setopt(handle, CURLOPT_URL, request_name.c_str());
|
curl_easy_setopt(handle, CURLOPT_URL, request_name.c_str());
|
||||||
curl_easy_setopt(handle, CURLOPT_PROXY, local_proxy_address.c_str());
|
curl_easy_setopt(handle, CURLOPT_PROXY, local_proxy_address.c_str());
|
||||||
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, noop_cb);
|
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, noop_cb);
|
||||||
/* complete within 10 seconds */
|
/* complete within 5 seconds */
|
||||||
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, 5L);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 5L);
|
||||||
curl_multi_add_handle(curlMultiHandle, handle);
|
curl_multi_add_handle(curlMultiHandle, handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user