Fixed host ping time calculation when using SOCKS5 proxy
This commit is contained in:
@@ -80,6 +80,8 @@ struct CurlContext
|
||||
|
||||
uint64_t m_startTime;
|
||||
uint64_t m_connectedTime;
|
||||
|
||||
std::string m_proxy;
|
||||
};
|
||||
|
||||
CurlContext::CurlContext(const std::string& address, int port, const std::string& req, const std::string& auth, const std::string& proxy, bool ssl, const std::string& ssl_fingerprint, CallbackBase* cb, CallbackBase* close_cb, uv_loop_t* loop)
|
||||
@@ -93,6 +95,7 @@ CurlContext::CurlContext(const std::string& address, int port, const std::string
|
||||
, m_headers(nullptr)
|
||||
, m_startTime(0)
|
||||
, m_connectedTime(0)
|
||||
, m_proxy(proxy)
|
||||
{
|
||||
m_pollHandles.reserve(2);
|
||||
|
||||
@@ -244,9 +247,8 @@ CurlContext::~CurlContext()
|
||||
double tcp_ping = 0.0;
|
||||
|
||||
if (m_error.empty() && !m_response.empty()) {
|
||||
if (m_connectedTime) {
|
||||
tcp_ping = static_cast<double>(m_connectedTime - m_startTime) / 1000.0;
|
||||
}
|
||||
const uint64_t t = (m_proxy.empty() && m_connectedTime) ? m_connectedTime : microseconds_since_epoch();
|
||||
tcp_ping = static_cast<double>(t - m_startTime) / 1000.0;
|
||||
(*m_callback)(m_response.data(), m_response.size(), tcp_ping);
|
||||
}
|
||||
delete m_callback;
|
||||
|
||||
Reference in New Issue
Block a user