From 12dd8a394d801bfea5a733224cb10c14c1ec5635 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Sun, 2 Aug 2015 23:18:55 +0200 Subject: [PATCH 1/5] Fix building without AESNI. --- build/CMakeLists.txt | 3 ++- tunnel/TunnelCrypto.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index f7f85a16..59fe111b 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -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/I2PServer.cpp" "${CMAKE_SOURCE_DIR}/I2PTunnel.cpp" "${CMAKE_SOURCE_DIR}/SAM.cpp" "${CMAKE_SOURCE_DIR}/SOCKS.cpp" diff --git a/tunnel/TunnelCrypto.cpp b/tunnel/TunnelCrypto.cpp index 834be06d..e24f6997 100644 --- a/tunnel/TunnelCrypto.cpp +++ b/tunnel/TunnelCrypto.cpp @@ -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) : "%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 } From 2db3fe36d11a4b9a8c591d54db2a4b2f7d0b3ef7 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Sun, 2 Aug 2015 23:22:13 +0200 Subject: [PATCH 2/5] Fix building with CMake (typo in commit 12dd8a3) --- build/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 59fe111b..875c745b 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -63,7 +63,7 @@ set (DAEMON_SRC "${CMAKE_SOURCE_DIR}/HTTPServer.cpp" "${CMAKE_SOURCE_DIR}/I2PService.cpp" "${CMAKE_SOURCE_DIR}/i2pcontrol/I2PControl.cpp" - "${CMAKE_SOURCE_DIR}/i2pcontrol/I2PServer.cpp" + "${CMAKE_SOURCE_DIR}/i2pcontrol/I2PControlServer.cpp" "${CMAKE_SOURCE_DIR}/I2PTunnel.cpp" "${CMAKE_SOURCE_DIR}/SAM.cpp" "${CMAKE_SOURCE_DIR}/SOCKS.cpp" From 56cb3004a7a19cd9c817491e12f2f8044230ead6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Tue, 11 Aug 2015 18:27:26 +0200 Subject: [PATCH 3/5] Use address instead of host in code and README.md --- ClientContext.cpp | 2 +- README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 9b4f7f17..7f8ba590 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -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(serverTunnel))); diff --git a/README.md b/README.md index df80c3b9..fd63c1f7 100644 --- a/README.md +++ b/README.md @@ -98,15 +98,15 @@ 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 From e57b6294ae3eb1bfcc23aa81c01adaf90ca646e3 Mon Sep 17 00:00:00 2001 From: tayler1 Date: Tue, 11 Aug 2015 22:36:35 +0300 Subject: [PATCH 4/5] Returning default mtu. Also mtu function for osx. --- util/util.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/util.cpp b/util/util.cpp index 39312acb..42bae817 100644 --- a/util/util.cpp +++ b/util/util.cpp @@ -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 #include #elif defined(WIN32) @@ -455,7 +455,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 +655,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; } } From 3d489a29962aef779af608b6cb311ec23552ed89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Tue, 11 Aug 2015 23:19:25 +0200 Subject: [PATCH 5/5] Make tunnels.cfg configurable --- ClientContext.cpp | 7 ++++--- ClientContext.h | 1 - README.md | 1 + util/util.cpp | 8 ++++++++ util/util.h | 5 +++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 7f8ba590..8c679299 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -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 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 ()); diff --git a/ClientContext.h b/ClientContext.h index b4d8b35a..33d1960f 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -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 { diff --git a/README.md b/README.md index fd63c1f7..afbd4522 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ Cmdline options * --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. diff --git a/util/util.cpp b/util/util.cpp index 39312acb..d37e764a 100644 --- a/util/util.cpp +++ b/util/util.cpp @@ -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 diff --git a/util/util.h b/util/util.h index 8ae7b863..29f68de5 100644 --- a/util/util.h +++ b/util/util.h @@ -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 */