mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-13 02:57:54 +00:00
process b32 address with path
This commit is contained in:
parent
10c7e05ff4
commit
f5fa953458
@ -60,9 +60,20 @@ namespace util
|
||||
{
|
||||
m_Buffer[bytes_transferred] = 0;
|
||||
auto address = ExtractAddress ();
|
||||
//LogPrint (address);
|
||||
if (address.length () > 1) // not just '/'
|
||||
HandleDestinationRequest (address.substr (1)); // exclude '/'
|
||||
{
|
||||
std::string uri ("/"), b32;
|
||||
size_t pos = address.find ('/', 1);
|
||||
if (pos == std::string::npos)
|
||||
b32 = address.substr (1); // excluding leading '/' to end of line
|
||||
else
|
||||
{
|
||||
b32 = address.substr (1, pos - 1); // excluding leading '/' to next '/'
|
||||
uri = address.substr (pos); // rest of line
|
||||
}
|
||||
|
||||
HandleDestinationRequest (b32, uri);
|
||||
}
|
||||
else
|
||||
HandleRequest ();
|
||||
boost::asio::async_write (*m_Socket, m_Reply.to_buffers(),
|
||||
@ -149,10 +160,14 @@ namespace util
|
||||
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq\">Flibusta</a></p>";
|
||||
}
|
||||
|
||||
void HTTPConnection::HandleDestinationRequest (std::string b32)
|
||||
void HTTPConnection::HandleDestinationRequest (const std::string& b32, const std::string& uri)
|
||||
{
|
||||
uint8_t destination[32];
|
||||
i2p::data::Base32ToByteStream (b32.c_str (), b32.length (), destination, 32);
|
||||
if (i2p::data::Base32ToByteStream (b32.c_str (), b32.length (), destination, 32) != 32)
|
||||
{
|
||||
LogPrint ("Invalid Base32 address ", b32);
|
||||
return;
|
||||
}
|
||||
auto leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
||||
if (!leaseSet || !leaseSet->HasNonExpiredLeases ())
|
||||
{
|
||||
@ -173,7 +188,7 @@ namespace util
|
||||
auto s = i2p::stream::CreateStream (leaseSet);
|
||||
if (s)
|
||||
{
|
||||
std::string request = "GET / HTTP/1.1\n Host:" + b32 + ".b32.i2p\n";
|
||||
std::string request = "GET " + uri + " HTTP/1.1\n Host:" + b32 + ".b32.i2p\n";
|
||||
s->Send ((uint8_t *)request.c_str (), request.length (), 10);
|
||||
std::stringstream ss;
|
||||
uint8_t buf[8192];
|
||||
@ -193,7 +208,7 @@ namespace util
|
||||
else // nothing received
|
||||
ss << "<html>Not responding</html>";
|
||||
s->Close ();
|
||||
//DeleteStream (s);
|
||||
DeleteStream (s);
|
||||
|
||||
m_Reply.content = ss.str ();
|
||||
m_Reply.headers.resize(2);
|
||||
|
@ -48,7 +48,7 @@ namespace util
|
||||
void HandleWrite(const boost::system::error_code& ecode);
|
||||
|
||||
void HandleRequest ();
|
||||
void HandleDestinationRequest (std::string b32);
|
||||
void HandleDestinationRequest (const std::string& b32, const std::string& uri);
|
||||
void FillContent (std::stringstream& s);
|
||||
std::string ExtractAddress ();
|
||||
|
||||
|
@ -318,7 +318,7 @@ namespace stream
|
||||
|
||||
void StreamingDestination::HandleNextPacket (Packet * packet)
|
||||
{
|
||||
uint32_t sendStreamID = be32toh (*(uint32_t *)(packet->buf));
|
||||
uint32_t sendStreamID = packet->GetSendStreamID ();
|
||||
auto it = m_Streams.find (sendStreamID);
|
||||
if (it != m_Streams.end ())
|
||||
it->second->HandleNextPacket (packet);
|
||||
|
Loading…
Reference in New Issue
Block a user