|
|
@ -389,11 +389,19 @@ namespace proxy { |
|
|
|
m_ClientRequestURL.host = ""; |
|
|
|
m_ClientRequestURL.host = ""; |
|
|
|
m_ClientRequest.uri = m_ClientRequestURL.to_string(); |
|
|
|
m_ClientRequest.uri = m_ClientRequestURL.to_string(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_ProxyURL.schema == "http" && (!m_ProxyURL.user.empty () || !m_ProxyURL.pass.empty ())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// http proxy authorization
|
|
|
|
|
|
|
|
std::string s = "basic " + i2p::data::ToBase64Standard (m_ProxyURL.user + ":" + m_ProxyURL.pass); |
|
|
|
|
|
|
|
m_ClientRequest.AddHeader("Proxy-Authorization", s); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ClientRequest.write(m_ClientRequestBuffer); |
|
|
|
m_ClientRequest.write(m_ClientRequestBuffer); |
|
|
|
m_ClientRequestBuffer << m_recv_buf.substr(m_req_len); |
|
|
|
m_ClientRequestBuffer << m_recv_buf.substr(m_req_len); |
|
|
|
|
|
|
|
|
|
|
|
// assume http if empty schema
|
|
|
|
// assume http if empty schema
|
|
|
|
if (m_ProxyURL.schema == "" || m_ProxyURL.schema == "http") { |
|
|
|
if (m_ProxyURL.schema == "" || m_ProxyURL.schema == "http") |
|
|
|
|
|
|
|
{ |
|
|
|
// handle upstream http proxy
|
|
|
|
// handle upstream http proxy
|
|
|
|
if (!m_ProxyURL.port) m_ProxyURL.port = 80; |
|
|
|
if (!m_ProxyURL.port) m_ProxyURL.port = 80; |
|
|
|
if (m_ProxyURL.is_i2p()) |
|
|
|
if (m_ProxyURL.is_i2p()) |
|
|
@ -409,14 +417,18 @@ namespace proxy { |
|
|
|
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamHTTPProxyConnect, this, std::placeholders::_1)); |
|
|
|
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamHTTPProxyConnect, this, std::placeholders::_1)); |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (m_ProxyURL.schema == "socks") { |
|
|
|
} |
|
|
|
|
|
|
|
else if (m_ProxyURL.schema == "socks") |
|
|
|
|
|
|
|
{ |
|
|
|
// handle upstream socks proxy
|
|
|
|
// handle upstream socks proxy
|
|
|
|
if (!m_ProxyURL.port) m_ProxyURL.port = 9050; // default to tor default if not specified
|
|
|
|
if (!m_ProxyURL.port) m_ProxyURL.port = 9050; // default to tor default if not specified
|
|
|
|
boost::asio::ip::tcp::resolver::query q(m_ProxyURL.host, std::to_string(m_ProxyURL.port)); |
|
|
|
boost::asio::ip::tcp::resolver::query q(m_ProxyURL.host, std::to_string(m_ProxyURL.port)); |
|
|
|
m_proxy_resolver.async_resolve(q, std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this, std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep) { |
|
|
|
m_proxy_resolver.async_resolve(q, std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this, std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep) { |
|
|
|
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamSocksProxyConnect, this, std::placeholders::_1)); |
|
|
|
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamSocksProxyConnect, this, std::placeholders::_1)); |
|
|
|
})); |
|
|
|
})); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
// unknown type, complain
|
|
|
|
// unknown type, complain
|
|
|
|
GenericProxyError("unknown outproxy url", m_ProxyURL.to_string().c_str()); |
|
|
|
GenericProxyError("unknown outproxy url", m_ProxyURL.to_string().c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|