mirror of https://github.com/PurpleI2P/i2pd
commit
85884a5b84
@ -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
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,113 @@
|
||||
cmake_minimum_required ( VERSION 2.8 )
|
||||
project ( i2pd )
|
||||
|
||||
# Default build is Debug
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
|
||||
|
||||
set ( SRC_DIR ".." )
|
||||
set ( INC_DIR ".." )
|
||||
|
||||
|
||||
add_definitions ( "-std=c++0x -Wall" )
|
||||
|
||||
set ( SOURCES
|
||||
AddressBook.cpp
|
||||
Garlic.cpp
|
||||
HTTPServer.cpp
|
||||
i2p.cpp
|
||||
Identity.cpp
|
||||
Log.cpp
|
||||
NTCPSession.cpp
|
||||
RouterContext.cpp
|
||||
SSU.cpp
|
||||
TransitTunnel.cpp
|
||||
Tunnel.cpp
|
||||
TunnelGateway.cpp
|
||||
UPnP.cpp
|
||||
base64.cpp
|
||||
HTTPProxy.cpp
|
||||
I2NPProtocol.cpp
|
||||
LeaseSet.cpp
|
||||
NetDb.cpp
|
||||
Reseed.cpp
|
||||
RouterInfo.cpp
|
||||
Streaming.cpp
|
||||
Transports.cpp
|
||||
TunnelEndpoint.cpp
|
||||
TunnelPool.cpp
|
||||
util.cpp
|
||||
)
|
||||
|
||||
set ( HEADERS
|
||||
AddressBook.h
|
||||
Garlic.h
|
||||
HTTPServer.h
|
||||
Identity.h
|
||||
Log.h
|
||||
NTCPSession.h
|
||||
RouterContext.h
|
||||
SSU.h
|
||||
TransitTunnel.h
|
||||
Tunnel.h
|
||||
TunnelGateway.h
|
||||
UPnP.h
|
||||
base64.h
|
||||
HTTPProxy.h
|
||||
I2NPProtocol.h
|
||||
LeaseSet.h
|
||||
NetDb.h
|
||||
Reseed.h
|
||||
RouterInfo.h
|
||||
Streaming.h
|
||||
Transports.h
|
||||
TunnelEndpoint.h
|
||||
TunnelPool.h
|
||||
util.h
|
||||
)
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
|
||||
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
|
||||
|
||||
find_package ( Threads REQUIRED )
|
||||
|
||||
find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED )
|
||||
|
||||
find_package ( CryptoPP REQUIRED )
|
||||
|
||||
# Check for libraries
|
||||
if(NOT DEFINED Boost_INCLUDE_DIRS)
|
||||
message(FATAL_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CRYPTO++_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Could not find Crypto++. Please download and install it first!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
# End checks
|
||||
|
||||
|
||||
include_directories ( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR})
|
||||
|
||||
|
||||
unset ( TMP )
|
||||
foreach ( src ${SOURCES} )
|
||||
list ( APPEND TMP "${SRC_DIR}/${src}" )
|
||||
endforeach ()
|
||||
set ( SOURCES ${TMP} )
|
||||
|
||||
unset ( TMP )
|
||||
foreach ( hdr ${HEADERS} )
|
||||
list ( APPEND TMP "${INC_DIR}/${hdr}" )
|
||||
endforeach ()
|
||||
set ( HEADERS ${TMP} )
|
||||
|
||||
|
||||
add_executable ( ${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCES} )
|
||||
|
||||
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
|
@ -0,0 +1,35 @@
|
||||
# - Find Crypto++
|
||||
|
||||
if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||
set(CRYPTO++_FOUND TRUE)
|
||||
|
||||
else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||
find_path(CRYPTO++_INCLUDE_DIR cryptlib.h
|
||||
/usr/include/crypto++
|
||||
/usr/include/cryptopp
|
||||
/usr/local/include/crypto++
|
||||
/usr/local/include/cryptopp
|
||||
/opt/local/include/crypto++
|
||||
/opt/local/include/cryptopp
|
||||
$ENV{SystemDrive}/Crypto++/include
|
||||
)
|
||||
|
||||
find_library(CRYPTO++_LIBRARIES NAMES cryptopp
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
$ENV{SystemDrive}/Crypto++/lib
|
||||
)
|
||||
|
||||
if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||
set(CRYPTO++_FOUND TRUE)
|
||||
message(STATUS "Found Crypto++: ${CRYPTO++_INCLUDE_DIR}, ${CRYPTO++_LIBRARIES}")
|
||||
else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||
set(CRYPTO++_FOUND FALSE)
|
||||
message(STATUS "Crypto++ not found.")
|
||||
endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||
|
||||
mark_as_advanced(CRYPTO++_INCLUDE_DIR CRYPTO++_LIBRARIES)
|
||||
|
||||
endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
Loading…
Reference in New Issue