mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-18 00:09:58 +00:00
handle .i2p addresses
This commit is contained in:
parent
c9ba7da0b0
commit
6066b7073f
@ -197,14 +197,31 @@ namespace util
|
|||||||
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq\">Flibusta</a></p>";
|
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq\">Flibusta</a></p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPConnection::HandleDestinationRequest (const std::string& b32, const std::string& uri)
|
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri)
|
||||||
{
|
{
|
||||||
uint8_t destination[32];
|
i2p::data::IdentHash destination;
|
||||||
if (i2p::data::Base32ToByteStream (b32.c_str (), b32.length (), destination, 32) != 32)
|
std::string fullAddress;
|
||||||
{
|
if (address.find (".i2p") != std::string::npos)
|
||||||
LogPrint ("Invalid Base32 address ", b32);
|
{
|
||||||
return;
|
auto addr = i2p::data::netdb.FindAddress(address);
|
||||||
|
if (!addr)
|
||||||
|
{
|
||||||
|
LogPrint ("Unknown address ", address);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
destination = *addr;
|
||||||
|
fullAddress = address;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i2p::data::Base32ToByteStream (address.c_str (), address.length (), (uint8_t *)destination, 32) != 32)
|
||||||
|
{
|
||||||
|
LogPrint ("Invalid Base32 address ", address);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fullAddress = address + ".b32.i2p";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
auto leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
||||||
if (!leaseSet || !leaseSet->HasNonExpiredLeases ())
|
if (!leaseSet || !leaseSet->HasNonExpiredLeases ())
|
||||||
{
|
{
|
||||||
@ -225,7 +242,7 @@ namespace util
|
|||||||
auto s = i2p::stream::CreateStream (*leaseSet);
|
auto s = i2p::stream::CreateStream (*leaseSet);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
std::string request = "GET " + uri + " HTTP/1.1\n Host:" + b32 + ".b32.i2p\n";
|
std::string request = "GET " + uri + " HTTP/1.1\n Host:" + fullAddress + "\n";
|
||||||
s->Send ((uint8_t *)request.c_str (), request.length (), 10);
|
s->Send ((uint8_t *)request.c_str (), request.length (), 10);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
uint8_t buf[8192];
|
uint8_t buf[8192];
|
||||||
|
@ -48,7 +48,7 @@ namespace util
|
|||||||
void HandleWrite(const boost::system::error_code& ecode);
|
void HandleWrite(const boost::system::error_code& ecode);
|
||||||
|
|
||||||
void HandleRequest ();
|
void HandleRequest ();
|
||||||
void HandleDestinationRequest (const std::string& b32, const std::string& uri);
|
void HandleDestinationRequest (const std::string& address, const std::string& uri);
|
||||||
void FillContent (std::stringstream& s);
|
void FillContent (std::stringstream& s);
|
||||||
std::string ExtractAddress ();
|
std::string ExtractAddress ();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user