| 2124 | } |
| 2125 | |
| 2126 | void NTCP2Server::ConnectWithProxy (std::shared_ptr<NTCP2Session> conn) |
| 2127 | { |
| 2128 | if(!m_ProxyEndpoint) return; |
| 2129 | if (!conn || conn->GetRemoteEndpoint ().address ().is_unspecified ()) |
| 2130 | { |
| 2131 | LogPrint (eLogError, "NTCP2: Can't connect to unspecified address"); |
| 2132 | return; |
| 2133 | } |
| 2134 | boost::asio::post (GetService(), [this, conn]() |
| 2135 | { |
| 2136 | if (this->AddNTCP2Session (conn)) |
| 2137 | { |
| 2138 | auto timer = std::make_shared<boost::asio::steady_timer>(GetService()); |
| 2139 | auto timeout = NTCP2_CONNECT_TIMEOUT * 5; |
| 2140 | conn->SetTerminationTimeout(timeout * 2); |
| 2141 | timer->expires_after (std::chrono::seconds(timeout)); |
| 2142 | timer->async_wait ([conn, timeout](const boost::system::error_code& ecode) |
| 2143 | { |
| 2144 | if (ecode != boost::asio::error::operation_aborted) |
| 2145 | { |
| 2146 | LogPrint (eLogInfo, "NTCP2: Not connected in ", timeout, " seconds"); |
| 2147 | conn->Terminate (); |
| 2148 | } |
| 2149 | }); |
| 2150 | conn->GetSocket ().async_connect (*m_ProxyEndpoint, std::bind (&NTCP2Server::HandleProxyConnect, this, std::placeholders::_1, conn, timer)); |
| 2151 | } |
| 2152 | }); |
| 2153 | } |
| 2154 | |
| 2155 | void NTCP2Server::UseProxy(ProxyType proxytype, const std::string& addr, uint16_t port, |
| 2156 | const std::string& user, const std::string& pass) |
no test coverage detected