mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
parse address in AddressBook
This commit is contained in:
parent
ec3462fabe
commit
07654212f8
6 changed files with 37 additions and 50 deletions
|
@ -829,34 +829,12 @@ namespace util
|
|||
void HTTPConnection::SendToAddress (const std::string& address, const char * buf, size_t len)
|
||||
{
|
||||
i2p::data::IdentHash destination;
|
||||
if (address.find(".b32.i2p") != std::string::npos)
|
||||
if (!i2p::data::netdb.GetAddressBook ().GetIdentHash (address, destination))
|
||||
{
|
||||
if (i2p::data::Base32ToByteStream(address.c_str(), address.length() - strlen(".b32.i2p"), (uint8_t *)destination, 32) != 32)
|
||||
{
|
||||
LogPrint ("Invalid Base32 address ", address);
|
||||
SendReply ("<html>" + itoopieImage + "<br>Invalid Base32 address</html>", 400);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (address.find(".i2p") != std::string::npos)
|
||||
{
|
||||
auto addr = i2p::data::netdb.FindAddress(address);
|
||||
if (!addr)
|
||||
{
|
||||
LogPrint ("Unknown address ", address);
|
||||
SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>", 404);
|
||||
return;
|
||||
}
|
||||
destination = *addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendReply ("<html>Unexpected address " + address + "</html>", 404);
|
||||
return;
|
||||
}
|
||||
}
|
||||
LogPrint ("Unknown address ", address);
|
||||
SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>", 404);
|
||||
return;
|
||||
}
|
||||
|
||||
SendToDestination (destination, buf, len);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue