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: @@ -3,6 +3,7 @@ cache:
apt: true
os:
- linux
- osx
sudo: required
dist: trusty
addons:
@ -23,6 +24,11 @@ addons: @@ -23,6 +24,11 @@ addons:
- libssl-dev
compiler:
- 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:
matrix:
- BUILD_TYPE=Release UPNP=ON

16
ClientContext.cpp

@ -52,8 +52,12 @@ namespace client @@ -52,8 +52,12 @@ namespace client
LoadPrivateKeys (keys, httpProxyKeys);
localDestination = CreateNewLocalDestination (keys, false);
}
try {
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);
@ -70,8 +74,12 @@ namespace client @@ -70,8 +74,12 @@ namespace client
LoadPrivateKeys (keys, socksProxyKeys);
localDestination = CreateNewLocalDestination (keys, false);
}
try {
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
@ -83,8 +91,12 @@ namespace client @@ -83,8 +91,12 @@ namespace client
std::string samAddr; i2p::config::GetOption("sam.address", samAddr);
uint16_t samPort; i2p::config::GetOption("sam.port", samPort);
LogPrint(eLogInfo, "Clients: starting SAM bridge at ", samAddr, ":", samPort);
try {
m_SamBridge = new SAMBridge (samAddr, samPort);
m_SamBridge->Start ();
} catch (std::exception& e) {
LogPrint(eLogError, "Clients: Exception in SAM bridge: ", e.what());
}
}
// BOB
@ -93,8 +105,12 @@ namespace client @@ -93,8 +105,12 @@ namespace client
std::string bobAddr; i2p::config::GetOption("bob.address", bobAddr);
uint16_t bobPort; i2p::config::GetOption("bob.port", bobPort);
LogPrint(eLogInfo, "Clients: starting BOB command channel at ", bobAddr, ":", bobPort);
try {
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 ();

7
Daemon.h

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

22
DaemonLinux.cpp

@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
#include "Config.h"
#include "FS.h"
#include "Log.h"
#include "RouterContext.h"
void handle_signal(int sig)
{
@ -21,9 +22,18 @@ void handle_signal(int sig) @@ -21,9 +22,18 @@ void handle_signal(int sig)
LogPrint(eLogInfo, "Daemon: Got SIGHUP, reopening log...");
i2p::log::Logger().Reopen ();
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 SIGTERM:
case SIGINT:
Daemon.running = 0; // Exit loop
break;
}
@ -96,6 +106,7 @@ namespace i2p @@ -96,6 +106,7 @@ namespace i2p
return false;
}
}
gracefullShutdownInterval = 0; // not specified
// Signal handler
struct sigaction sa;
@ -122,6 +133,15 @@ namespace i2p @@ -122,6 +133,15 @@ namespace i2p
while (running)
{
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