mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
NTCP2 proxy with authorization
This commit is contained in:
parent
744b25190a
commit
880d1a7ccd
@ -1465,11 +1465,14 @@ namespace transport
|
||||
});
|
||||
}
|
||||
|
||||
void NTCP2Server::UseProxy(ProxyType proxytype, const std::string & addr, uint16_t port)
|
||||
void NTCP2Server::UseProxy(ProxyType proxytype, const std::string& addr, uint16_t port,
|
||||
const std::string& user, const std::string& pass)
|
||||
{
|
||||
m_ProxyType = proxytype;
|
||||
m_ProxyAddress = addr;
|
||||
m_ProxyPort = port;
|
||||
if ((!user.empty () || !pass.empty ()) && m_ProxyType == eHTTPProxy )
|
||||
m_ProxyAuthorization = "Basic " + i2p::data::ToBase64Standard (user + ":" + pass);
|
||||
}
|
||||
|
||||
void NTCP2Server::HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr<NTCP2Session> conn, std::shared_ptr<boost::asio::deadline_timer> timer)
|
||||
@ -1538,8 +1541,10 @@ namespace transport
|
||||
if(ep.address ().is_v6 ())
|
||||
req.uri = "[" + ep.address ().to_string() + "]:" + std::to_string(ep.port ());
|
||||
else
|
||||
req.uri = ep.address ().to_string() + ":" + std::to_string(ep.port ());
|
||||
|
||||
req.uri = ep.address ().to_string() + ":" + std::to_string(ep.port ());
|
||||
if (!m_ProxyAuthorization.empty ())
|
||||
req.AddHeader("Proxy-Authorization", m_ProxyAuthorization);
|
||||
|
||||
boost::asio::streambuf writebuff;
|
||||
std::ostream out(&writebuff);
|
||||
out << req.to_string();
|
||||
|
@ -246,7 +246,7 @@ namespace transport
|
||||
void Connect(std::shared_ptr<NTCP2Session> conn);
|
||||
|
||||
bool UsingProxy() const { return m_ProxyType != eNoProxy; };
|
||||
void UseProxy(ProxyType proxy, const std::string & address, uint16_t port);
|
||||
void UseProxy(ProxyType proxy, const std::string& address, uint16_t port, const std::string& user, const std::string& pass);
|
||||
|
||||
void SetLocalAddress (const boost::asio::ip::address& localAddress);
|
||||
|
||||
@ -271,7 +271,7 @@ namespace transport
|
||||
std::list<std::shared_ptr<NTCP2Session> > m_PendingIncomingSessions;
|
||||
|
||||
ProxyType m_ProxyType;
|
||||
std::string m_ProxyAddress;
|
||||
std::string m_ProxyAddress, m_ProxyAuthorization;
|
||||
uint16_t m_ProxyPort;
|
||||
boost::asio::ip::tcp::resolver m_Resolver;
|
||||
std::unique_ptr<boost::asio::ip::tcp::endpoint> m_ProxyEndpoint;
|
||||
|
@ -188,7 +188,7 @@ namespace transport
|
||||
if (proxyurl.schema == "http")
|
||||
proxytype = NTCP2Server::eHTTPProxy;
|
||||
|
||||
m_NTCP2Server->UseProxy(proxytype, proxyurl.host, proxyurl.port);
|
||||
m_NTCP2Server->UseProxy(proxytype, proxyurl.host, proxyurl.port, proxyurl.user, proxyurl.pass);
|
||||
i2p::context.SetStatus (eRouterStatusProxy);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user