|
|
@ -343,10 +343,11 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AddressBook::LoadHostsFromStream (std::istream& f) |
|
|
|
bool AddressBook::LoadHostsFromStream (std::istream& f) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::unique_lock<std::mutex> l(m_AddressBookMutex); |
|
|
|
std::unique_lock<std::mutex> l(m_AddressBookMutex); |
|
|
|
int numAddresses = 0; |
|
|
|
int numAddresses = 0; |
|
|
|
|
|
|
|
bool incomplete = false; |
|
|
|
std::string s; |
|
|
|
std::string s; |
|
|
|
while (!f.eof ()) |
|
|
|
while (!f.eof ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -370,15 +371,21 @@ namespace client |
|
|
|
numAddresses++; |
|
|
|
numAddresses++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
LogPrint (eLogError, "Addressbook: malformed address ", addr, " for ", name); |
|
|
|
LogPrint (eLogError, "Addressbook: malformed address ", addr, " for ", name); |
|
|
|
|
|
|
|
incomplete = f.eof (); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
incomplete = f.eof (); |
|
|
|
} |
|
|
|
} |
|
|
|
LogPrint (eLogInfo, "Addressbook: ", numAddresses, " addresses processed"); |
|
|
|
LogPrint (eLogInfo, "Addressbook: ", numAddresses, " addresses processed"); |
|
|
|
if (numAddresses > 0) |
|
|
|
if (numAddresses > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_IsLoaded = true; |
|
|
|
if (!incomplete) m_IsLoaded = true; |
|
|
|
m_Storage->Save (m_Addresses); |
|
|
|
m_Storage->Save (m_Addresses); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return !incomplete; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AddressBook::LoadSubscriptions () |
|
|
|
void AddressBook::LoadSubscriptions () |
|
|
@ -776,13 +783,12 @@ namespace client |
|
|
|
i2p::data::GzipInflator inflator; |
|
|
|
i2p::data::GzipInflator inflator; |
|
|
|
inflator.Inflate (s, uncompressed); |
|
|
|
inflator.Inflate (s, uncompressed); |
|
|
|
if (!uncompressed.fail ()) |
|
|
|
if (!uncompressed.fail ()) |
|
|
|
m_Book.LoadHostsFromStream (uncompressed); |
|
|
|
return m_Book.LoadHostsFromStream (uncompressed); |
|
|
|
else |
|
|
|
else |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
m_Book.LoadHostsFromStream (s); |
|
|
|
return m_Book.LoadHostsFromStream (s); |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AddressResolver::AddressResolver (std::shared_ptr<ClientDestination> destination): |
|
|
|
AddressResolver::AddressResolver (std::shared_ptr<ClientDestination> destination): |
|
|
|