From cb94d43092c856e3d52d09157bef2a7e272c2ceb Mon Sep 17 00:00:00 2001 From: "Francisco Blas (klondike) Izquierdo Riera" Date: Mon, 5 Jan 2015 12:36:09 +0100 Subject: [PATCH] Use the address book for conversion into .b32.i2p --- AddressBook.cpp | 2 +- AddressBook.h | 4 +++- ClientContext.cpp | 6 +++--- Destination.cpp | 4 ++-- HTTPServer.cpp | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/AddressBook.cpp b/AddressBook.cpp index 7dfa6964..f78666a0 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -240,7 +240,7 @@ namespace client m_Storage = CreateStorage (); m_Storage->AddAddress (ident); m_Addresses[address] = ident.GetIdentHash (); - LogPrint (address,"->",ident.GetIdentHash ().ToBase32 (), ".b32.i2p added"); + LogPrint (address,"->", ToAddress(ident.GetIdentHash ()), " added"); } void AddressBook::InsertAddress (const i2p::data::IdentityEx& address) diff --git a/AddressBook.h b/AddressBook.h index 47b819db..5b24c017 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -54,7 +54,9 @@ namespace client void StopSubscriptions (); void LoadHostsFromStream (std::istream& f); void DownloadComplete (bool success); - + //This method returns the ".b32.i2p" address + std::string ToAddress(const i2p::data::IdentHash& ident) { return ident.ToBase32().append(".b32.i2p"); } + std::string ToAddress(const i2p::data::IdentityEx& ident) { return ToAddress(ident.GetIdentHash ()); } private: AddressBookStorage * CreateStorage (); diff --git a/ClientContext.cpp b/ClientContext.cpp index 46bace37..b6126fcb 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -141,7 +141,7 @@ namespace client s.read ((char *)buf, len); keys.FromBuffer (buf, len); delete[] buf; - LogPrint ("Local address ", keys.GetPublic ().GetIdentHash ().ToBase32 (), ".b32.i2p loaded"); + LogPrint ("Local address ", m_AddressBook.ToAddress(keys.GetPublic ().GetIdentHash ()), " loaded"); } else { @@ -154,7 +154,7 @@ namespace client f.write ((char *)buf, len); delete[] buf; - LogPrint ("New private keys file ", fullPath, " for ", keys.GetPublic ().GetIdentHash ().ToBase32 (), ".b32.i2p created"); + LogPrint ("New private keys file ", fullPath, " for ", m_AddressBook.ToAddress(keys.GetPublic ().GetIdentHash ()), " created"); } auto localDestination = new ClientDestination (keys, isPublic); @@ -197,7 +197,7 @@ namespace client auto it = m_Destinations.find (keys.GetPublic ().GetIdentHash ()); if (it != m_Destinations.end ()) { - LogPrint ("Local destination ", keys.GetPublic ().GetIdentHash ().ToBase32 (), ".b32.i2p exists"); + LogPrint ("Local destination ", m_AddressBook.ToAddress(keys.GetPublic ().GetIdentHash ()), " exists"); if (!it->second->IsRunning ()) { it->second->Start (); diff --git a/Destination.cpp b/Destination.cpp index 2a60f673..e299a5c6 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -48,7 +48,7 @@ namespace client } m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this, inboundTunnelLen, outboundTunnelLen); if (m_IsPublic) - LogPrint (eLogInfo, "Local address ", GetIdentHash ().ToBase32 (), ".b32.i2p created"); + LogPrint (eLogInfo, "Local address ", i2p::client::context.GetAddressBook ().ToAddress(GetIdentHash()), " created"); m_StreamingDestination = new i2p::stream::StreamingDestination (*this); // TODO: } @@ -245,7 +245,7 @@ namespace client delete it1->second; m_LeaseSetRequests.erase (it1); } - } + } void ClientDestination::HandleDatabaseSearchReplyMessage (const uint8_t * buf, size_t len) { diff --git a/HTTPServer.cpp b/HTTPServer.cpp index f2679817..9da6f206 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -792,7 +792,7 @@ namespace util std::string b32 = it.first.ToBase32 (); s << ""; - s << b32 << ".b32.i2p
" << std::endl; + s << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetIdentHash()) << "
" << std::endl; } } @@ -832,7 +832,7 @@ namespace util s << "
Streams:
"; for (auto it: dest->GetStreamingDestination ()->GetStreams ()) { - s << it.first << "->" << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase32 () << ".b32.i2p "; + s << it.first << "->" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetRemoteIdentity ()) << " "; s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; s << " [out:" << it.second->GetSendQueueSize () << "][in:" << it.second->GetReceiveQueueSize () << "]"; s << "
"<< std::endl;