mirror of https://github.com/PurpleI2P/i2pd.git
orignal
8 years ago
committed by
GitHub
76 changed files with 1492 additions and 768 deletions
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
#include "Event.h" |
||||
#include "Log.h" |
||||
|
||||
namespace i2p |
||||
{ |
||||
namespace event |
||||
{ |
||||
#ifdef WITH_EVENTS |
||||
EventCore core; |
||||
#endif |
||||
|
||||
void EventCore::SetListener(EventListener * l) |
||||
{ |
||||
m_listener = l; |
||||
LogPrint(eLogInfo, "Event: listener set"); |
||||
} |
||||
|
||||
void EventCore::QueueEvent(const EventType & ev) |
||||
{ |
||||
if(m_listener) |
||||
m_listener->HandleEvent(ev); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void EmitEvent(const EventType & e) |
||||
{ |
||||
#ifdef WITH_EVENTS |
||||
i2p::event::core.QueueEvent(e); |
||||
#endif |
||||
} |
||||
|
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
#ifndef EVENT_H__ |
||||
#define EVENT_H__ |
||||
#include <map> |
||||
#include <string> |
||||
#include <memory> |
||||
|
||||
#include <boost/asio.hpp> |
||||
|
||||
typedef std::map<std::string, std::string> EventType; |
||||
|
||||
namespace i2p |
||||
{ |
||||
namespace event |
||||
{ |
||||
class EventListener { |
||||
public: |
||||
virtual ~EventListener() {}; |
||||
virtual void HandleEvent(const EventType & ev) = 0; |
||||
}; |
||||
|
||||
class EventCore |
||||
{ |
||||
public: |
||||
void QueueEvent(const EventType & ev); |
||||
void SetListener(EventListener * l); |
||||
|
||||
private: |
||||
EventListener * m_listener = nullptr; |
||||
}; |
||||
#ifdef WITH_EVENTS |
||||
extern EventCore core; |
||||
#endif |
||||
} |
||||
} |
||||
void EmitEvent(const EventType & ev); |
||||
|
||||
#endif |
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
#include "Websocket.h" |
||||
#include "Log.h" |
||||
|
||||
#include <set> |
||||
|
||||
#include <websocketpp/config/asio_no_tls.hpp> |
||||
#include <websocketpp/server.hpp> |
||||
#include <boost/property_tree/ini_parser.hpp> |
||||
#define GCC47_BOOST149 ((BOOST_VERSION == 104900) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) |
||||
#if !GCC47_BOOST149 |
||||
#include <boost/property_tree/json_parser.hpp> |
||||
#endif |
||||
|
||||
#include <stdexcept> |
||||
|
||||
namespace i2p |
||||
{ |
||||
namespace event |
||||
{ |
||||
|
||||
typedef websocketpp::server<websocketpp::config::asio> ServerImpl; |
||||
typedef websocketpp::connection_hdl ServerConn; |
||||
|
||||
class WebsocketServerImpl : public EventListener |
||||
{ |
||||
private: |
||||
typedef ServerImpl::message_ptr MessagePtr; |
||||
public: |
||||
|
||||
WebsocketServerImpl(const std::string & addr, int port) : m_run(false), m_thread(nullptr) |
||||
{ |
||||
m_server.init_asio(); |
||||
m_server.set_open_handler(std::bind(&WebsocketServerImpl::ConnOpened, this, std::placeholders::_1)); |
||||
m_server.set_close_handler(std::bind(&WebsocketServerImpl::ConnClosed, this, std::placeholders::_1)); |
||||
m_server.set_message_handler(std::bind(&WebsocketServerImpl::OnConnMessage, this, std::placeholders::_1, std::placeholders::_2)); |
||||
|
||||
m_server.listen(boost::asio::ip::address::from_string(addr), port); |
||||
} |
||||
|
||||
~WebsocketServerImpl() |
||||
{ |
||||
} |
||||
|
||||
void Start() { |
||||
m_run = true; |
||||
m_server.start_accept(); |
||||
m_thread = new std::thread([&] () { |
||||
while(m_run) { |
||||
try { |
||||
m_server.run(); |
||||
} catch (std::exception & e ) { |
||||
LogPrint(eLogError, "Websocket server: ", e.what()); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
void Stop() { |
||||
m_run = false; |
||||
m_server.stop(); |
||||
if(m_thread) { |
||||
m_thread->join(); |
||||
delete m_thread; |
||||
} |
||||
m_thread = nullptr; |
||||
} |
||||
|
||||
void ConnOpened(ServerConn c) |
||||
{ |
||||
std::lock_guard<std::mutex> lock(m_connsMutex); |
||||
m_conns.insert(c); |
||||
} |
||||
|
||||
void ConnClosed(ServerConn c) |
||||
{ |
||||
std::lock_guard<std::mutex> lock(m_connsMutex); |
||||
m_conns.erase(c); |
||||
} |
||||
|
||||
void OnConnMessage(ServerConn conn, ServerImpl::message_ptr msg) |
||||
{ |
||||
(void) conn; |
||||
(void) msg; |
||||
} |
||||
|
||||
void HandleEvent(const EventType & ev) |
||||
{ |
||||
std::lock_guard<std::mutex> lock(m_connsMutex); |
||||
LogPrint(eLogDebug, "websocket event"); |
||||
boost::property_tree::ptree event; |
||||
for (const auto & item : ev) { |
||||
event.put(item.first, item.second); |
||||
} |
||||
std::ostringstream ss; |
||||
write_json(ss, event); |
||||
std::string s = ss.str(); |
||||
|
||||
ConnList::iterator it; |
||||
for (it = m_conns.begin(); it != m_conns.end(); ++it) { |
||||
ServerImpl::connection_ptr con = m_server.get_con_from_hdl(*it); |
||||
con->send(s); |
||||
} |
||||
} |
||||
|
||||
private: |
||||
typedef std::set<ServerConn, std::owner_less<ServerConn> > ConnList; |
||||
bool m_run; |
||||
std::thread * m_thread; |
||||
std::mutex m_connsMutex; |
||||
ConnList m_conns; |
||||
ServerImpl m_server; |
||||
}; |
||||
|
||||
|
||||
WebsocketServer::WebsocketServer(const std::string & addr, int port) : m_impl(new WebsocketServerImpl(addr, port)) {} |
||||
WebsocketServer::~WebsocketServer() |
||||
{ |
||||
delete m_impl; |
||||
} |
||||
|
||||
|
||||
void WebsocketServer::Start() |
||||
{ |
||||
m_impl->Start(); |
||||
} |
||||
|
||||
void WebsocketServer::Stop() |
||||
{ |
||||
m_impl->Stop(); |
||||
} |
||||
|
||||
EventListener * WebsocketServer::ToListener() |
||||
{ |
||||
return m_impl; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
#ifndef WEBSOCKET_H__ |
||||
#define WEBSOCKET_H__ |
||||
#include "Event.h" |
||||
namespace i2p |
||||
{ |
||||
namespace event |
||||
{ |
||||
|
||||
class WebsocketServerImpl; |
||||
|
||||
class WebsocketServer |
||||
{ |
||||
public: |
||||
WebsocketServer(const std::string & addr, int port); |
||||
~WebsocketServer(); |
||||
|
||||
void Start(); |
||||
void Stop(); |
||||
|
||||
EventListener * ToListener(); |
||||
|
||||
private: |
||||
WebsocketServerImpl * m_impl; |
||||
}; |
||||
|
||||
} |
||||
} |
||||
#endif |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
This forder contain systemd unit files. |
||||
To use systemd daemon control, place files from this directory to debian folder. |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
[Unit] |
||||
Description=I2P Router written in C++ |
||||
After=network.target |
||||
|
||||
[Service] |
||||
User=i2pd |
||||
Group=i2pd |
||||
Type=forking |
||||
ExecStart=/usr/sbin/i2pd --conf=/etc/i2pd/i2pd.conf --pidfile=/var/run/i2pd/i2pd.pid --logfile=/var/log/i2pd/i2pd.log --daemon --service |
||||
ExecReload=/bin/kill -HUP $MAINPID |
||||
PIDFile=/var/run/i2pd/i2pd.pid |
||||
### Uncomment, if auto restart needed |
||||
#Restart=on-failure |
||||
|
||||
### Use SIGINT for gracefull stop daemon. |
||||
# i2pd stops accepting new tunnels and waits ~10 min while old ones do not die. |
||||
KillSignal=SIGINT |
||||
TimeoutStopSec=10m |
||||
|
||||
# If you have problems with hunging i2pd, you can try enable this |
||||
#LimitNOFILE=4096 |
||||
PrivateDevices=yes |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
d /var/run/i2pd 0755 i2pd i2pd - - |
||||
d /var/log/i2pd 0755 i2pd i2pd - - |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
files |
||||
i2pd-dbg.substvars |
||||
i2pd-dbg/ |
||||
i2pd.postinst.debhelper |
||||
i2pd.postrm.debhelper |
||||
i2pd.prerm.debhelper |
||||
i2pd.substvars |
||||
i2pd/ |
||||
|
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
Building on Android |
||||
=================== |
||||
|
||||
There are two versions: with QT and without QT. |
||||
|
||||
Pre-requesties |
||||
-------------- |
||||
|
||||
You need to install Android SDK, NDK and QT with android support. |
||||
|
||||
- [SDK](https://developer.android.com/studio/index.html) (choose command line tools only) |
||||
- [NDK](https://developer.android.com/ndk/downloads/index.html) |
||||
- [QT](https://www.qt.io/download-open-source/)(for QT only). Choose one for your platform for android. For example QT 5.6 under Linux would be [this file](http://download.qt.io/official_releases/qt/5.6/5.6.1-1/qt-opensource-linux-x64-android-5.6.1-1.run ) |
||||
|
||||
You also need Java JDK and Ant. |
||||
|
||||
QT-Creator (for QT only) |
||||
------------------------ |
||||
Open QT-creator that should be installed with QT. |
||||
Go to Settings/Anndroid and specify correct paths to SDK and NDK. |
||||
If everything is correct you will see two set avaiable: |
||||
Android for armeabi-v7a (gcc, qt) and Android for x86 (gcc, qt). |
||||
|
||||
Dependencies |
||||
-------------- |
||||
Take following pre-compiled binaries from PurpleI2P's repositories. |
||||
```bash |
||||
git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git |
||||
git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git |
||||
git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git |
||||
git clone https://github.com/PurpleI2P/android-ifaddrs.git |
||||
``` |
||||
|
||||
|
||||
Building the app with QT |
||||
------------------------ |
||||
- Open qt/i2pd_qt/i2pd_qt.pro in the QT-creator |
||||
- Change line MAIN_PATH = /path/to/libraries to an actual path where you put the dependancies to |
||||
- Select appropriate project (usually armeabi-v7a) and build |
||||
- You will find an .apk file in android-build/bin folder |
||||
|
||||
Building the app without QT |
||||
--------------------------- |
||||
- Change line I2PD_LIBS_PATH in android/jni/Application.mk to an actual path where you put the dependancies to |
||||
- Run 'ndk-build -j4' from andorid folder |
||||
- Create or edit file 'local.properties'. Place 'sdk.dir=<path to SDK>' and 'ndk.dir=<path to NDK>' |
||||
- Run 'ant clean debug' |
||||
|
||||
Creating release .apk |
||||
---------------------- |
||||
In order to create release .apk you must obtain a Java keystore file(.jks). Either you have in already, or you can generate it yourself using keytool, or from one of you existing well-know ceritificates. For example, i2pd release are signed with this [certificate](https://github.com/PurpleI2P/i2pd/blob/openssl/contrib/certificates/router/orignal_at_mail.i2p.crt). |
||||
Create file 'ant.propeties' |
||||
key.store='path to keystore file' |
||||
key.alias='alias name' |
||||
key.store.password='keystore password' |
||||
key.alias.password='alias password' |
||||
Run 'ant clean release' |
@ -1,75 +0,0 @@
@@ -1,75 +0,0 @@
|
||||
Cross compilation notes |
||||
======================= |
||||
|
||||
Static 64 bit windows binary on Ubuntu 15.10 (Wily Werewolf) |
||||
--------------------------------------------------------------------- |
||||
|
||||
Install cross compiler and friends |
||||
```sh |
||||
sudo apt-get install g++-mingw-w64-x86-64 |
||||
``` |
||||
Default is to use Win32 threading model which lacks std::mutex and such. So we change defaults |
||||
```sh |
||||
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix |
||||
``` |
||||
From now on we assume we have everything in `~/dev/`. Get Boost sources unpacked into `~/dev/boost_1_60_0/` |
||||
and change directory to it. |
||||
Now add out cross compiler configuration. Warning: the following will wipe out whatever you had in there. |
||||
```sh |
||||
echo "using gcc : mingw : x86_64-w64-mingw32-g++ ;" > ~/user-config.jam |
||||
``` |
||||
Proceed with building Boost normal way, but let's define dedicated staging directory |
||||
```sh |
||||
./bootstrap.sh |
||||
./b2 toolset=gcc-mingw target-os=windows variant=release link=static runtime-link=static address-model=64 \ |
||||
--build-type=minimal --with-filesystem --with-program_options --with-date_time \ |
||||
--stagedir=stage-mingw-64 |
||||
cd .. |
||||
``` |
||||
Now we get & build OpenSSL |
||||
```sh |
||||
git clone https://github.com/openssl/openssl |
||||
cd openssl |
||||
git checkout OpenSSL_1_0_2g |
||||
./Configure mingw64 no-rc2 no-rc4 no-rc5 no-idea no-bf no-cast no-whirlpool no-md2 no-md4 no-ripemd no-mdc2 \ |
||||
no-camellia no-seed no-comp no-krb5 no-gmp no-rfc3779 no-ec2m no-ssl2 no-jpake no-srp no-sctp no-srtp \ |
||||
--prefix=~/dev/stage --cross-compile-prefix=x86_64-w64-mingw32- |
||||
make depend |
||||
make |
||||
make install |
||||
cd .. |
||||
``` |
||||
and Zlib |
||||
```sh |
||||
git clone https://github.com/madler/zlib |
||||
cd zlib |
||||
git checkout v1.2.8 |
||||
CC=x86_64-w64-mingw32-gcc CFLAGS=-O3 ./configure --static --64 --prefix=~/dev/stage |
||||
make |
||||
make install |
||||
cd .. |
||||
``` |
||||
Now we prepare cross toolchain hint file for CMake, let's name it `~/dev/toolchain-mingw.cmake` |
||||
```cmake |
||||
SET(CMAKE_SYSTEM_NAME Windows) |
||||
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) |
||||
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) |
||||
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) |
||||
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) |
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
||||
``` |
||||
Download miniupnpc, unpack, and symlink it into `~/dev/miniupnpc/`. |
||||
Finally, we can build i2pd with all that goodness |
||||
```sh |
||||
git clone https://github.com/PurpleI2P/i2pd |
||||
mkdir i2pd-mingw-64-build |
||||
cd i2pd-mingw-64-build |
||||
BOOST_ROOT=~/dev/boost_1_60_0 cmake -G 'Unix Makefiles' ~/dev/i2pd/build -DBUILD_TYPE=Release \ |
||||
-DCMAKE_TOOLCHAIN_FILE=~/dev/toolchain-mingw.cmake -DWITH_AESNI=ON -DWITH_UPNP=ON -DWITH_STATIC=ON \ |
||||
-DWITH_HARDENING=ON -DCMAKE_INSTALL_PREFIX:PATH=~/dev/i2pd-mingw-64-static \ |
||||
-DZLIB_ROOT=~/dev/stage -DBOOST_LIBRARYDIR:PATH=~/dev/boost_1_60_0/stage-mingw-64/lib \ |
||||
-DOPENSSL_ROOT_DIR:PATH=~/dev/stage |
||||
make |
||||
x86_64-w64-mingw32-strip i2pd.exe |
||||
``` |
||||
By now, you should have a release build with stripped symbols. |
@ -1,148 +0,0 @@
@@ -1,148 +0,0 @@
|
||||
Building on Unix systems |
||||
============================= |
||||
|
||||
First of all we need to make sure that all dependencies are satisfied. |
||||
|
||||
This doc is trying to cover: |
||||
* [Debian/Ubuntu](#debian-ubuntu) (contains packaging instructions) |
||||
* [Fedora/Centos](#fedora-centos) |
||||
* [Fedora/Centos](#mac-os-x) |
||||
* [FreeBSD](#freebsd) |
||||
|
||||
Make sure you have all required dependencies for your system successfully installed. |
||||
|
||||
If so then we are ready to go! |
||||
Let's clone the repository and start building the i2pd: |
||||
```bash |
||||
git clone https://github.com/PurpleI2P/i2pd.git |
||||
cd i2pd/build |
||||
cmake -DCMAKE_BUILD_TYPE=Release # more options could be passed, see "CMake Options" |
||||
make # you may add VERBOSE=1 to cmdline for debugging |
||||
``` |
||||
|
||||
After successfull build i2pd could be installed with: |
||||
```bash |
||||
make install |
||||
``` |
||||
or you can just use 'make' once you have all dependencies (boost and openssl) installed |
||||
|
||||
```bash |
||||
git clone https://github.com/PurpleI2P/i2pd.git |
||||
cd i2pd |
||||
make |
||||
``` |
||||
|
||||
Debian/Ubuntu |
||||
------------- |
||||
|
||||
You will need a compiler and other tools that could be installed with `build-essential` package: |
||||
```bash |
||||
sudo apt-get install build-essential |
||||
``` |
||||
|
||||
Also you will need a bunch of development libraries: |
||||
```bash |
||||
sudo apt-get install \ |
||||
libboost-chrono-dev \ |
||||
libboost-date-time-dev \ |
||||
libboost-filesystem-dev \ |
||||
libboost-program-options-dev \ |
||||
libboost-system-dev \ |
||||
libboost-thread-dev \ |
||||
libssl-dev |
||||
``` |
||||
|
||||
If you need UPnP support (don't forget to run CMake with `WITH_UPNP=ON`) miniupnpc development library should be installed: |
||||
```bash |
||||
sudo apt-get install libminiupnpc-dev |
||||
``` |
||||
|
||||
You may also build deb-package with the following: |
||||
```bash |
||||
sudo apt-get install fakeroot devscripts |
||||
cd i2pd |
||||
debuild --no-tgz-check |
||||
``` |
||||
|
||||
Fedora/Centos |
||||
------------- |
||||
|
||||
You will need a compiler and other tools to perform a build: |
||||
```bash |
||||
sudo yum install make cmake gcc gcc-c++ |
||||
``` |
||||
|
||||
*Latest Fedora system using [DNF](https://en.wikipedia.org/wiki/DNF_(software)) instead of YUM by default, you may prefer to use DNF, but YUM should be ok* |
||||
|
||||
Also you will need a bunch of development libraries |
||||
```bash |
||||
sudo yum install boost-devel openssl-devel |
||||
``` |
||||
|
||||
If you need UPnP support (don't forget to run CMake with `WITH_UPNP=ON`) miniupnpc development library should be installed: |
||||
```bash |
||||
miniupnpc-devel |
||||
``` |
||||
> *Centos 7 has CMake 2.8.11 in the official repositories that too old to build i2pd, CMake >=2.8.12 is required.* |
||||
> |
||||
> But you can use cmake3 from the epel repository: |
||||
> ```bash |
||||
> yum install epel-release -y |
||||
> yum install make cmake3 gcc gcc-c++ miniupnpc-devel boost-devel openssl-devel -y |
||||
> cmake3 -DWITH_LIBRARY=OFF -DWITH_UPNP=ON -DWITH_HARDENING=ON -DBUILD_SHARED_LIBS:BOOL=OFF |
||||
> make |
||||
> ``` |
||||
|
||||
MAC OS X |
||||
-------- |
||||
|
||||
Requires [homebrew](http://brew.sh/) |
||||
|
||||
```bash |
||||
brew install libressl boost |
||||
``` |
||||
|
||||
Then build: |
||||
```bash |
||||
make HOMEBREW=1 |
||||
``` |
||||
|
||||
|
||||
FreeBSD |
||||
------- |
||||
|
||||
For 10.X use clang. You would also need boost and openssl ports. |
||||
Type gmake, it invokes Makefile.bsd, make necessary changes there is required. |
||||
|
||||
Branch 9.X has gcc v4.2, that knows nothing about required c++11 standart. |
||||
|
||||
Required ports: |
||||
|
||||
* `devel/cmake` |
||||
* `devel/boost-libs` |
||||
* `lang/gcc47`(or later version) |
||||
|
||||
To use newer compiler you should set these variables(replace "47" with your actual gcc version): |
||||
```bash |
||||
export CC=/usr/local/bin/gcc47 |
||||
export CXX=/usr/local/bin/g++47 |
||||
``` |
||||
|
||||
CMake Options |
||||
------------- |
||||
|
||||
Available CMake options(each option has a form of `<key>=<value>`, for more information see `man 1 cmake`): |
||||
|
||||
* `CMAKE_BUILD_TYPE` build profile (Debug/Release) |
||||
* `WITH_BINARY` build i2pd itself |
||||
* `WITH_LIBRARY` build libi2pd |
||||
* `WITH_STATIC` build static versions of library and i2pd binary |
||||
* `WITH_UPNP` build with UPnP support (requires libupnp) |
||||
* `WITH_AESNI` build with AES-NI support (ON/OFF) |
||||
* `WITH_HARDENING` enable hardening features (ON/OFF) (gcc only) |
||||
* `WITH_PCH` use pre-compiled header (experimental, speeds up build) |
||||
|
||||
Also there is `-L` flag for CMake that could be used to list current cached options: |
||||
```bash |
||||
cmake -L |
||||
``` |
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
Build requirements |
||||
============ |
||||
|
||||
Linux/FreeBSD/OSX |
||||
----------------- |
||||
|
||||
GCC 4.7 or newer, Boost 1.49 or newer, openssl, zlib. Clang can be used instead of GCC. |
||||
|
||||
Windows |
||||
------- |
||||
|
||||
VS2013 (known to work with 12.0.21005.1 or newer), Boost 1.46 or newer, |
||||
crypto++ 5.62. See Win32/README-Build.txt for instructions on how to build i2pd |
||||
and its dependencies. |
||||
|
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
Building on Android |
||||
=================== |
||||
|
||||
There are two versions: with QT and without QT. |
||||
|
||||
Pre-requesties |
||||
-------------- |
||||
|
||||
You need to install Android SDK, NDK and QT with android support. |
||||
|
||||
- [SDK](https://developer.android.com/studio/index.html) (choose command line tools only) |
||||
- [NDK](https://developer.android.com/ndk/downloads/index.html) |
||||
- [QT](https://www.qt.io/download-open-source/)(for QT only). |
||||
Choose one for your platform for android. For example QT 5.6 under Linux would be [this file](http://download.qt.io/official_releases/qt/5.6/5.6.1-1/qt-opensource-linux-x64-android-5.6.1-1.run) |
||||
|
||||
You also need Java JDK and Ant. |
||||
|
||||
QT-Creator (for QT only) |
||||
------------------------ |
||||
|
||||
Open QT-creator that should be installed with QT. |
||||
Go to Settings/Anndroid and specify correct paths to SDK and NDK. |
||||
If everything is correct you will see two set avaiable: |
||||
Android for armeabi-v7a (gcc, qt) and Android for x86 (gcc, qt). |
||||
|
||||
Dependencies |
||||
-------------- |
||||
|
||||
Take following pre-compiled binaries from PurpleI2P's repositories. |
||||
|
||||
git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git |
||||
git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git |
||||
git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git |
||||
git clone https://github.com/PurpleI2P/android-ifaddrs.git |
||||
|
||||
Building the app with QT |
||||
------------------------ |
||||
|
||||
- Open `qt/i2pd_qt/i2pd_qt.pro` in the QT-creator |
||||
- Change line `MAIN_PATH = /path/to/libraries` to an actual path where you put the dependancies to |
||||
- Select appropriate project (usually armeabi-v7a) and build |
||||
- You will find an .apk file in `android-build/bin` folder |
||||
|
||||
Building the app without QT |
||||
--------------------------- |
||||
|
||||
- Change line `I2PD_LIBS_PATH` in `android/jni/Application.mk` to an actual path where you put the dependancies to |
||||
- Run `ndk-build -j4` from andorid folder |
||||
- Create or edit file 'local.properties'. Place 'sdk.dir=<path to SDK>' and 'ndk.dir=<path to NDK>' |
||||
- Run `ant clean debug` |
||||
|
||||
Creating release .apk |
||||
---------------------- |
||||
|
||||
In order to create release .apk you must obtain a Java keystore file(.jks). Either you have in already, or you can generate it yourself using keytool, or from one of you existing well-know ceritificates. |
||||
For example, i2pd release are signed with this [certificate](https://github.com/PurpleI2P/i2pd/blob/openssl/contrib/certificates/router/orignal_at_mail.i2p.crt). |
||||
|
||||
Create file 'ant.propeties': |
||||
|
||||
key.store='path to keystore file' |
||||
key.alias='alias name' |
||||
key.store.password='keystore password' |
||||
key.alias.password='alias password' |
||||
|
||||
Run `ant clean release` |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
Cross compilation notes |
||||
======================= |
||||
|
||||
Static 64 bit windows binary on Ubuntu 15.10 (Wily Werewolf) |
||||
------------------------------------------------------------ |
||||
|
||||
Install cross compiler and friends |
||||
|
||||
sudo apt-get install g++-mingw-w64-x86-64 |
||||
|
||||
Default is to use Win32 threading model which lacks std::mutex and such. So we change defaults |
||||
|
||||
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix |
||||
|
||||
From now on we assume we have everything in `~/dev/`. Get Boost sources unpacked into `~/dev/boost_1_60_0/` and change directory to it. |
||||
Now add out cross compiler configuration. Warning: the following will wipe out whatever you had in there. |
||||
|
||||
echo "using gcc : mingw : x86_64-w64-mingw32-g++ ;" > ~/user-config.jam |
||||
|
||||
Proceed with building Boost normal way, but let's define dedicated staging directory |
||||
|
||||
./bootstrap.sh |
||||
./b2 toolset=gcc-mingw target-os=windows variant=release link=static runtime-link=static address-model=64 \ |
||||
--build-type=minimal --with-filesystem --with-program_options --with-date_time \ |
||||
--stagedir=stage-mingw-64 |
||||
cd .. |
||||
|
||||
Now we get & build OpenSSL |
||||
|
||||
git clone https://github.com/openssl/openssl |
||||
cd openssl |
||||
git checkout OpenSSL_1_0_2g |
||||
./Configure mingw64 no-rc2 no-rc4 no-rc5 no-idea no-bf no-cast no-whirlpool no-md2 no-md4 no-ripemd no-mdc2 \ |
||||
no-camellia no-seed no-comp no-krb5 no-gmp no-rfc3779 no-ec2m no-ssl2 no-jpake no-srp no-sctp no-srtp \ |
||||
--prefix=~/dev/stage --cross-compile-prefix=x86_64-w64-mingw32- |
||||
make depend |
||||
make |
||||
make install |
||||
cd .. |
||||
|
||||
...and zlib |
||||
|
||||
git clone https://github.com/madler/zlib |
||||
cd zlib |
||||
git checkout v1.2.8 |
||||
CC=x86_64-w64-mingw32-gcc CFLAGS=-O3 ./configure --static --64 --prefix=~/dev/stage |
||||
make |
||||
make install |
||||
cd .. |
||||
|
||||
Now we prepare cross toolchain hint file for CMake, let's name it `~/dev/toolchain-mingw.cmake` |
||||
|
||||
set(CMAKE_SYSTEM_NAME Windows) |
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) |
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) |
||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) |
||||
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) |
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
||||
|
||||
Download miniupnpc, unpack and symlink it into `~/dev/miniupnpc/`. |
||||
Finally, we can build i2pd with all that goodness |
||||
|
||||
git clone https://github.com/PurpleI2P/i2pd |
||||
mkdir i2pd-mingw-64-build |
||||
cd i2pd-mingw-64-build |
||||
BOOST_ROOT=~/dev/boost_1_60_0 cmake -G 'Unix Makefiles' ~/dev/i2pd/build -DBUILD_TYPE=Release \ |
||||
-DCMAKE_TOOLCHAIN_FILE=~/dev/toolchain-mingw.cmake -DWITH_AESNI=ON -DWITH_UPNP=ON -DWITH_STATIC=ON \ |
||||
-DWITH_HARDENING=ON -DCMAKE_INSTALL_PREFIX:PATH=~/dev/i2pd-mingw-64-static \ |
||||
-DZLIB_ROOT=~/dev/stage -DBOOST_LIBRARYDIR:PATH=~/dev/boost_1_60_0/stage-mingw-64/lib \ |
||||
-DOPENSSL_ROOT_DIR:PATH=~/dev/stage |
||||
make |
||||
x86_64-w64-mingw32-strip i2pd.exe |
||||
|
||||
By now, you should have a release build with stripped symbols. |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
Build requirements |
||||
================== |
||||
|
||||
In general, for building i2pd you need several things: |
||||
|
||||
* compiler with c++11 support (for example: gcc >= 4.7, clang) |
||||
* boost >= 1.49 |
||||
* openssl library |
||||
* zlib library (openssl already depends on it) |
||||
|
||||
Optional tools: |
||||
|
||||
* cmake >= 2.8 (or 3.3+ if you want to use precompiled headers on windows) |
||||
* miniupnp library (for upnp support) |
||||
* [websocketpp](https://github.com/zaphoyd/websocketpp/) (for websocket ui) |
@ -0,0 +1,138 @@
@@ -0,0 +1,138 @@
|
||||
Building on Unix systems |
||||
============================= |
||||
|
||||
First of all we need to make sure that all dependencies are satisfied. |
||||
|
||||
This doc is trying to cover: |
||||
|
||||
* [Debian/Ubuntu](#debian-ubuntu) (contains packaging instructions) |
||||
* [Fedora/Centos](#fedora-centos) |
||||
* [Fedora/Centos](#mac-os-x) |
||||
* [FreeBSD](#freebsd) |
||||
|
||||
Make sure you have all required dependencies for your system successfully installed. |
||||
See [this](requirements.md) page for common requirements. |
||||
|
||||
If so then we are ready to go! |
||||
Let's clone the repository and start building the i2pd: |
||||
|
||||
git clone https://github.com/PurpleI2P/i2pd.git |
||||
|
||||
Generic build process looks like this (with cmake): |
||||
|
||||
cd i2pd/build |
||||
cmake <cmake options> . # see "CMake Options" section below |
||||
make # you may add VERBOSE=1 to cmdline for debugging |
||||
|
||||
..or with quick-and-dirty way with just make: |
||||
|
||||
cd i2pd/ |
||||
make |
||||
|
||||
After successfull build i2pd could be installed with: |
||||
|
||||
make install |
||||
|
||||
CMake Options |
||||
------------- |
||||
|
||||
Available CMake options(each option has a form of `<key>=<value>`, for more information see `man 1 cmake`): |
||||
|
||||
* `CMAKE_BUILD_TYPE` build profile (Debug/Release) |
||||
* `WITH_BINARY` build i2pd itself |
||||
* `WITH_LIBRARY` build libi2pd |
||||
* `WITH_STATIC` build static versions of library and i2pd binary |
||||
* `WITH_UPNP` build with UPnP support (requires libminiupnp) |
||||
* `WITH_AESNI` build with AES-NI support (ON/OFF) |
||||
* `WITH_HARDENING` enable hardening features (ON/OFF) (gcc only) |
||||
* `WITH_PCH` use pre-compiled header (experimental, speeds up build) |
||||
* `WITH_I2LUA` used when building i2lua |
||||
* `WITH_WEBSOCKETS` enable websocket server |
||||
|
||||
|
||||
Also there is `-L` flag for CMake that could be used to list current cached options: |
||||
|
||||
cmake -L |
||||
|
||||
Debian/Ubuntu |
||||
------------- |
||||
|
||||
You will need a compiler and other tools that could be installed with `build-essential` package: |
||||
|
||||
sudo apt-get install build-essential |
||||
|
||||
Also you will need a bunch of development libraries: |
||||
|
||||
sudo apt-get install \ |
||||
libboost-chrono-dev \ |
||||
libboost-date-time-dev \ |
||||
libboost-filesystem-dev \ |
||||
libboost-program-options-dev \ |
||||
libboost-system-dev \ |
||||
libboost-thread-dev \ |
||||
libssl-dev |
||||
|
||||
If you need UPnP support miniupnpc development library should be installed (don't forget to rerun CMake with needed option): |
||||
|
||||
sudo apt-get install libminiupnpc-dev |
||||
|
||||
You may also build deb-package with the following: |
||||
|
||||
sudo apt-get install fakeroot devscripts |
||||
cd i2pd |
||||
debuild --no-tgz-check |
||||
|
||||
Fedora/Centos |
||||
------------- |
||||
|
||||
You will need a compiler and other tools to perform a build: |
||||
|
||||
sudo yum install make cmake gcc gcc-c++ |
||||
|
||||
Also you will need a bunch of development libraries |
||||
|
||||
sudo yum install boost-devel openssl-devel |
||||
|
||||
If you need UPnP support miniupnpc development library should be installed (don't forget to rerun CMake with needed option): |
||||
|
||||
sudo yum install miniupnpc-devel |
||||
|
||||
Latest Fedora systems using [DNF](https://en.wikipedia.org/wiki/DNF_(software)) instead of YUM by default, you may prefer to use DNF, but YUM should be ok |
||||
|
||||
Centos 7 has CMake 2.8.11 in the official repositories that too old to build i2pd, CMake >=2.8.12 is required. |
||||
But you can use cmake3 from the epel repository: |
||||
|
||||
yum install epel-release -y |
||||
yum install make cmake3 gcc gcc-c++ miniupnpc-devel boost-devel openssl-devel -y |
||||
|
||||
...and then use 'cmake3' instead 'cmake'. |
||||
|
||||
MAC OS X |
||||
-------- |
||||
|
||||
Requires [homebrew](http://brew.sh) |
||||
|
||||
brew install boost libressl |
||||
|
||||
Then build: |
||||
|
||||
make HOMEBREW=1 |
||||
|
||||
FreeBSD |
||||
------- |
||||
|
||||
For 10.X use clang. You would also need devel/boost-libs, security/openssl and devel/gmake ports. |
||||
Type gmake, it invokes Makefile.bsd, make necessary changes there is required. |
||||
|
||||
Branch 9.X has gcc v4.2, that is too old (not supports -std=c++11) |
||||
|
||||
Required ports: |
||||
|
||||
* `devel/cmake` |
||||
* `devel/boost-libs` |
||||
* `lang/gcc47`(or later version) |
||||
|
||||
To use newer compiler you should set these variables(replace "47" with your actual gcc version): |
||||
|
||||
export CC=/usr/local/bin/gcc47 |
||||
export CXX=/usr/local/bin/g++47 |
Loading…
Reference in new issue