mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-24 12:47:37 +01:00
Merge branch 'openssl' into OSX_Native_App
This commit is contained in:
commit
e561a43e5d
10 changed files with 91 additions and 12 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
#include "NetDb.h"
|
#include "NetDb.h"
|
||||||
#include "Destination.h"
|
#include "Destination.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -36,27 +37,29 @@ namespace client
|
||||||
auto it = params->find (I2CP_PARAM_INBOUND_TUNNEL_LENGTH);
|
auto it = params->find (I2CP_PARAM_INBOUND_TUNNEL_LENGTH);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
{
|
{
|
||||||
int len = boost::lexical_cast<int>(it->second);
|
|
||||||
|
int len = i2p::util::lexical_cast<int>(it->second, inboundTunnelLen);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
inboundTunnelLen = len;
|
inboundTunnelLen = len;
|
||||||
LogPrint (eLogInfo, "Destination: Inbound tunnel length set to ", len);
|
|
||||||
}
|
}
|
||||||
|
LogPrint (eLogInfo, "Destination: Inbound tunnel length set to ", inboundTunnelLen);
|
||||||
}
|
}
|
||||||
it = params->find (I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH);
|
it = params->find (I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
{
|
{
|
||||||
int len = boost::lexical_cast<int>(it->second);
|
|
||||||
|
int len = i2p::util::lexical_cast<int>(it->second, outboundTunnelLen);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
outboundTunnelLen = len;
|
outboundTunnelLen = len;
|
||||||
LogPrint (eLogInfo, "Destination: Outbound tunnel length set to ", len);
|
|
||||||
}
|
}
|
||||||
|
LogPrint (eLogInfo, "Destination: Outbound tunnel length set to ", outboundTunnelLen);
|
||||||
}
|
}
|
||||||
it = params->find (I2CP_PARAM_INBOUND_TUNNELS_QUANTITY);
|
it = params->find (I2CP_PARAM_INBOUND_TUNNELS_QUANTITY);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
{
|
{
|
||||||
int quantity = boost::lexical_cast<int>(it->second);
|
int quantity = i2p::util::lexical_cast<int>(it->second, inboundTunnelsQuantity);
|
||||||
if (quantity > 0)
|
if (quantity > 0)
|
||||||
{
|
{
|
||||||
inboundTunnelsQuantity = quantity;
|
inboundTunnelsQuantity = quantity;
|
||||||
|
@ -66,7 +69,7 @@ namespace client
|
||||||
it = params->find (I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY);
|
it = params->find (I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
{
|
{
|
||||||
int quantity = boost::lexical_cast<int>(it->second);
|
int quantity = i2p::util::lexical_cast<int>(it->second, outboundTunnelsQuantity);
|
||||||
if (quantity > 0)
|
if (quantity > 0)
|
||||||
{
|
{
|
||||||
outboundTunnelsQuantity = quantity;
|
outboundTunnelsQuantity = quantity;
|
||||||
|
@ -76,7 +79,7 @@ namespace client
|
||||||
it = params->find (I2CP_PARAM_TAGS_TO_SEND);
|
it = params->find (I2CP_PARAM_TAGS_TO_SEND);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
{
|
{
|
||||||
int tagsToSend = boost::lexical_cast<int>(it->second);
|
int tagsToSend = i2p::util::lexical_cast<int>(it->second, numTags);
|
||||||
if (tagsToSend > 0)
|
if (tagsToSend > 0)
|
||||||
{
|
{
|
||||||
numTags = tagsToSend;
|
numTags = tagsToSend;
|
||||||
|
|
|
@ -417,6 +417,9 @@ namespace util
|
||||||
default: s << "Unknown";
|
default: s << "Unknown";
|
||||||
}
|
}
|
||||||
s << "<br>\r\n";
|
s << "<br>\r\n";
|
||||||
|
auto family = i2p::context.GetFamily ();
|
||||||
|
if (family.length () > 0)
|
||||||
|
s << "<b>Family:</b> " << family << "<br>\r\n";
|
||||||
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
|
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
|
||||||
s << "<b>Received:</b> ";
|
s << "<b>Received:</b> ";
|
||||||
s << std::fixed << std::setprecision(2);
|
s << std::fixed << std::setprecision(2);
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -14,7 +14,7 @@ USE_STATIC := no
|
||||||
|
|
||||||
ifeq ($(UNAME),Darwin)
|
ifeq ($(UNAME),Darwin)
|
||||||
DAEMON_SRC += DaemonLinux.cpp
|
DAEMON_SRC += DaemonLinux.cpp
|
||||||
include Makefile.osx
|
include Makefile.homebrew
|
||||||
else ifeq ($(shell echo $(UNAME) | $(GREP) -c FreeBSD),1)
|
else ifeq ($(shell echo $(UNAME) | $(GREP) -c FreeBSD),1)
|
||||||
DAEMON_SRC += DaemonLinux.cpp
|
DAEMON_SRC += DaemonLinux.cpp
|
||||||
include Makefile.bsd
|
include Makefile.bsd
|
||||||
|
|
29
Makefile.homebrew
Normal file
29
Makefile.homebrew
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# root directory holding homebrew
|
||||||
|
BREWROOT = /usr/local/
|
||||||
|
BOOSTROOT = ${BREWROOT}/opt/boost
|
||||||
|
SSLROOT = ${BREWROOT}/opt/libressl
|
||||||
|
CXX = clang++
|
||||||
|
CXXFLAGS = -g -Wall -std=c++11 -DMAC_OSX
|
||||||
|
INCFLAGS = -I${SSLROOT}/include -I${BOOSTROOT}/include
|
||||||
|
LDFLAGS = -L${SSLROOT}/lib -L${BOOSTROOT}/lib
|
||||||
|
LDLIBS = -lz -lcrypto -lssl -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
||||||
|
|
||||||
|
ifeq ($(USE_UPNP),1)
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
CXXFLAGS += -DUSE_UPNP
|
||||||
|
endif
|
||||||
|
|
||||||
|
# OSX Notes
|
||||||
|
# http://www.hutsby.net/2011/08/macs-with-aes-ni.html
|
||||||
|
# Seems like all recent Mac's have AES-NI, after firmware upgrade 2.2
|
||||||
|
# Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic
|
||||||
|
# note from psi: 2009 macbook does not have aesni
|
||||||
|
#ifeq ($(USE_AESNI),yes)
|
||||||
|
# CXXFLAGS += -maes -DAESNI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# Disabled, since it will be the default make rule. I think its better
|
||||||
|
# to define the default rule in Makefile and not Makefile.<ostype> - torkel
|
||||||
|
#install: all
|
||||||
|
# test -d ${PREFIX} || mkdir -p ${PREFIX}/
|
||||||
|
# cp -r i2p ${PREFIX}/
|
|
@ -149,6 +149,11 @@ namespace i2p
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string RouterContext::GetFamily () const
|
||||||
|
{
|
||||||
|
return m_RouterInfo.GetProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY);
|
||||||
|
}
|
||||||
|
|
||||||
void RouterContext::SetFamily (const std::string& family)
|
void RouterContext::SetFamily (const std::string& family)
|
||||||
{
|
{
|
||||||
std::string signature;
|
std::string signature;
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace i2p
|
||||||
bool IsFloodfill () const { return m_IsFloodfill; };
|
bool IsFloodfill () const { return m_IsFloodfill; };
|
||||||
void SetFloodfill (bool floodfill);
|
void SetFloodfill (bool floodfill);
|
||||||
void SetFamily (const std::string& family);
|
void SetFamily (const std::string& family);
|
||||||
|
std::string GetFamily () const;
|
||||||
void SetBandwidth (int limit); /* in kilobytes */
|
void SetBandwidth (int limit); /* in kilobytes */
|
||||||
void SetBandwidth (char L); /* by letter */
|
void SetBandwidth (char L); /* by letter */
|
||||||
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
|
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
|
||||||
|
|
|
@ -636,6 +636,14 @@ namespace data
|
||||||
m_Properties.erase (key);
|
m_Properties.erase (key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string RouterInfo::GetProperty (const std::string& key) const
|
||||||
|
{
|
||||||
|
auto it = m_Properties.find (key);
|
||||||
|
if (it != m_Properties.end ())
|
||||||
|
return it->second;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
bool RouterInfo::IsNTCP (bool v4only) const
|
bool RouterInfo::IsNTCP (bool v4only) const
|
||||||
{
|
{
|
||||||
if (v4only)
|
if (v4only)
|
||||||
|
|
|
@ -128,6 +128,7 @@ namespace data
|
||||||
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||||
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
|
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
|
||||||
void DeleteProperty (const std::string& key); // called from RouterContext only
|
void DeleteProperty (const std::string& key); // called from RouterContext only
|
||||||
|
std::string GetProperty (const std::string& key) const; // called from RouterContext only
|
||||||
void ClearProperties () { m_Properties.clear (); };
|
void ClearProperties () { m_Properties.clear (); };
|
||||||
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
||||||
bool IsReachable () const { return m_Caps & Caps::eReachable; };
|
bool IsReachable () const { return m_Caps & Caps::eReachable; };
|
||||||
|
|
|
@ -93,6 +93,21 @@ If you need UPnP support (don't forget to run CMake with `WITH_UPNP=ON`) miniupn
|
||||||
miniupnpc-devel
|
miniupnpc-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
|
MAC OS X
|
||||||
|
--------
|
||||||
|
|
||||||
|
Requires homebrew
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install libressl boost
|
||||||
|
```
|
||||||
|
|
||||||
|
Then build:
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
FreeBSD
|
FreeBSD
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
14
util.h
14
util.h
|
@ -5,11 +5,25 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace util
|
namespace util
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
wrapper arround boost::lexical_cast that "never" fails
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
T lexical_cast(const std::string & str, const T fallback) {
|
||||||
|
try {
|
||||||
|
return boost::lexical_cast<T>(str);
|
||||||
|
} catch ( ... ) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
// in (lower case)
|
// in (lower case)
|
||||||
|
|
Loading…
Add table
Reference in a new issue