-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from orignal/master
Merge pull request from orignal/master
- Loading branch information
Showing
26 changed files
with
547 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: cpp | ||
compiler: gcc | ||
cache: apt | ||
branches: | ||
only: | ||
- master | ||
before_install: | ||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test # GCC 4.7 | ||
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ quantal main universe" # Boost 1.50 | ||
- sudo apt-get update -qq | ||
- sudo apt-get install -qq libboost1.50-all-dev libcrypto++9 libcrypto++-dev | ||
script: | ||
- make | ||
notifications: | ||
email: | ||
recipients: | ||
- meeh@sigterm.no | ||
on_success: change | ||
on_failure: always | ||
irc: | ||
channels: | ||
- "irc.freenode.net#i2p-dev" | ||
template: | ||
- "%{repository}/%{branch} (%{commit} - %{author}): %{message}" | ||
on_failure: always | ||
on_success: change | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <string.h> | ||
#include <string> | ||
#include <map> | ||
#include "base64.h" | ||
#include "util.h" | ||
#include "Identity.h" | ||
#include "Log.h" | ||
#include "AddressBook.h" | ||
|
||
namespace i2p | ||
{ | ||
namespace data | ||
{ | ||
|
||
AddressBook::AddressBook (): m_IsLoaded (false) | ||
{ | ||
} | ||
|
||
|
||
const IdentHash * AddressBook::FindAddress (const std::string& address) | ||
{ | ||
if (!m_IsLoaded) | ||
LoadHosts (); | ||
auto it = m_Addresses.find (address); | ||
if (it != m_Addresses.end ()) | ||
return &it->second; | ||
else | ||
return nullptr; | ||
} | ||
|
||
|
||
void AddressBook::LoadHosts () | ||
{ | ||
m_IsLoaded = true; | ||
std::ifstream f (i2p::util::filesystem::GetFullPath ("hosts.txt").c_str (), std::ofstream::in); // in text mode | ||
if (!f.is_open ()) | ||
{ | ||
LogPrint ("hosts.txt not found"); | ||
return; | ||
} | ||
int numAddresses = 0; | ||
|
||
std::string s; | ||
|
||
while (!f.eof ()) | ||
{ | ||
getline(f, s); | ||
|
||
if (!s.length()) | ||
break; | ||
|
||
size_t pos = s.find('='); | ||
|
||
if (pos != std::string::npos) | ||
{ | ||
std::string name = s.substr(0, pos++); | ||
std::string addr = s.substr(pos); | ||
|
||
Identity ident; | ||
Base64ToByteStream (addr.c_str(), addr.length(), (uint8_t *)&ident, sizeof (ident)); | ||
m_Addresses[name] = CalculateIdentHash (ident); | ||
numAddresses++; | ||
} | ||
} | ||
LogPrint (numAddresses, " addresses loaded"); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.