mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 22:57:52 +00:00
Merge remote-tracking branch 'purple/openssl'
This commit is contained in:
commit
a98498eb06
@ -3,6 +3,7 @@ cache:
|
|||||||
apt: true
|
apt: true
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
|
- osx
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
addons:
|
addons:
|
||||||
@ -23,6 +24,11 @@ addons:
|
|||||||
- libssl-dev
|
- libssl-dev
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- gcc
|
||||||
|
- clang
|
||||||
|
before_install:
|
||||||
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
|
||||||
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openssl miniupnpc ; fi
|
||||||
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink boost openssl && brew link boost openssl -f ; fi
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- BUILD_TYPE=Release UPNP=ON
|
- BUILD_TYPE=Release UPNP=ON
|
||||||
|
@ -52,8 +52,12 @@ namespace client
|
|||||||
LoadPrivateKeys (keys, httpProxyKeys);
|
LoadPrivateKeys (keys, httpProxyKeys);
|
||||||
localDestination = CreateNewLocalDestination (keys, false);
|
localDestination = CreateNewLocalDestination (keys, false);
|
||||||
}
|
}
|
||||||
m_HttpProxy = new i2p::proxy::HTTPProxy(httpProxyAddr, httpProxyPort, localDestination);
|
try {
|
||||||
m_HttpProxy->Start();
|
m_HttpProxy = new i2p::proxy::HTTPProxy(httpProxyAddr, httpProxyPort, localDestination);
|
||||||
|
m_HttpProxy->Start();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
LogPrint(eLogError, "Clients: Exception in HTTP Proxy: ", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool socksproxy; i2p::config::GetOption("socksproxy.enabled", socksproxy);
|
bool socksproxy; i2p::config::GetOption("socksproxy.enabled", socksproxy);
|
||||||
@ -70,8 +74,12 @@ namespace client
|
|||||||
LoadPrivateKeys (keys, socksProxyKeys);
|
LoadPrivateKeys (keys, socksProxyKeys);
|
||||||
localDestination = CreateNewLocalDestination (keys, false);
|
localDestination = CreateNewLocalDestination (keys, false);
|
||||||
}
|
}
|
||||||
m_SocksProxy = new i2p::proxy::SOCKSProxy(socksProxyAddr, socksProxyPort, socksOutProxyAddr, socksOutProxyPort, localDestination);
|
try {
|
||||||
m_SocksProxy->Start();
|
m_SocksProxy = new i2p::proxy::SOCKSProxy(socksProxyAddr, socksProxyPort, socksOutProxyAddr, socksOutProxyPort, localDestination);
|
||||||
|
m_SocksProxy->Start();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
LogPrint(eLogError, "Clients: Exception in SOCKS Proxy: ", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// I2P tunnels
|
// I2P tunnels
|
||||||
@ -83,8 +91,12 @@ namespace client
|
|||||||
std::string samAddr; i2p::config::GetOption("sam.address", samAddr);
|
std::string samAddr; i2p::config::GetOption("sam.address", samAddr);
|
||||||
uint16_t samPort; i2p::config::GetOption("sam.port", samPort);
|
uint16_t samPort; i2p::config::GetOption("sam.port", samPort);
|
||||||
LogPrint(eLogInfo, "Clients: starting SAM bridge at ", samAddr, ":", samPort);
|
LogPrint(eLogInfo, "Clients: starting SAM bridge at ", samAddr, ":", samPort);
|
||||||
m_SamBridge = new SAMBridge (samAddr, samPort);
|
try {
|
||||||
m_SamBridge->Start ();
|
m_SamBridge = new SAMBridge (samAddr, samPort);
|
||||||
|
m_SamBridge->Start ();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
LogPrint(eLogError, "Clients: Exception in SAM bridge: ", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOB
|
// BOB
|
||||||
@ -93,8 +105,12 @@ namespace client
|
|||||||
std::string bobAddr; i2p::config::GetOption("bob.address", bobAddr);
|
std::string bobAddr; i2p::config::GetOption("bob.address", bobAddr);
|
||||||
uint16_t bobPort; i2p::config::GetOption("bob.port", bobPort);
|
uint16_t bobPort; i2p::config::GetOption("bob.port", bobPort);
|
||||||
LogPrint(eLogInfo, "Clients: starting BOB command channel at ", bobAddr, ":", bobPort);
|
LogPrint(eLogInfo, "Clients: starting BOB command channel at ", bobAddr, ":", bobPort);
|
||||||
m_BOBCommandChannel = new BOBCommandChannel (bobAddr, bobPort);
|
try {
|
||||||
m_BOBCommandChannel->Start ();
|
m_BOBCommandChannel = new BOBCommandChannel (bobAddr, bobPort);
|
||||||
|
m_BOBCommandChannel->Start ();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
LogPrint(eLogError, "Clients: Exception in BOB bridge: ", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_AddressBook.StartResolvers ();
|
m_AddressBook.StartResolvers ();
|
||||||
|
29
Daemon.h
29
Daemon.h
@ -56,20 +56,25 @@ namespace i2p
|
|||||||
#else
|
#else
|
||||||
class DaemonLinux : public Daemon_Singleton
|
class DaemonLinux : public Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DaemonLinux& Instance()
|
static DaemonLinux& Instance()
|
||||||
{
|
{
|
||||||
static DaemonLinux instance;
|
static DaemonLinux instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start();
|
bool start();
|
||||||
bool stop();
|
bool stop();
|
||||||
; void run ();
|
void run ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string pidfile;
|
|
||||||
int pidFH;
|
std::string pidfile;
|
||||||
|
int pidFH;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
int gracefullShutdownInterval; // in seconds
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,19 +12,29 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "RouterContext.h"
|
||||||
|
|
||||||
void handle_signal(int sig)
|
void handle_signal(int sig)
|
||||||
{
|
{
|
||||||
switch (sig)
|
switch (sig)
|
||||||
{
|
{
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
LogPrint(eLogInfo, "Daemon: Got SIGHUP, reopening log...");
|
LogPrint(eLogInfo, "Daemon: Got SIGHUP, reopening log...");
|
||||||
i2p::log::Logger().Reopen ();
|
i2p::log::Logger().Reopen ();
|
||||||
break;
|
break;
|
||||||
case SIGABRT:
|
case SIGINT:
|
||||||
case SIGTERM:
|
if (i2p::context.AcceptsTunnels () && !Daemon.gracefullShutdownInterval)
|
||||||
case SIGINT:
|
{
|
||||||
Daemon.running = 0; // Exit loop
|
i2p::context.SetAcceptsTunnels (false);
|
||||||
|
Daemon.gracefullShutdownInterval = 10*60; // 10 minutes
|
||||||
|
LogPrint(eLogInfo, "Graceful shutdown after ", Daemon.gracefullShutdownInterval, " seconds");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Daemon.running = 0;
|
||||||
|
break;
|
||||||
|
case SIGABRT:
|
||||||
|
case SIGTERM:
|
||||||
|
Daemon.running = 0; // Exit loop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,6 +106,7 @@ namespace i2p
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gracefullShutdownInterval = 0; // not specified
|
||||||
|
|
||||||
// Signal handler
|
// Signal handler
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@ -122,6 +133,15 @@ namespace i2p
|
|||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for (std::chrono::seconds(1));
|
std::this_thread::sleep_for (std::chrono::seconds(1));
|
||||||
|
if (gracefullShutdownInterval)
|
||||||
|
{
|
||||||
|
gracefullShutdownInterval--; // - 1 second
|
||||||
|
if (gracefullShutdownInterval <= 0)
|
||||||
|
{
|
||||||
|
LogPrint(eLogInfo, "Graceful shutdown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user