Browse Source

Add *.b32.i2p address detection

pull/66/head
chertov 11 years ago
parent
commit
fd08dc72bd
  1. 43
      HTTPServer.cpp

43
HTTPServer.cpp

@ -311,28 +311,41 @@ namespace util
{ {
i2p::data::IdentHash destination; i2p::data::IdentHash destination;
std::string fullAddress; std::string fullAddress;
if (address.find (".i2p") != std::string::npos) if (address.find(".b32.i2p") != std::string::npos)
{ {
auto addr = i2p::data::netdb.FindAddress(address); if (i2p::data::Base32ToByteStream(address.c_str(), address.length() - strlen(".b32.i2p"), (uint8_t *)destination, 32) != 32)
if (!addr)
{ {
LogPrint ("Unknown address ", address); LogPrint ("Invalid Base32 address ", address);
SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>"); SendReply ("<html>" + itoopieImage + "<br>Invalid Base32 address");
return; return;
} }
destination = *addr;
fullAddress = address; fullAddress = address;
} }
else else
{ {
if (i2p::data::Base32ToByteStream (address.c_str (), address.length (), (uint8_t *)destination, 32) != 32) if (address.find(".i2p") != std::string::npos)
{ {
LogPrint ("Invalid Base32 address ", address); auto addr = i2p::data::netdb.FindAddress(address);
SendReply ("<html>" + itoopieImage + "<br>Invalid Base32 address"); if (!addr)
return; {
LogPrint ("Unknown address ", address);
SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>");
return;
}
destination = *addr;
fullAddress = address;
} }
fullAddress = address + ".b32.i2p"; else
} {
if (i2p::data::Base32ToByteStream(address.c_str(), address.length(), (uint8_t *)destination, 32) != 32)
{
LogPrint("Invalid Base32 address ", address);
SendReply("<html>" + itoopieImage + "<br>Invalid Base32 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 ())

Loading…
Cancel
Save