1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 04:04:16 +00:00

jump service

This commit is contained in:
orignal 2014-09-23 15:38:56 -04:00
parent f30a466bec
commit e51cca8263
4 changed files with 24 additions and 0 deletions

View File

@ -32,6 +32,14 @@ namespace data
return nullptr; return nullptr;
} }
void AddressBook::InsertAddress (const std::string& address, const std::string& base64)
{
IdentityEx ident;
ident.FromBase64 (base64);
m_Addresses[address] = ident.GetIdentHash ();
LogPrint (address,"->",ident.GetIdentHash ().ToBase32 (), ".b32.i2p added");
}
void AddressBook::LoadHostsFromI2P () void AddressBook::LoadHostsFromI2P ()
{ {
std::string content; std::string content;

View File

@ -19,6 +19,7 @@ namespace data
AddressBook (); AddressBook ();
const IdentHash * FindAddress (const std::string& address); const IdentHash * FindAddress (const std::string& address);
void InsertAddress (const std::string& address, const std::string& base64); // for jump service
private: private:

View File

@ -1,6 +1,7 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include "NetDb.h"
#include "HTTPProxy.h" #include "HTTPProxy.h"
namespace i2p namespace i2p
@ -63,6 +64,19 @@ namespace proxy
request r; request r;
ExtractRequest(r); ExtractRequest(r);
parseHeaders(m_Buffer, r.headers); parseHeaders(m_Buffer, r.headers);
size_t addressHelperPos = r.uri.find ("i2paddresshelper");
if (addressHelperPos != std::string::npos)
{
// jump service
size_t addressPos = r.uri.find ("=", addressHelperPos);
if (addressPos != std::string::npos)
{
LogPrint ("Jump service for ", r.host, " found. Inserting to address book");
auto base64 = r.uri.substr (addressPos + 1);
i2p::data::netdb.InsertAddress (r.host, base64);
}
}
LogPrint("Requesting ", r.host, " with path ", r.uri, " and method ", r.method); LogPrint("Requesting ", r.host, " with path ", r.uri, " and method ", r.method);
SendToAddress (r.host, m_Buffer, m_BufferLen); SendToAddress (r.host, m_Buffer, m_BufferLen);
} }

View File

@ -67,6 +67,7 @@ namespace data
RouterInfo * FindRouter (const IdentHash& ident) const; RouterInfo * FindRouter (const IdentHash& ident) const;
LeaseSet * FindLeaseSet (const IdentHash& destination) const; LeaseSet * FindLeaseSet (const IdentHash& destination) const;
const IdentHash * FindAddress (const std::string& address) { return m_AddressBook.FindAddress (address); }; // TODO: move AddressBook away from NetDb const IdentHash * FindAddress (const std::string& address) { return m_AddressBook.FindAddress (address); }; // TODO: move AddressBook away from NetDb
void InsertAddress (const std::string& address, const std::string& base64) { m_AddressBook.InsertAddress (address, base64); };
void Subscribe (const IdentHash& ident, i2p::tunnel::TunnelPool * pool = nullptr); // keep LeaseSets upto date void Subscribe (const IdentHash& ident, i2p::tunnel::TunnelPool * pool = nullptr); // keep LeaseSets upto date
void Unsubscribe (const IdentHash& ident); void Unsubscribe (const IdentHash& ident);