mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
try fixing issue #482
This commit is contained in:
parent
c54f7c81c4
commit
2373b94d3e
@ -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
|
||||||
{
|
{
|
||||||
@ -35,28 +36,30 @@ 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,11 +79,11 @@ 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;
|
||||||
LogPrint (eLogInfo, "Destination: Tags to send set to ", tagsToSend);
|
LogPrint (eLogInfo, "Destination: Tags to send set to ", tagsToSend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it = params->find (I2CP_PARAM_EXPLICIT_PEERS);
|
it = params->find (I2CP_PARAM_EXPLICIT_PEERS);
|
||||||
|
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…
x
Reference in New Issue
Block a user