Browse Source

Merge pull request #381 from PurpleI2P/openssl

recent changes
pull/394/head
orignal 9 years ago
parent
commit
01a8c507e5
  1. 50
      AddressBook.cpp
  2. 2
      AddressBook.h
  3. 8
      NetDb.cpp
  4. 7
      docs/build_notes_unix.md

50
AddressBook.cpp

@ -229,11 +229,7 @@ namespace client @@ -229,11 +229,7 @@ namespace client
delete m_Storage;
m_Storage = nullptr;
}
if (m_DefaultSubscription)
{
delete m_DefaultSubscription;
m_DefaultSubscription = nullptr;
}
m_DefaultSubscription = nullptr;
for (auto it: m_Subscriptions)
delete it;
m_Subscriptions.clear ();
@ -327,19 +323,6 @@ namespace client @@ -327,19 +323,6 @@ namespace client
LoadHostsFromStream (f);
m_IsLoaded = true;
}
else
{
// if not found download it from http://i2p-projekt.i2p/hosts.txt
LogPrint (eLogInfo, "Addressbook: hosts.txt not found, trying to download it from default subscription.");
if (!m_IsDownloading)
{
m_IsDownloading = true;
if (!m_DefaultSubscription)
m_DefaultSubscription = new AddressBookSubscription (*this, DEFAULT_SUBSCRIPTION_ADDRESS);
m_DefaultSubscription->CheckSubscription ();
}
}
}
void AddressBook::LoadHostsFromStream (std::istream& f)
@ -406,6 +389,11 @@ namespace client @@ -406,6 +389,11 @@ namespace client
void AddressBook::DownloadComplete (bool success)
{
m_IsDownloading = false;
if (success && m_DefaultSubscription)
{
m_DefaultSubscription.reset (nullptr);
m_IsLoaded = true;
}
if (m_SubscriptionsUpdateTimer)
{
m_SubscriptionsUpdateTimer->expires_from_now (boost::posix_time::minutes(
@ -418,8 +406,8 @@ namespace client @@ -418,8 +406,8 @@ namespace client
void AddressBook::StartSubscriptions ()
{
LoadSubscriptions ();
if (!m_Subscriptions.size ()) return;
if (m_IsLoaded && m_Subscriptions.empty ()) return;
auto dest = i2p::client::context.GetSharedLocalDestination ();
if (dest)
{
@ -444,12 +432,24 @@ namespace client @@ -444,12 +432,24 @@ namespace client
{
auto dest = i2p::client::context.GetSharedLocalDestination ();
if (!dest) return;
if (m_IsLoaded && !m_IsDownloading && dest->IsReady () && !m_Subscriptions.empty ())
if (!m_IsDownloading && dest->IsReady ())
{
// pick random subscription
auto ind = rand () % m_Subscriptions.size();
m_IsDownloading = true;
m_Subscriptions[ind]->CheckSubscription ();
if (!m_IsLoaded)
{
// download it from http://i2p-projekt.i2p/hosts.txt
LogPrint (eLogInfo, "Addressbook: trying to download it from default subscription.");
if (!m_DefaultSubscription)
m_DefaultSubscription.reset (new AddressBookSubscription (*this, DEFAULT_SUBSCRIPTION_ADDRESS));
m_IsDownloading = true;
m_DefaultSubscription->CheckSubscription ();
}
else if (!m_Subscriptions.empty ())
{
// pick random subscription
auto ind = rand () % m_Subscriptions.size();
m_IsDownloading = true;
m_Subscriptions[ind]->CheckSubscription ();
}
}
else
{

2
AddressBook.h

@ -78,7 +78,7 @@ namespace client @@ -78,7 +78,7 @@ namespace client
AddressBookStorage * m_Storage;
volatile bool m_IsLoaded, m_IsDownloading;
std::vector<AddressBookSubscription *> m_Subscriptions;
AddressBookSubscription * m_DefaultSubscription; // in case if we don't know any addresses yet
std::unique_ptr<AddressBookSubscription> m_DefaultSubscription; // in case if we don't know any addresses yet
boost::asio::deadline_timer * m_SubscriptionsUpdateTimer;
};

8
NetDb.cpp

@ -375,6 +375,14 @@ namespace data @@ -375,6 +375,14 @@ namespace data
total--;
}
}
else if (total > 2500)
{
if (ts > it.second->GetTimestamp () + 12*3600*1000LL) // 12 hours
{
it.second->SetUnreachable (true);
total--;
}
}
else if (total > 300)
{
if (ts > it.second->GetTimestamp () + 30*3600*1000LL) // 30 hours

7
docs/build_notes_unix.md

@ -23,6 +23,13 @@ After successfull build i2pd could be installed with: @@ -23,6 +23,13 @@ After successfull build i2pd could be installed with:
```bash
make install
```
or you can just use 'make' once you have all dependacies (boost and openssl) installed
```bash
git clone https://github.com/PurpleI2P/i2pd.git
cd i2pd
make
```
Debian/Ubuntu
-------------

Loading…
Cancel
Save