Browse Source

Merge remote-tracking branch 'purple/openssl'

pull/464/head
Jeff Becker 9 years ago
parent
commit
a98498eb06
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
  1. 6
      .travis.yml
  2. 16
      ClientContext.cpp
  3. 7
      Daemon.h
  4. 22
      DaemonLinux.cpp

6
.travis.yml

@ -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

16
ClientContext.cpp

@ -52,8 +52,12 @@ namespace client
LoadPrivateKeys (keys, httpProxyKeys); LoadPrivateKeys (keys, httpProxyKeys);
localDestination = CreateNewLocalDestination (keys, false); localDestination = CreateNewLocalDestination (keys, false);
} }
try {
m_HttpProxy = new i2p::proxy::HTTPProxy(httpProxyAddr, httpProxyPort, localDestination); m_HttpProxy = new i2p::proxy::HTTPProxy(httpProxyAddr, httpProxyPort, localDestination);
m_HttpProxy->Start(); 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);
} }
try {
m_SocksProxy = new i2p::proxy::SOCKSProxy(socksProxyAddr, socksProxyPort, socksOutProxyAddr, socksOutProxyPort, localDestination); m_SocksProxy = new i2p::proxy::SOCKSProxy(socksProxyAddr, socksProxyPort, socksOutProxyAddr, socksOutProxyPort, localDestination);
m_SocksProxy->Start(); 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);
try {
m_SamBridge = new SAMBridge (samAddr, samPort); m_SamBridge = new SAMBridge (samAddr, samPort);
m_SamBridge->Start (); 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);
try {
m_BOBCommandChannel = new BOBCommandChannel (bobAddr, bobPort); m_BOBCommandChannel = new BOBCommandChannel (bobAddr, bobPort);
m_BOBCommandChannel->Start (); m_BOBCommandChannel->Start ();
} catch (std::exception& e) {
LogPrint(eLogError, "Clients: Exception in BOB bridge: ", e.what());
}
} }
m_AddressBook.StartResolvers (); m_AddressBook.StartResolvers ();

7
Daemon.h

@ -65,12 +65,17 @@ namespace i2p
bool start(); bool start();
bool stop(); bool stop();
; void run (); void run ();
private: private:
std::string pidfile; std::string pidfile;
int pidFH; int pidFH;
public:
int gracefullShutdownInterval; // in seconds
}; };
#endif #endif
} }

22
DaemonLinux.cpp

@ -12,6 +12,7 @@
#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)
{ {
@ -21,9 +22,18 @@ void handle_signal(int sig)
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 SIGINT:
if (i2p::context.AcceptsTunnels () && !Daemon.gracefullShutdownInterval)
{
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 SIGABRT:
case SIGTERM: case SIGTERM:
case SIGINT:
Daemon.running = 0; // Exit loop 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…
Cancel
Save