Browse Source

replace Host: for server http tunnels

pull/197/head
orignal 10 years ago
parent
commit
09fd0baf78
  1. 28
      I2PTunnel.cpp
  2. 3
      I2PTunnel.h

28
I2PTunnel.cpp

@ -165,7 +165,7 @@ namespace client @@ -165,7 +165,7 @@ namespace client
I2PTunnelConnectionHTTP::I2PTunnelConnectionHTTP (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
std::shared_ptr<boost::asio::ip::tcp::socket> socket,
const boost::asio::ip::tcp::endpoint& target, const std::string& host):
I2PTunnelConnection (owner, stream, socket, target), m_HeaderSent (false)
I2PTunnelConnection (owner, stream, socket, target), m_Host (host), m_HeaderSent (false)
{
}
@ -175,9 +175,31 @@ namespace client @@ -175,9 +175,31 @@ namespace client
I2PTunnelConnection::Write (buf, len);
else
{
m_Header.write ((const char *)buf, len);
I2PTunnelConnection::Write ((uint8_t *)m_Header.str ().c_str (), m_Header.str ().length ());
m_InHeader.clear ();
m_InHeader.write ((const char *)buf, len);
std::string line;
bool endOfHeader = false;
while (!endOfHeader)
{
std::getline(m_InHeader, line);
if (!m_InHeader.fail ())
{
if (line.find ("Host:") != std::string::npos)
m_OutHeader << "Host: " << m_Host << "\r\n";
else
m_OutHeader << line << "\n";
if (line == "\r") endOfHeader = true;
}
else
break;
}
if (endOfHeader)
{
m_OutHeader << m_InHeader.str (); // data right after header
m_HeaderSent = true;
I2PTunnelConnection::Write ((uint8_t *)m_OutHeader.str ().c_str (), m_OutHeader.str ().length ());
}
}
}

3
I2PTunnel.h

@ -71,7 +71,8 @@ namespace client @@ -71,7 +71,8 @@ namespace client
private:
std::stringstream m_Header;
std::string m_Host;
std::stringstream m_InHeader, m_OutHeader;
bool m_HeaderSent;
};

Loading…
Cancel
Save