Browse Source

Merge branch 'master' into web-ui

pull/251/head
EinMByte 10 years ago
parent
commit
3cc95c0df2
  1. 9
      ClientContext.cpp
  2. 1
      ClientContext.h
  3. 8
      HTTPServer.cpp
  4. 7
      README.md
  5. 3
      build/CMakeLists.txt
  6. 8
      tunnel/TunnelCrypto.cpp
  7. 15
      util/util.cpp
  8. 5
      util/util.h

9
ClientContext.cpp

@ -81,7 +81,7 @@ namespace client @@ -81,7 +81,7 @@ namespace client
if (eepKeys.length () > 0) // eepkeys file is presented
{
localDestination = LoadLocalDestination (eepKeys, true);
auto serverTunnel = new I2PServerTunnel (i2p::util::config::GetArg("-eephost", "127.0.0.1"),
auto serverTunnel = new I2PServerTunnel (i2p::util::config::GetArg("-eepaddress", "127.0.0.1"),
i2p::util::config::GetArg("-eepport", 80), localDestination);
serverTunnel->Start ();
m_ServerTunnels.insert (std::make_pair(localDestination->GetIdentHash (), std::unique_ptr<I2PServerTunnel>(serverTunnel)));
@ -280,13 +280,14 @@ namespace client @@ -280,13 +280,14 @@ namespace client
void ClientContext::ReadTunnels ()
{
boost::property_tree::ptree pt;
std::string pathTunnelsConfigFile = i2p::util::filesystem::GetTunnelsConfigFile().string();
try {
boost::property_tree::read_ini(
i2p::util::filesystem::GetFullPath(TUNNELS_CONFIG_FILENAME),
pathTunnelsConfigFile,
pt
);
} catch(const std::exception& ex) {
LogPrint(eLogWarning, "Can't read ", TUNNELS_CONFIG_FILENAME, ": ", ex.what ());
LogPrint(eLogWarning, "Can't read ", pathTunnelsConfigFile, ": ", ex.what ());
return;
}
@ -349,7 +350,7 @@ namespace client @@ -349,7 +350,7 @@ namespace client
LogPrint (eLogError, "I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists");
numServerTunnels++;
} else
LogPrint (eLogWarning, "Unknown section type=", type, " of ", name, " in ", TUNNELS_CONFIG_FILENAME);
LogPrint (eLogWarning, "Unknown section type=", type, " of ", name, " in ", pathTunnelsConfigFile);
} catch (const std::exception& ex) {
LogPrint (eLogError, "Can't read tunnel ", name, " params: ", ex.what ());

1
ClientContext.h

@ -31,7 +31,6 @@ namespace client @@ -31,7 +31,6 @@ namespace client
const char I2P_SERVER_TUNNEL_KEYS[] = "keys";
const char I2P_SERVER_TUNNEL_INPORT[] = "inport";
const char I2P_SERVER_TUNNEL_ACCESS_LIST[] = "accesslist";
const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg";
class ClientContext
{

8
HTTPServer.cpp

@ -518,15 +518,7 @@ namespace util @@ -518,15 +518,7 @@ namespace util
void HTTPConnection::Terminate ()
{
if (!m_Stream) return;
m_Socket->close ();
m_Stream->Close ();
m_Socket->get_io_service ().post ([=](void)
{
m_Stream.reset ();
m_Stream = nullptr;
});
}
void HTTPConnection::Receive ()

7
README.md

@ -98,20 +98,21 @@ Cmdline options @@ -98,20 +98,21 @@ Cmdline options
* --socksproxyaddress= - The address to listen on (SOCKS Proxy)
* --proxykeys= - optional keys file for proxy's local destination
* --ircport= - The local port of IRC tunnel to listen on. 6668 by default
* --irchost= - The adddress of IRC tunnel to listen on, 127.0.0.1 by default
* --ircaddress= - The adddress of IRC tunnel to listen on, 127.0.0.1 by default
* --ircdest= - I2P destination address of IRC server. For example irc.postman.i2p
* --irckeys= - optional keys file for tunnel's local destination
* --eepkeys= - File name containing destination keys, for example privKeys.dat.
The file will be created if it does not already exist (issue #110).
* --eephost= - Address incoming trafic forward to. 127.0.0.1 by default
* --eepaddress= - Address incoming trafic forward to. 127.0.0.1 by default
* --eepport= - Port incoming trafic forward to. 80 by default
* --samport= - Port of SAM bridge. Usually 7656. SAM is off if not specified
* --samhost= - Address of SAM bridge, 127.0.0.1 by default (only used if SAM is on)
* --samaddress= - Address of SAM bridge, 127.0.0.1 by default (only used if SAM is on)
* --bobport= - Port of BOB command channel. Usually 2827. BOB is off if not specified
* --bobaddress= - Address of BOB service, 127.0.0.1 by default (only used if BOB is on)
* --i2pcontrolport= - Port of I2P control service. Usually 7650. I2PControl is off if not specified
* --i2pcontroladdress= - Address of I2P control service, 127.0.0.1 by default (only used if I2PControl is on)
* --i2pcontrolpassword= - I2P control service password, "itoopie" by default
* --tunnelscfg= - Tunnels Config file (default: ~/.i2pd/tunnels.cfg or /var/lib/i2pd/tunnels.cfg)
* --conf= - Config file (default: ~/.i2pd/i2p.conf or /var/lib/i2pd/i2p.conf)
This parameter will be silently ignored if the specified config file does not exist.
Options specified on the command line take precedence over those in the config file.

3
build/CMakeLists.txt

@ -62,7 +62,8 @@ set (DAEMON_SRC @@ -62,7 +62,8 @@ set (DAEMON_SRC
"${CMAKE_SOURCE_DIR}/HTTPProxy.cpp"
"${CMAKE_SOURCE_DIR}/HTTPServer.cpp"
"${CMAKE_SOURCE_DIR}/I2PService.cpp"
"${CMAKE_SOURCE_DIR}/I2PControl.cpp"
"${CMAKE_SOURCE_DIR}/i2pcontrol/I2PControl.cpp"
"${CMAKE_SOURCE_DIR}/i2pcontrol/I2PControlServer.cpp"
"${CMAKE_SOURCE_DIR}/I2PTunnel.cpp"
"${CMAKE_SOURCE_DIR}/SAM.cpp"
"${CMAKE_SOURCE_DIR}/SOCKS.cpp"

8
tunnel/TunnelCrypto.cpp

@ -40,10 +40,10 @@ void TunnelEncryption::Encrypt (const uint8_t * in, uint8_t * out) @@ -40,10 +40,10 @@ void TunnelEncryption::Encrypt (const uint8_t * in, uint8_t * out)
: "%xmm0", "%xmm1", "cc", "memory"
);
#else
m_IVEncryption.Encrypt ((const ChipherBlock *)in, (ChipherBlock *)out); // iv
m_IVEncryption.Encrypt ((const CipherBlock *)in, (CipherBlock *)out); // iv
m_LayerEncryption.SetIV (out);
m_LayerEncryption.Encrypt (in + 16, i2p::tunnel::TUNNEL_DATA_ENCRYPTED_SIZE, out + 16); // data
m_IVEncryption.Encrypt ((ChipherBlock *)out, (ChipherBlock *)out); // double iv
m_IVEncryption.Encrypt ((CipherBlock *)out, (CipherBlock *)out); // double iv
#endif
}
@ -77,10 +77,10 @@ void TunnelDecryption::Decrypt (const uint8_t * in, uint8_t * out) @@ -77,10 +77,10 @@ void TunnelDecryption::Decrypt (const uint8_t * in, uint8_t * out)
: "%xmm0", "%xmm1", "%xmm2", "cc", "memory"
);
#else
m_IVDecryption.Decrypt ((const ChipherBlock *)in, (ChipherBlock *)out); // iv
m_IVDecryption.Decrypt ((const CipherBlock *)in, (CipherBlock *)out); // iv
m_LayerDecryption.SetIV (out);
m_LayerDecryption.Decrypt (in + 16, i2p::tunnel::TUNNEL_DATA_ENCRYPTED_SIZE, out + 16); // data
m_IVDecryption.Decrypt ((ChipherBlock *)out, (ChipherBlock *)out); // double iv
m_IVDecryption.Decrypt ((CipherBlock *)out, (CipherBlock *)out); // double iv
#endif
}

15
util/util.cpp

@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
#include "util.h"
#include "Log.h"
#if defined(__linux__) || defined(__FreeBSD_kernel__)
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
#include <sys/types.h>
#include <ifaddrs.h>
#elif defined(WIN32)
@ -185,6 +185,14 @@ namespace filesystem @@ -185,6 +185,14 @@ namespace filesystem
return pathConfigFile;
}
boost::filesystem::path GetTunnelsConfigFile()
{
boost::filesystem::path pathTunnelsConfigFile(i2p::util::config::GetArg("-tunnelscfg", "tunnels.cfg"));
if(!pathTunnelsConfigFile.is_complete())
pathTunnelsConfigFile = GetDataDir() / pathTunnelsConfigFile;
return pathTunnelsConfigFile;
}
boost::filesystem::path GetDefaultDataDir()
{
// Windows < Vista: C:\Documents and Settings\Username\Application Data\i2pd
@ -455,7 +463,7 @@ namespace http @@ -455,7 +463,7 @@ namespace http
namespace net {
#if defined(__linux__) || defined(__FreeBSD_kernel__)
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
int GetMTUUnix(const boost::asio::ip::address& localAddress, int fallback)
{
@ -655,11 +663,12 @@ namespace net { @@ -655,11 +663,12 @@ namespace net {
{
const int fallback = 576; // fallback MTU
#if defined(__linux__) || defined(__FreeBSD_kernel__)
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
return GetMTUUnix(localAddress, fallback);
#elif defined(WIN32)
return GetMTUWindows(localAddress, fallback);
#endif
return fallback;
}
}

5
util/util.h

@ -70,6 +70,11 @@ namespace util @@ -70,6 +70,11 @@ namespace util
*/
boost::filesystem::path GetConfigFile();
/**
* @return the path of the tunnels configuration file
*/
boost::filesystem::path GetTunnelsConfigFile();
/**
* @return the default directory for i2pd data
*/

Loading…
Cancel
Save