Browse Source

Merge pull request #889 from PurpleI2P/openssl

recent changes
pull/1036/head
orignal 8 years ago committed by GitHub
parent
commit
36afef3498
  1. 8
      .gitignore
  2. 11
      ChangeLog
  3. 22
      Makefile
  4. 34
      Makefile.mingw
  5. 3
      README.md
  6. 0
      Win32/DaemonWin32.cpp
  7. 2
      Win32/Resource.rc2
  8. 14
      Win32/Win32App.cpp
  9. 4
      Win32/Win32Service.cpp
  10. 2
      Win32/i2pd.vcxproj
  11. 2
      Win32/i2pd.vcxproj.filters
  12. 2
      Win32/installer.iss
  13. 1
      android/.gitignore
  14. 5
      android/AndroidManifest.xml
  15. 1
      android/build.xml
  16. 62
      android/jni/Android.mk
  17. 11
      android/jni/Application.mk
  18. 3
      android/jni/DaemonAndroid.cpp
  19. 4
      android/jni/i2pd_android.cpp
  20. 1
      android/libs/.gitignore
  21. BIN
      android/libs/android-support-v4.jar
  22. 3
      android/src/org/purplei2p/i2pd/ForegroundService.java
  23. 2
      appveyor.yml
  24. 158
      build/CMakeLists.txt
  25. 5
      contrib/i2pd.conf
  26. 21
      contrib/rpm/i2pd.spec
  27. 18
      contrib/tunnels.conf
  28. 12
      daemon/Daemon.cpp
  29. 0
      daemon/Daemon.h
  30. 35
      daemon/HTTPServer.cpp
  31. 0
      daemon/HTTPServer.h
  32. 2
      daemon/I2PControl.cpp
  33. 0
      daemon/I2PControl.h
  34. 2
      daemon/UPnP.cpp
  35. 0
      daemon/UPnP.h
  36. 0
      daemon/UnixDaemon.cpp
  37. 0
      daemon/i2pd.cpp
  38. 11
      debian/changelog
  39. 4
      debian/control
  40. 32
      filelist.mk
  41. 0
      libi2pd/Base.cpp
  42. 0
      libi2pd/Base.h
  43. 0
      libi2pd/BloomFilter.cpp
  44. 0
      libi2pd/BloomFilter.h
  45. 8
      libi2pd/Config.cpp
  46. 0
      libi2pd/Config.h
  47. 0
      libi2pd/Crypto.cpp
  48. 0
      libi2pd/Crypto.h
  49. 0
      libi2pd/Datagram.cpp
  50. 0
      libi2pd/Datagram.h
  51. 2
      libi2pd/Destination.cpp
  52. 2
      libi2pd/Destination.h
  53. 0
      libi2pd/Event.cpp
  54. 0
      libi2pd/Event.h
  55. 0
      libi2pd/FS.cpp
  56. 0
      libi2pd/FS.h
  57. 0
      libi2pd/Family.cpp
  58. 0
      libi2pd/Family.h
  59. 0
      libi2pd/Garlic.cpp
  60. 0
      libi2pd/Garlic.h
  61. 3
      libi2pd/Gost.cpp
  62. 0
      libi2pd/Gost.h
  63. 0
      libi2pd/Gzip.cpp
  64. 0
      libi2pd/Gzip.h
  65. 0
      libi2pd/HTTP.cpp
  66. 0
      libi2pd/HTTP.h
  67. 5
      libi2pd/I2NPProtocol.cpp
  68. 0
      libi2pd/I2NPProtocol.h
  69. 0
      libi2pd/I2PEndian.cpp
  70. 0
      libi2pd/I2PEndian.h
  71. 0
      libi2pd/Identity.cpp
  72. 0
      libi2pd/Identity.h
  73. 2
      libi2pd/LeaseSet.cpp
  74. 0
      libi2pd/LeaseSet.h
  75. 0
      libi2pd/LittleBigEndian.h
  76. 0
      libi2pd/Log.cpp
  77. 0
      libi2pd/Log.h
  78. 268
      libi2pd/NTCPSession.cpp
  79. 30
      libi2pd/NTCPSession.h
  80. 2
      libi2pd/NetDb.cpp
  81. 2
      libi2pd/NetDb.hpp
  82. 2
      libi2pd/NetDbRequests.cpp
  83. 0
      libi2pd/NetDbRequests.h
  84. 0
      libi2pd/Profiling.cpp
  85. 0
      libi2pd/Profiling.h
  86. 0
      libi2pd/Queue.h
  87. 2
      libi2pd/Reseed.cpp
  88. 0
      libi2pd/Reseed.h
  89. 13
      libi2pd/RouterContext.cpp
  90. 5
      libi2pd/RouterContext.h
  91. 16
      libi2pd/RouterInfo.cpp
  92. 2
      libi2pd/RouterInfo.h
  93. 2
      libi2pd/SSU.cpp
  94. 0
      libi2pd/SSU.h
  95. 2
      libi2pd/SSUData.cpp
  96. 0
      libi2pd/SSUData.h
  97. 2
      libi2pd/SSUSession.cpp
  98. 0
      libi2pd/SSUSession.h
  99. 0
      libi2pd/Signature.cpp
  100. 0
      libi2pd/Signature.h
  101. Some files were not shown because too many files have changed in this diff Show More

8
.gitignore vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
# i2pd
obj/*.o
*.o
router.info
router.keys
i2p
@ -249,3 +249,9 @@ docs/generated @@ -249,3 +249,9 @@ docs/generated
# gdb files
.gdb_history
# cmake makefile
build/Makefile
# debian stuff
.pc/

11
ChangeLog

@ -1,6 +1,17 @@ @@ -1,6 +1,17 @@
# for this file format description,
# see https://github.com/olivierlacan/keep-a-changelog
## [2.14.0] - 2017-06-01
### Added
- Transit traffic bandwidth limitation
- NTCP connections through HTTP and SOCKS proxies
- Ability to disable address helper for HTTP proxy
### Changed
- Reseed servers list
- Minimal required version is 4.0 for Android
### Fixed
- Ignore comments in addressbook feed
## [2.13.0] - 2017-04-06
### Added
- Persist local destination's tags

22
Makefile

@ -7,6 +7,10 @@ I2PD := i2pd @@ -7,6 +7,10 @@ I2PD := i2pd
GREP := grep
DEPS := obj/make.dep
LIB_SRC_DIR := libi2pd
LIB_CLIENT_SRC_DIR := libi2pd_client
DAEMON_SRC_DIR := daemon
include filelist.mk
USE_AESNI := yes
@ -17,24 +21,23 @@ USE_UPNP := no @@ -17,24 +21,23 @@ USE_UPNP := no
ifeq ($(WEBSOCKETS),1)
NEEDED_CXXFLAGS += -DWITH_EVENTS
DAEMON_SRC += Websocket.cpp
endif
ifeq ($(UNAME),Darwin)
DAEMON_SRC += DaemonLinux.cpp
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
ifeq ($(HOMEBREW),1)
include Makefile.homebrew
else
include Makefile.osx
endif
else ifeq ($(shell echo $(UNAME) | $(GREP) -Ec '(Free|Open)BSD'),1)
DAEMON_SRC += DaemonLinux.cpp
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
include Makefile.bsd
else ifeq ($(UNAME),Linux)
DAEMON_SRC += DaemonLinux.cpp
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
include Makefile.linux
else # win32 mingw
DAEMON_SRC += DaemonWin32.cpp Win32/Win32Service.cpp Win32/Win32App.cpp
else
DAEMON_SRC += Win32/DaemonWin32.cpp Win32/Win32Service.cpp Win32/Win32App.cpp
include Makefile.mingw
endif
@ -42,11 +45,16 @@ ifeq ($(USE_MESHNET),yes) @@ -42,11 +45,16 @@ ifeq ($(USE_MESHNET),yes)
NEEDED_CXXFLAGS += -DMESHNET
endif
NEEDED_CXXFLAGS += -I$(LIB_SRC_DIR) -I$(LIB_CLIENT_SRC_DIR)
all: mk_obj_dir $(ARLIB) $(ARLIB_CLIENT) $(I2PD)
mk_obj_dir:
@mkdir -p obj
@mkdir -p obj/Win32
@mkdir -p obj/$(LIB_SRC_DIR)
@mkdir -p obj/$(LIB_CLIENT_SRC_DIR)
@mkdir -p obj/$(DAEMON_SRC_DIR)
api: mk_obj_dir $(SHLIB) $(ARLIB)
api_client: mk_obj_dir $(SHLIB) $(ARLIB) $(SHLIB_CLIENT) $(ARLIB_CLIENT)
@ -70,7 +78,7 @@ obj/%.o: %.cpp @@ -70,7 +78,7 @@ obj/%.o: %.cpp
DAEMON_OBJS += $(patsubst %.cpp,obj/%.o,$(DAEMON_SRC))
$(I2PD): $(DAEMON_OBJS) $(ARLIB) $(ARLIB_CLIENT)
$(CXX) -o $@ $^ $(LDLIBS) $(LDFLAGS)
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS)
$(SHLIB): $(patsubst %.cpp,obj/%.o,$(LIB_SRC))
ifneq ($(USE_STATIC),yes)

34
Makefile.mingw

@ -4,31 +4,29 @@ WINDRES = windres @@ -4,31 +4,29 @@ WINDRES = windres
CXXFLAGS = -Os -D_MT -DWIN32 -D_WINDOWS -DWIN32_LEAN_AND_MEAN
NEEDED_CXXFLAGS = -std=c++11
BOOST_SUFFIX = -mt
INCFLAGS = -I/usr/include/ -I/usr/local/include/
LDFLAGS = -Wl,-rpath,/usr/local/lib \
-L/usr/local/lib
INCFLAGS = -I/usr/include/ -I/usr/local/include/ -I. -Idaemon
LDFLAGS = -Wl,-rpath,/usr/local/lib -Wl,-Bstatic -static-libgcc -static-libstdc++ -L/usr/local/lib
# UPNP Support
ifeq ($(USE_UPNP),yes)
CXXFLAGS += -DUSE_UPNP -DMINIUPNP_STATICLIB
LDLIBS = -Wl,-Bstatic -lminiupnpc
LDLIBS = -lminiupnpc
endif
LDLIBS += \
-Wl,-Bstatic -lboost_system$(BOOST_SUFFIX) \
-Wl,-Bstatic -lboost_date_time$(BOOST_SUFFIX) \
-Wl,-Bstatic -lboost_filesystem$(BOOST_SUFFIX) \
-Wl,-Bstatic -lboost_program_options$(BOOST_SUFFIX) \
-Wl,-Bstatic -lssl \
-Wl,-Bstatic -lcrypto \
-Wl,-Bstatic -lz \
-Wl,-Bstatic -lwsock32 \
-Wl,-Bstatic -lws2_32 \
-Wl,-Bstatic -lgdi32 \
-Wl,-Bstatic -liphlpapi \
-static-libgcc -static-libstdc++ \
-Wl,-Bstatic -lstdc++ \
-Wl,-Bstatic -lpthread
-lboost_system$(BOOST_SUFFIX) \
-lboost_date_time$(BOOST_SUFFIX) \
-lboost_filesystem$(BOOST_SUFFIX) \
-lboost_program_options$(BOOST_SUFFIX) \
-lssl \
-lcrypto \
-lz \
-lwsock32 \
-lws2_32 \
-lgdi32 \
-liphlpapi \
-lstdc++ \
-lpthread
ifeq ($(USE_WIN32_APP), yes)
CXXFLAGS += -DWIN32_APP

3
README.md

@ -65,8 +65,9 @@ BTC: 1K7Ds6KUeR8ya287UC4rYTjvC96vXyZbDY @@ -65,8 +65,9 @@ BTC: 1K7Ds6KUeR8ya287UC4rYTjvC96vXyZbDY
ZEC: t1cTckLuXsr1dwVrK4NDzfhehss4NvMadAJ
DASH: Xw8YUrQpYzP9tZBmbjqxS3M97Q7v3vJKUF
LTC: LKQirrYrDeTuAPnpYq5y7LVKtywfkkHi59
ANC: AQJYweYYUqM1nVfLqfoSMpUMfzxvS4Xd7z
DOGE: DNXLQKziRPAsD9H3DFNjk4fLQrdaSX893Y
ANC: AQJYweYYUqM1nVfLqfoSMpUMfzxvS4Xd7z
GST: GbD2JSQHBHCKLa9WTHmigJRpyFgmBj4woG
License
-------

0
DaemonWin32.cpp → Win32/DaemonWin32.cpp

2
Win32/Resource.rc2

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
#include "../version.h"
#include "../libi2pd/version.h"
/////////////////////////////////////////////////////////////////////////////
//

14
Win32/Win32App.cpp

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
#include <string.h>
#include <windows.h>
#include <shellapi.h>
#include "../ClientContext.h"
#include "../Config.h"
#include "../NetDb.h"
#include "../RouterContext.h"
#include "../Transports.h"
#include "../Tunnel.h"
#include "../version.h"
#include "ClientContext.h"
#include "Config.h"
#include "NetDb.hpp"
#include "RouterContext.h"
#include "Transports.h"
#include "Tunnel.h"
#include "version.h"
#include "resource.h"
#include "Win32App.h"
#include <stdio.h>

4
Win32/Win32Service.cpp

@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
#include <strsafe.h>
#include <windows.h>
#include "../Daemon.h"
#include "../Log.h"
#include "Daemon.h"
#include "Log.h"
I2PService *I2PService::s_service = NULL;

2
Win32/i2pd.vcxproj

@ -83,7 +83,7 @@ @@ -83,7 +83,7 @@
<ClInclude Include="..\LittleBigEndian.h" />
<ClInclude Include="..\Log.h" />
<ClInclude Include="..\NetDbRequests.h" />
<ClInclude Include="..\NetDb.h" />
<ClInclude Include="..\NetDb.hpp" />
<ClInclude Include="..\NTCPSession.h" />
<ClInclude Include="..\Queue.h" />
<ClInclude Include="..\Profiling.h" />

2
Win32/i2pd.vcxproj.filters

@ -158,7 +158,7 @@ @@ -158,7 +158,7 @@
<ClInclude Include="..\Log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NetDb.h">
<ClInclude Include="..\NetDb.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NTCPSession.h">

2
Win32/installer.iss

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#define I2Pd_AppName "i2pd"
#define I2Pd_ver "2.13.0"
#define I2Pd_ver "2.14.0"
#define I2Pd_Publisher "PurpleI2P"
[Setup]

1
android/.gitignore vendored

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
gen
tests
.idea
ant.properties
local.properties
build.sh
bin

5
android/AndroidManifest.xml

@ -2,8 +2,9 @@ @@ -2,8 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.purplei2p.i2pd"
android:versionCode="1"
android:versionName="2.13.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="24"/>
android:versionName="2.14.0"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

1
android/build.xml

@ -93,5 +93,4 @@ @@ -93,5 +93,4 @@
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

62
android/jni/Android.mk

@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir) @@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := i2pd
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_C_INCLUDES += $(IFADDRS_PATH) ../..
LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(DAEMON_SRC_PATH)
LOCAL_STATIC_LIBRARIES := \
boost_system \
boost_date_time \
@ -12,59 +12,13 @@ LOCAL_STATIC_LIBRARIES := \ @@ -12,59 +12,13 @@ LOCAL_STATIC_LIBRARIES := \
miniupnpc
LOCAL_LDLIBS := -lz
LOCAL_SRC_FILES := DaemonAndroid.cpp i2pd_android.cpp \
$(IFADDRS_PATH)/ifaddrs.c \
../../HTTPServer.cpp ../../I2PControl.cpp ../../Daemon.cpp ../../Config.cpp \
../../AddressBook.cpp \
../../api.cpp \
../../Base.cpp \
../../BOB.cpp \
../../ClientContext.cpp \
../../Crypto.cpp \
../../Datagram.cpp \
../../Destination.cpp \
../../Family.cpp \
../../FS.cpp \
../../Garlic.cpp \
../../Gzip.cpp \
../../HTTP.cpp \
../../HTTPProxy.cpp \
../../I2CP.cpp \
../../I2NPProtocol.cpp \
../../I2PEndian.cpp \
../../I2PService.cpp \
../../I2PTunnel.cpp \
../../Identity.cpp \
../../LeaseSet.cpp \
../../Log.cpp \
../../NetDb.cpp \
../../NetDbRequests.cpp \
../../NTCPSession.cpp \
../../Profiling.cpp \
../../Reseed.cpp \
../../RouterContext.cpp \
../../RouterInfo.cpp \
../../SAM.cpp \
../../Signature.cpp \
../../SOCKS.cpp \
../../SSU.cpp \
../../SSUData.cpp \
../../SSUSession.cpp \
../../Streaming.cpp \
../../TransitTunnel.cpp \
../../Transports.cpp \
../../Tunnel.cpp \
../../TunnelEndpoint.cpp \
../../TunnelGateway.cpp \
../../TunnelPool.cpp \
../../Timestamp.cpp \
../../Event.cpp \
../../Gost.cpp \
../../WebSocks.cpp \
../../BloomFilter.cpp \
../../MatchedDestination.cpp \
../../util.cpp \
../../i2pd.cpp ../../UPnP.cpp
LOCAL_SRC_FILES := DaemonAndroid.cpp i2pd_android.cpp $(IFADDRS_PATH)/ifaddrs.c \
$(wildcard $(LIB_SRC_PATH)/*.cpp)\
$(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp)\
$(DAEMON_SRC_PATH)/Daemon.cpp \
$(DAEMON_SRC_PATH)/UPnP.cpp \
$(DAEMON_SRC_PATH)/HTTPServer.cpp \
$(DAEMON_SRC_PATH)/I2PControl.cpp
include $(BUILD_SHARED_LIBRARY)

11
android/jni/Application.mk

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#APP_ABI := x86
APP_ABI := armeabi-v7a
#can be android-3 but will fail for x86 since arch-x86 is not present at ndkroot/platforms/android-3/ . libz is taken from there.
APP_PLATFORM := android-9
APP_PLATFORM := android-14
# http://stackoverflow.com/a/21386866/529442 http://stackoverflow.com/a/15616255/529442 to enable c++11 support in Eclipse
NDK_TOOLCHAIN_VERSION := 4.9
@ -25,8 +25,15 @@ APP_OPTIM := debug @@ -25,8 +25,15 @@ APP_OPTIM := debug
# git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git
# git clone https://github.com/PurpleI2P/android-ifaddrs.git
# change to your own
I2PD_LIBS_PATH=/path/to/libraries
I2PD_LIBS_PATH = /path/to/libraries
BOOST_PATH = $(I2PD_LIBS_PATH)/Boost-for-Android-Prebuilt
OPENSSL_PATH = $(I2PD_LIBS_PATH)/OpenSSL-for-Android-Prebuilt
MINIUPNP_PATH = $(I2PD_LIBS_PATH)/MiniUPnP-for-Android-Prebuilt
IFADDRS_PATH = $(I2PD_LIBS_PATH)/android-ifaddrs
# don't change me
I2PD_SRC_PATH = $(PWD)/..
LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd
LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client
DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon

3
android/jni/DaemonAndroid.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#include "DaemonAndroid.h"
#include "../../Daemon.h"
#include "Daemon.h"
#include <iostream>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception_ptr.hpp>
@ -191,4 +191,3 @@ namespace android @@ -191,4 +191,3 @@ namespace android
}
}
}

4
android/jni/i2pd_android.cpp

@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
#include <jni.h>
#include "org_purplei2p_i2pd_I2PD_JNI.h"
#include "DaemonAndroid.h"
#include "../../RouterContext.h"
#include "../../Transports.h"
#include "RouterContext.h"
#include "Transports.h"
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
(JNIEnv * env, jclass clazz) {

1
android/libs/.gitignore vendored

@ -1 +0,0 @@ @@ -1 +0,0 @@
armeabi-v7a

BIN
android/libs/android-support-v4.jar

Binary file not shown.

3
android/src/org/purplei2p/i2pd/ForegroundService.java

@ -6,7 +6,6 @@ import android.app.Service; @@ -6,7 +6,6 @@ import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class ForegroundService extends Service {
@ -72,7 +71,7 @@ public class ForegroundService extends Service { @@ -72,7 +71,7 @@ public class ForegroundService extends Service {
new Intent(this, I2PD.class), 0);
// Set the info for the views that show in the notification panel.
Notification notification = new NotificationCompat.Builder(this)
Notification notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.itoopie_notification_icon) // the status icon
.setTicker(text) // the status text
.setWhen(System.currentTimeMillis()) // the time stamp

2
appveyor.yml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
version: 2.13.{build}
version: 2.14.{build}
pull_requests:
do_not_increment_build_number: true
branches:

158
build/CMakeLists.txt

@ -8,6 +8,7 @@ project ( "i2pd" ) @@ -8,6 +8,7 @@ project ( "i2pd" )
# configurale options
option(WITH_AESNI "Use AES-NI instructions set" OFF)
option(WITH_AVX "Use AVX instructions" OFF)
option(WITH_HARDENING "Use hardening compiler flags" OFF)
option(WITH_LIBRARY "Build library" ON)
option(WITH_BINARY "Build binary" ON)
@ -25,44 +26,51 @@ option(WITH_WEBSOCKETS "Build with websocket ui" OFF) @@ -25,44 +26,51 @@ option(WITH_WEBSOCKETS "Build with websocket ui" OFF)
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
set ( CMAKE_SOURCE_DIR ".." )
set(LIBI2PD_SRC_DIR ../libi2pd)
set(LIBI2PD_CLIENT_SRC_DIR ../libi2pd_client)
include_directories(${LIBI2PD_SRC_DIR})
include_directories(${LIBI2PD_CLIENT_SRC_DIR})
set (LIBI2PD_SRC
"${CMAKE_SOURCE_DIR}/BloomFilter.cpp"
"${CMAKE_SOURCE_DIR}/Config.cpp"
"${CMAKE_SOURCE_DIR}/Crypto.cpp"
"${CMAKE_SOURCE_DIR}/Garlic.cpp"
"${CMAKE_SOURCE_DIR}/Gzip.cpp"
"${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp"
"${CMAKE_SOURCE_DIR}/Identity.cpp"
"${CMAKE_SOURCE_DIR}/LeaseSet.cpp"
"${CMAKE_SOURCE_DIR}/FS.cpp"
"${CMAKE_SOURCE_DIR}/Log.cpp"
"${CMAKE_SOURCE_DIR}/NTCPSession.cpp"
"${CMAKE_SOURCE_DIR}/NetDbRequests.cpp"
"${CMAKE_SOURCE_DIR}/NetDb.cpp"
"${CMAKE_SOURCE_DIR}/Profiling.cpp"
"${CMAKE_SOURCE_DIR}/Reseed.cpp"
"${CMAKE_SOURCE_DIR}/RouterContext.cpp"
"${CMAKE_SOURCE_DIR}/RouterInfo.cpp"
"${CMAKE_SOURCE_DIR}/SSU.cpp"
"${CMAKE_SOURCE_DIR}/SSUData.cpp"
"${CMAKE_SOURCE_DIR}/SSUSession.cpp"
"${CMAKE_SOURCE_DIR}/Streaming.cpp"
"${CMAKE_SOURCE_DIR}/Destination.cpp"
"${CMAKE_SOURCE_DIR}/TransitTunnel.cpp"
"${CMAKE_SOURCE_DIR}/Tunnel.cpp"
"${CMAKE_SOURCE_DIR}/TunnelGateway.cpp"
"${CMAKE_SOURCE_DIR}/Transports.cpp"
"${CMAKE_SOURCE_DIR}/TunnelEndpoint.cpp"
"${CMAKE_SOURCE_DIR}/TunnelPool.cpp"
"${CMAKE_SOURCE_DIR}/Base.cpp"
"${CMAKE_SOURCE_DIR}/util.cpp"
"${CMAKE_SOURCE_DIR}/Datagram.cpp"
"${CMAKE_SOURCE_DIR}/Family.cpp"
"${CMAKE_SOURCE_DIR}/Signature.cpp"
"${CMAKE_SOURCE_DIR}/Timestamp.cpp"
"${CMAKE_SOURCE_DIR}/api.cpp"
"${CMAKE_SOURCE_DIR}/Event.cpp"
"${CMAKE_SOURCE_DIR}/Gost.cpp"
"${LIBI2PD_SRC_DIR}/BloomFilter.cpp"
"${LIBI2PD_SRC_DIR}/Config.cpp"
"${LIBI2PD_SRC_DIR}/Crypto.cpp"
"${LIBI2PD_SRC_DIR}/Garlic.cpp"
"${LIBI2PD_SRC_DIR}/Gzip.cpp"
"${LIBI2PD_SRC_DIR}/HTTP.cpp"
"${LIBI2PD_SRC_DIR}/I2NPProtocol.cpp"
"${LIBI2PD_SRC_DIR}/Identity.cpp"
"${LIBI2PD_SRC_DIR}/LeaseSet.cpp"
"${LIBI2PD_SRC_DIR}/FS.cpp"
"${LIBI2PD_SRC_DIR}/Log.cpp"
"${LIBI2PD_SRC_DIR}/NTCPSession.cpp"
"${LIBI2PD_SRC_DIR}/NetDbRequests.cpp"
"${LIBI2PD_SRC_DIR}/NetDb.cpp"
"${LIBI2PD_SRC_DIR}/Profiling.cpp"
"${LIBI2PD_SRC_DIR}/Reseed.cpp"
"${LIBI2PD_SRC_DIR}/RouterContext.cpp"
"${LIBI2PD_SRC_DIR}/RouterInfo.cpp"
"${LIBI2PD_SRC_DIR}/SSU.cpp"
"${LIBI2PD_SRC_DIR}/SSUData.cpp"
"${LIBI2PD_SRC_DIR}/SSUSession.cpp"
"${LIBI2PD_SRC_DIR}/Streaming.cpp"
"${LIBI2PD_SRC_DIR}/Destination.cpp"
"${LIBI2PD_SRC_DIR}/TransitTunnel.cpp"
"${LIBI2PD_SRC_DIR}/Tunnel.cpp"
"${LIBI2PD_SRC_DIR}/TunnelGateway.cpp"
"${LIBI2PD_SRC_DIR}/Transports.cpp"
"${LIBI2PD_SRC_DIR}/TunnelEndpoint.cpp"
"${LIBI2PD_SRC_DIR}/TunnelPool.cpp"
"${LIBI2PD_SRC_DIR}/Base.cpp"
"${LIBI2PD_SRC_DIR}/util.cpp"
"${LIBI2PD_SRC_DIR}/Datagram.cpp"
"${LIBI2PD_SRC_DIR}/Family.cpp"
"${LIBI2PD_SRC_DIR}/Signature.cpp"
"${LIBI2PD_SRC_DIR}/Timestamp.cpp"
"${LIBI2PD_SRC_DIR}/api.cpp"
"${LIBI2PD_SRC_DIR}/Event.cpp"
"${LIBI2PD_SRC_DIR}/Gost.cpp"
)
if (WITH_WEBSOCKETS)
@ -89,31 +97,32 @@ install(TARGETS libi2pd @@ -89,31 +97,32 @@ install(TARGETS libi2pd
# install(EXPORT libi2pd DESTINATION ${CMAKE_INSTALL_LIBDIR})
set (CLIENT_SRC
"${CMAKE_SOURCE_DIR}/AddressBook.cpp"
"${CMAKE_SOURCE_DIR}/BOB.cpp"
"${CMAKE_SOURCE_DIR}/ClientContext.cpp"
"${CMAKE_SOURCE_DIR}/MatchedDestination.cpp"
"${CMAKE_SOURCE_DIR}/I2PTunnel.cpp"
"${CMAKE_SOURCE_DIR}/I2PService.cpp"
"${CMAKE_SOURCE_DIR}/SAM.cpp"
"${CMAKE_SOURCE_DIR}/SOCKS.cpp"
"${CMAKE_SOURCE_DIR}/HTTP.cpp"
"${CMAKE_SOURCE_DIR}/HTTPProxy.cpp"
"${CMAKE_SOURCE_DIR}/I2CP.cpp"
"${CMAKE_SOURCE_DIR}/WebSocks.cpp"
)
"${LIBI2PD_CLIENT_SRC_DIR}/AddressBook.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/BOB.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/ClientContext.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/MatchedDestination.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/I2PTunnel.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/I2PService.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/SAM.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/SOCKS.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/HTTPProxy.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/I2CP.cpp"
"${LIBI2PD_CLIENT_SRC_DIR}/WebSocks.cpp"
)
if(WITH_WEBSOCKETS)
list (APPEND CLIENT_SRC "${CMAKE_SOURCE_DIR}/Websocket.cpp")
list (APPEND CLIENT_SRC "${LIBI2PD_CLIENT_SRC_DIR}/Websocket.cpp")
endif ()
add_library(i2pdclient ${CLIENT_SRC})
set(DAEMON_SRC_DIR ../daemon)
set (DAEMON_SRC
"${CMAKE_SOURCE_DIR}/Daemon.cpp"
"${CMAKE_SOURCE_DIR}/HTTPServer.cpp"
"${CMAKE_SOURCE_DIR}/I2PControl.cpp"
"${CMAKE_SOURCE_DIR}/i2pd.cpp"
"${CMAKE_SOURCE_DIR}/UPnP.cpp"
"${DAEMON_SRC_DIR}/Daemon.cpp"
"${DAEMON_SRC_DIR}/HTTPServer.cpp"
"${DAEMON_SRC_DIR}/I2PControl.cpp"
"${DAEMON_SRC_DIR}/i2pd.cpp"
"${DAEMON_SRC_DIR}/UPnP.cpp"
)
if (WITH_MESHNET)
@ -178,22 +187,22 @@ endif () @@ -178,22 +187,22 @@ endif ()
# compiler flags customization (by system)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
list (APPEND DAEMON_SRC "${DAEMON_SRC_DIR}/UnixDaemon.cpp")
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8
add_definitions( "-D_GLIBCXX_USE_NANOSLEEP=1" )
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
list (APPEND DAEMON_SRC "${DAEMON_SRC_DIR}/UnixDaemon.cpp")
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8
add_definitions( "-D_GLIBCXX_USE_NANOSLEEP=1" )
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS)
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonWin32.cpp")
list (APPEND DAEMON_SRC "${DAEMON_SRC_DIR}/UnixDaemon.cpp")
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
list (APPEND DAEMON_SRC "${DAEMON_SRC_DIR}/UnixDaemon.cpp")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS)
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/DaemonWin32.cpp")
if (WITH_GUI)
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Win32App.cpp")
set_source_files_properties("${CMAKE_SOURCE_DIR}/DaemonWin32.cpp"
set_source_files_properties("${CMAKE_SOURCE_DIR}/Win32/DaemonWin32.cpp"
PROPERTIES COMPILE_DEFINITIONS WIN32_APP)
endif ()
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Win32Service.cpp")
@ -205,6 +214,10 @@ if (WITH_AESNI) @@ -205,6 +214,10 @@ if (WITH_AESNI)
add_definitions ( -DAESNI )
endif()
if (WITH_AVX)
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx" )
endif()
if (WITH_ADDRSANITIZER)
if (NOT MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
@ -275,7 +288,7 @@ endif () @@ -275,7 +288,7 @@ endif ()
if (WITH_PCH)
include_directories(BEFORE ${CMAKE_BINARY_DIR})
add_library(stdafx STATIC "${CMAKE_SOURCE_DIR}/stdafx.cpp")
add_library(stdafx STATIC "${LIBI2PD_SRC_DIR}/stdafx.cpp")
if(MSVC)
target_compile_options(stdafx PRIVATE /Ycstdafx.h /Zm155)
add_custom_command(TARGET stdafx POST_BUILD
@ -291,10 +304,10 @@ if (WITH_PCH) @@ -291,10 +304,10 @@ if (WITH_PCH)
get_directory_property(DEFS DEFINITIONS)
string(REPLACE " " ";" FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTU}} ${DEFS}")
add_custom_command(TARGET stdafx PRE_BUILD
COMMAND ${CMAKE_CXX_COMPILER} ${FLAGS} -c ${CMAKE_CURRENT_SOURCE_DIR}/../stdafx.h -o ${CMAKE_BINARY_DIR}/stdafx.h.gch
COMMAND ${CMAKE_CXX_COMPILER} ${FLAGS} -c ${CMAKE_CURRENT_SOURCE_DIR}/../libi2pd/stdafx.h -o ${CMAKE_BINARY_DIR}/stdafx.h.gch
)
target_compile_options(libi2pd PRIVATE -include stdafx.h)
target_compile_options(i2pdclient PRIVATE -include stdafx.h)
target_compile_options(libi2pd PRIVATE -include libi2pd/stdafx.h)
target_compile_options(i2pdclient PRIVATE -include libi2pd/stdafx.h)
endif()
target_link_libraries(libi2pd stdafx)
endif()
@ -371,6 +384,7 @@ message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}") @@ -371,6 +384,7 @@ message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}")
message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Options:")
message(STATUS " AESNI : ${WITH_AESNI}")
message(STATUS " AVX : ${WITH_AVX}")
message(STATUS " HARDENING : ${WITH_HARDENING}")
message(STATUS " LIBRARY : ${WITH_LIBRARY}")
message(STATUS " BINARY : ${WITH_BINARY}")
@ -402,7 +416,7 @@ if (WITH_BINARY) @@ -402,7 +416,7 @@ if (WITH_BINARY)
if (MSVC)
target_compile_options("${PROJECT_NAME}" PRIVATE /FIstdafx.h /Yustdafx.h /Zm155 "/Fp${CMAKE_BINARY_DIR}/stdafx.dir/$<CONFIG>/stdafx.pch")
else()
target_compile_options("${PROJECT_NAME}" PRIVATE -include stdafx.h)
target_compile_options("${PROJECT_NAME}" PRIVATE -include libi2pd/stdafx.h)
endif()
endif()
@ -453,7 +467,7 @@ install(FILES "C:/projects/openssl-$ENV{OPENSSL}/LICENSE" @@ -453,7 +467,7 @@ install(FILES "C:/projects/openssl-$ENV{OPENSSL}/LICENSE"
OPTIONAL # for local builds only!
)
file(GLOB_RECURSE I2PD_SOURCES "../*.cpp" "../build" "../Win32" "../Makefile*")
file(GLOB_RECURSE I2PD_SOURCES "../libi2pd/*.cpp" "../libi2pd_client/*.cpp" "../daemon/*.cpp" "../build" "../Win32" "../Makefile*")
install(FILES ${I2PD_SOURCES} DESTINATION src/ COMPONENT Source)
# install(DIRECTORY ../ DESTINATION src/
# # OPTIONAL
@ -462,7 +476,7 @@ install(FILES ${I2PD_SOURCES} DESTINATION src/ COMPONENT Source) @@ -462,7 +476,7 @@ install(FILES ${I2PD_SOURCES} DESTINATION src/ COMPONENT Source)
# PATTERN "*.cpp"
# )
file(GLOB I2PD_HEADERS "../*.h")
file(GLOB I2PD_HEADERS "../libi2pd/*.h" "../libi2pd_client/*.h" "../daemon/*.h")
install(FILES ${I2PD_HEADERS} DESTINATION src/ COMPONENT Headers)
# install(DIRECTORY ../ DESTINATION src/
# # OPTIONAL
@ -475,7 +489,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Purple I2P, a C++ I2P daemon") @@ -475,7 +489,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Purple I2P, a C++ I2P daemon")
set(CPACK_PACKAGE_VENDOR "Purple I2P")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
file(READ ../version.h version_h)
file(READ ../libi2pd/version.h version_h)
string(REGEX REPLACE ".*I2PD_VERSION_MAJOR ([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MAJOR "${version_h}")
string(REGEX REPLACE ".*I2PD_VERSION_MINOR ([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MINOR "${version_h}")
string(REGEX REPLACE ".*I2PD_VERSION_MICRO ([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MICRO "${version_h}")

5
contrib/i2pd.conf

@ -69,7 +69,8 @@ ipv6 = false @@ -69,7 +69,8 @@ ipv6 = false
## Default is X for floodfill, L for regular node
# bandwidth = L
## Router will not accept transit tunnels at startup
## Router will not accept transit tunnels, disabling transit traffic completely
## (default = false)
# notransit = true
## Router will be floodfill
@ -141,7 +142,7 @@ port = 4447 @@ -141,7 +142,7 @@ port = 4447
[sam]
## Uncomment and set to 'true' to enable SAM Bridge
# enabled = false
enabled = true
## Address and port service will listen on
# address = 127.0.0.1
# port = 7656

21
contrib/rpm/i2pd.spec

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
%define build_timestamp %(date +"%Y%m%d")
Name: i2pd
Version: 2.12.0
Version: 2.14.0
Release: %{build_timestamp}git%{?dist}
Summary: I2P router written in C++
@ -103,6 +103,23 @@ getent passwd i2pd >/dev/null || \ @@ -103,6 +103,23 @@ getent passwd i2pd >/dev/null || \
%changelog
* Thu Jun 01 2017 orignal <i2porignal@yandex.ru> - 2.14.0
- Added transit traffic bandwidth limitation
- Added NTCP connections through HTTP and SOCKS proxies
- Added ability to disable address helper for HTTP proxy
- Changed reseed servers list
* Thu Apr 06 2017 orignal <i2porignal@yandex.ru> - 2.13.0
- Added persist local destination's tags
- Added GOST signature types 9 and 10
- Added exploratory tunnels configuration
- Changed reseed servers list
- Changed inactive NTCP sockets get closed faster
- Changed some EdDSA speed up
- Fixed multiple acceptors for SAM
- Fixed follow on data after STREAM CREATE for SAM
- Fixed memory leaks
* Tue Feb 14 2017 orignal <i2porignal@yandex.ru> - 2.12.0
- Additional HTTP and SOCKS proxy tunnels
- Reseed from ZIP archive
@ -120,7 +137,7 @@ getent passwd i2pd >/dev/null || \ @@ -120,7 +137,7 @@ getent passwd i2pd >/dev/null || \
- Fixed UPnP discovery bug, producing excessive CPU usage
- Handle multiple lookups of the same LeaseSet correctly
* Tue Oct 20 2016 Anatolii Vorona <vorona.tolik@gmail.com> - 2.10.0-3
* Thu Oct 20 2016 Anatolii Vorona <vorona.tolik@gmail.com> - 2.10.0-3
- add support C7
- move rpm-related files to contrib folder

18
contrib/tunnels.conf

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
[IRC]
[IRC-IRC2P]
type = client
address = 127.0.0.1
port = 6668
@ -6,6 +6,14 @@ destination = irc.postman.i2p @@ -6,6 +6,14 @@ destination = irc.postman.i2p
destinationport = 6667
keys = irc-keys.dat
#[IRC-ILITA]
#type = client
#address = 127.0.0.1
#port = 6669
#destination = irc.ilita.i2p
#destinationport = 6667
#keys = irc-keys.dat
#[SMTP]
#type = client
#address = 127.0.0.1
@ -22,12 +30,4 @@ keys = irc-keys.dat @@ -22,12 +30,4 @@ keys = irc-keys.dat
#destinationport = 110
#keys = pop3-keys.dat
#[MTN]
#type = client
#address = 127.0.0.1
#port = 8998
#destination = mtn.i2p-projekt.i2p
#destinationport = 4691
#keys = mtn-keys.dat
# see more examples in /usr/share/doc/i2pd/configuration.md.gz

12
Daemon.cpp → daemon/Daemon.cpp

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
#include "RouterContext.h"
#include "Tunnel.h"
#include "HTTP.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "Garlic.h"
#include "Streaming.h"
#include "Destination.h"
@ -115,6 +115,12 @@ namespace i2p @@ -115,6 +115,12 @@ namespace i2p
}
LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
#ifdef AESNI
LogPrint(eLogInfo, "AESNI enabled");
#endif
#if defined(__AVX__)
LogPrint(eLogInfo, "AVX enabled");
#endif
LogPrint(eLogDebug, "FS: main config file: ", config);
LogPrint(eLogDebug, "FS: data directory: ", datadir);
@ -189,6 +195,9 @@ namespace i2p @@ -189,6 +195,9 @@ namespace i2p
i2p::context.SetBandwidth (i2p::data::CAPS_FLAG_LOW_BANDWIDTH2);
}
int shareRatio; i2p::config::GetOption("share", shareRatio);
i2p::context.SetShareRatio (shareRatio);
std::string family; i2p::config::GetOption("family", family);
i2p::context.SetFamily (family);
if (family.length () > 0)
@ -260,6 +269,7 @@ namespace i2p @@ -260,6 +269,7 @@ namespace i2p
LogPrint(eLogInfo, "Daemon: starting Transports");
if(!ssu) LogPrint(eLogInfo, "Daemon: ssu disabled");
if(!ntcp) LogPrint(eLogInfo, "Daemon: ntcp disabled");
i2p::transport::transports.Start(ntcp, ssu);
if (i2p::transport::transports.IsBoundNTCP() || i2p::transport::transports.IsBoundSSU()) {
LogPrint(eLogInfo, "Daemon: Transports started");

0
Daemon.h → daemon/Daemon.h

35
HTTPServer.cpp → daemon/HTTPServer.cpp

@ -11,9 +11,8 @@ @@ -11,9 +11,8 @@
#include "Log.h"
#include "Config.h"
#include "Tunnel.h"
#include "TransitTunnel.h"
#include "Transports.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "HTTP.h"
#include "LeaseSet.h"
#include "Destination.h"
@ -109,6 +108,18 @@ namespace http { @@ -109,6 +108,18 @@ namespace http {
s << seconds << " seconds";
}
static void ShowTraffic (std::stringstream& s, uint64_t bytes)
{
s << std::fixed << std::setprecision(2);
auto numKBytes = (double) bytes / 1024;
if (numKBytes < 1024)
s << numKBytes << " KiB";
else if (numKBytes < 1024 * 1024)
s << numKBytes / 1024 << " MiB";
else
s << numKBytes / 1024 / 1024 << " GiB";
}
static void ShowTunnelDetails (std::stringstream& s, enum i2p::tunnel::TunnelState eState, int bytes)
{
std::string state;
@ -212,24 +223,14 @@ namespace http { @@ -212,24 +223,14 @@ namespace http {
s << "<b>Family:</b> " << family << "<br>\r\n";
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
s << "<b>Received:</b> ";
s << std::fixed << std::setprecision(2);
auto numKBytesReceived = (double) i2p::transport::transports.GetTotalReceivedBytes () / 1024;
if (numKBytesReceived < 1024)
s << numKBytesReceived << " KiB";
else if (numKBytesReceived < 1024 * 1024)
s << numKBytesReceived / 1024 << " MiB";
else
s << numKBytesReceived / 1024 / 1024 << " GiB";
ShowTraffic (s, i2p::transport::transports.GetTotalReceivedBytes ());
s << " (" << (double) i2p::transport::transports.GetInBandwidth () / 1024 << " KiB/s)<br>\r\n";
s << "<b>Sent:</b> ";
auto numKBytesSent = (double) i2p::transport::transports.GetTotalSentBytes () / 1024;
if (numKBytesSent < 1024)
s << numKBytesSent << " KiB";
else if (numKBytesSent < 1024 * 1024)
s << numKBytesSent / 1024 << " MiB";
else
s << numKBytesSent / 1024 / 1024 << " GiB";
ShowTraffic (s, i2p::transport::transports.GetTotalSentBytes ());
s << " (" << (double) i2p::transport::transports.GetOutBandwidth () / 1024 << " KiB/s)<br>\r\n";
s << "<b>Transit:</b> ";
ShowTraffic (s, i2p::transport::transports.GetTotalTransitTransmittedBytes ());
s << " (" << (double) i2p::transport::transports.GetTransitBandwidth () / 1024 << " KiB/s)<br>\r\n";
s << "<b>Data path:</b> " << i2p::fs::GetDataDir() << "<br>\r\n";
s << "<div class='slide'\r\n><label for='slide1'>Hidden content. Press on text to see.</label>\r\n<input type='checkbox' id='slide1'/>\r\n<p class='content'>\r\n";
s << "<b>Router Ident:</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";

0
HTTPServer.h → daemon/HTTPServer.h

2
I2PControl.cpp → daemon/I2PControl.cpp

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
#include "FS.h"
#include "Log.h"
#include "Config.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "RouterContext.h"
#include "Daemon.h"
#include "Tunnel.h"

0
I2PControl.h → daemon/I2PControl.h

2
UPnP.cpp → daemon/UPnP.cpp

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
#include "RouterContext.h"
#include "UPnP.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "util.h"
#include "RouterInfo.h"
#include "Config.h"

0
UPnP.h → daemon/UPnP.h

0
DaemonLinux.cpp → daemon/UnixDaemon.cpp

0
i2pd.cpp → daemon/i2pd.cpp

11
debian/changelog vendored

@ -1,3 +1,12 @@ @@ -1,3 +1,12 @@
i2pd (2.14.0-1) unstable; urgency=low
* updated to version 2.14.0/0.9.30
* updated debian/control
* renamed logrotate to i2pd.logrotate
* fixed init.d script
-- orignal <orignal@i2pmail.org> Thu, 1 Jun 2017 14:00:00 +0000
i2pd (2.13.0-1) unstable; urgency=low
* updated to version 2.13.0/0.9.29
@ -5,7 +14,7 @@ i2pd (2.13.0-1) unstable; urgency=low @@ -5,7 +14,7 @@ i2pd (2.13.0-1) unstable; urgency=low
* renamed logrotate to i2pd.logrotate
* fixed init.d script
-- orignal <orignal@i2pmail.org> Tue, 6 Apr 2017 14:00:00 +0000
-- orignal <orignal@i2pmail.org> Thu, 6 Apr 2017 14:00:00 +0000
i2pd (2.12.0-1) unstable; urgency=low

4
debian/control vendored

@ -2,7 +2,7 @@ Source: i2pd @@ -2,7 +2,7 @@ Source: i2pd
Section: net
Priority: optional
Maintainer: R4SAS <r4sas@i2pmail.org>
Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1~), gcc (>= 4.7) | clang (>= 3.3), libboost-system-dev (>= 1.46), libboost-date-time-dev, libboost-filesystem-dev, libboost-program-options-dev, libminiupnpc-dev, libssl-dev
Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1~), gcc (>= 4.7) | clang (>= 3.3), libboost-system-dev (>= 1.46), libboost-date-time-dev, libboost-filesystem-dev, libboost-program-options-dev, libminiupnpc-dev, libssl-dev, zlib1g-dev
Standards-Version: 3.9.6
Homepage: http://i2pd.website/
Vcs-Git: git://github.com/PurpleI2P/i2pd.git
@ -13,7 +13,7 @@ Architecture: any @@ -13,7 +13,7 @@ Architecture: any
Pre-Depends: adduser
Depends: ${shlibs:Depends}, ${misc:Depends}
Suggests: tor, privoxy
Description: i2pd is a full-featured C++ implementation of I2P client.
Description: A full-featured C++ implementation of I2P client.
I2P (Invisible Internet Protocol) is a universal anonymous network layer. All
communications over I2P are anonymous and end-to-end encrypted, participants
don't reveal their real IP addresses.

32
filelist.mk

@ -1,16 +1,22 @@ @@ -1,16 +1,22 @@
LIB_SRC = \
BloomFilter.cpp Gzip.cpp Crypto.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \
Log.cpp NTCPSession.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp \
Reseed.cpp RouterContext.cpp RouterInfo.cpp Signature.cpp SSU.cpp \
SSUSession.cpp SSUData.cpp Streaming.cpp Identity.cpp TransitTunnel.cpp \
Transports.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp TunnelGateway.cpp \
Destination.cpp Base.cpp I2PEndian.cpp FS.cpp Config.cpp Family.cpp \
Config.cpp HTTP.cpp Timestamp.cpp util.cpp api.cpp Event.cpp Gost.cpp
#LIB_SRC = \
# BloomFilter.cpp Gzip.cpp Crypto.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \
# Log.cpp NTCPSession.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp \
# Reseed.cpp RouterContext.cpp RouterInfo.cpp Signature.cpp SSU.cpp \
# SSUSession.cpp SSUData.cpp Streaming.cpp Identity.cpp TransitTunnel.cpp \
# Transports.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp TunnelGateway.cpp \
# Destination.cpp Base.cpp I2PEndian.cpp FS.cpp Config.cpp Family.cpp \
# Config.cpp HTTP.cpp Timestamp.cpp util.cpp api.cpp Event.cpp Gost.cpp
LIB_CLIENT_SRC = \
AddressBook.cpp BOB.cpp ClientContext.cpp I2PTunnel.cpp I2PService.cpp MatchedDestination.cpp \
SAM.cpp SOCKS.cpp HTTPProxy.cpp I2CP.cpp WebSocks.cpp
LIB_SRC = $(wildcard $(LIB_SRC_DIR)/*.cpp)
#LIB_CLIENT_SRC = \
# AddressBook.cpp BOB.cpp ClientContext.cpp I2PTunnel.cpp I2PService.cpp MatchedDestination.cpp \
# SAM.cpp SOCKS.cpp HTTPProxy.cpp I2CP.cpp WebSocks.cpp
LIB_CLIENT_SRC = $(wildcard $(LIB_CLIENT_SRC_DIR)/*.cpp)
# also: Daemon{Linux,Win32}.cpp will be added later
DAEMON_SRC = \
HTTPServer.cpp I2PControl.cpp UPnP.cpp Daemon.cpp i2pd.cpp
#DAEMON_SRC = \
# HTTPServer.cpp I2PControl.cpp UPnP.cpp Daemon.cpp i2pd.cpp
DAEMON_SRC = $(wildcard $(DAEMON_SRC_DIR)/*.cpp)

0
Base.cpp → libi2pd/Base.cpp

0
Base.h → libi2pd/Base.h

0
BloomFilter.cpp → libi2pd/BloomFilter.cpp

0
BloomFilter.h → libi2pd/BloomFilter.h

8
Config.cpp → libi2pd/Config.cpp

@ -54,8 +54,10 @@ namespace config { @@ -54,8 +54,10 @@ namespace config {
("notransit", value<bool>()->zero_tokens()->default_value(false), "Router will not accept transit tunnels at startup")
("floodfill", value<bool>()->zero_tokens()->default_value(false), "Router will be floodfill")
("bandwidth", value<std::string>()->default_value(""), "Bandwidth limit: integer in KBps or letters: L (32), O (256), P (2048), X (>9000)")
("share", value<int>()->default_value(100), "Limit of transit traffic from max bandwidth in percents. (default: 100")
("ntcp", value<bool>()->zero_tokens()->default_value(true), "Enable NTCP transport")
("ssu", value<bool>()->zero_tokens()->default_value(true), "Enable SSU transport")
("ntcpproxy", value<std::string>()->default_value(""), "proxy url for ntcp transport")
#ifdef _WIN32
("svcctl", value<std::string>()->default_value(""), "Windows service management ('install' or 'remove')")
("insomnia", value<bool>()->zero_tokens()->default_value(false), "Prevent system from sleeping")
@ -116,7 +118,7 @@ namespace config { @@ -116,7 +118,7 @@ namespace config {
options_description sam("SAM bridge options");
sam.add_options()
("sam.enabled", value<bool>()->default_value(false), "Enable or disable SAM Application bridge")
("sam.enabled", value<bool>()->default_value(true), "Enable or disable SAM Application bridge")
("sam.address", value<std::string>()->default_value("127.0.0.1"), "SAM listen address")
("sam.port", value<uint16_t>()->default_value(7656), "SAM listen port")
;
@ -186,8 +188,8 @@ namespace config { @@ -186,8 +188,8 @@ namespace config {
"https://reseed.atomike.ninja/,"
"https://reseed.memcpy.io/,"
"https://reseed.onion.im/,"
"https://itoopie.atomike.ninja/,"
"https://randomrng.ddns.net/"
"https://itoopie.atomike.ninja/"
// "https://randomrng.ddns.net/" // dead
), "Reseed URLs, separated by comma")
;

0
Config.h → libi2pd/Config.h

0
Crypto.cpp → libi2pd/Crypto.cpp

0
Crypto.h → libi2pd/Crypto.h

0
Datagram.cpp → libi2pd/Datagram.cpp

0
Datagram.h → libi2pd/Datagram.h

2
Destination.cpp → libi2pd/Destination.cpp

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#include "Log.h"
#include "FS.h"
#include "Timestamp.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "Destination.h"
#include "util.h"

2
Destination.h → libi2pd/Destination.h

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
#include "Crypto.h"
#include "LeaseSet.h"
#include "Garlic.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "Streaming.h"
#include "Datagram.h"

0
Event.cpp → libi2pd/Event.cpp

0
Event.h → libi2pd/Event.h

0
FS.cpp → libi2pd/FS.cpp

0
FS.h → libi2pd/FS.h

0
Family.cpp → libi2pd/Family.cpp

0
Family.h → libi2pd/Family.h

0
Garlic.cpp → libi2pd/Garlic.cpp

0
Garlic.h → libi2pd/Garlic.h

3
Gost.cpp → libi2pd/Gost.cpp

@ -323,7 +323,7 @@ namespace crypto @@ -323,7 +323,7 @@ namespace crypto
for (int i = 63; i >= 0; i--)
{
uint16_t sum = buf[i] + other.buf[i] + carry;
ret.buf[i] = sum & 0xFF;
ret.buf[i] = sum;
carry = sum >> 8;
}
return ret;
@ -333,6 +333,7 @@ namespace crypto @@ -333,6 +333,7 @@ namespace crypto
{
for (int i = 63; i >= 0; i--)
{
if (!c) return;
c += buf[i];
buf[i] = c;
c >>= 8;

0
Gost.h → libi2pd/Gost.h

0
Gzip.cpp → libi2pd/Gzip.cpp

0
Gzip.h → libi2pd/Gzip.h

0
HTTP.cpp → libi2pd/HTTP.cpp

0
HTTP.h → libi2pd/HTTP.h

5
I2NPProtocol.cpp → libi2pd/I2NPProtocol.cpp

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
#include "I2PEndian.h"
#include "Timestamp.h"
#include "RouterContext.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "Tunnel.h"
#include "Transports.h"
#include "Garlic.h"
@ -332,7 +332,8 @@ namespace i2p @@ -332,7 +332,8 @@ namespace i2p
// replace record to reply
if (i2p::context.AcceptsTunnels () &&
i2p::tunnel::tunnels.GetTransitTunnels ().size () <= g_MaxNumTransitTunnels &&
!i2p::transport::transports.IsBandwidthExceeded ())
!i2p::transport::transports.IsBandwidthExceeded () &&
!i2p::transport::transports.IsTransitBandwidthExceeded ())
{
auto transitTunnel = i2p::tunnel::CreateTransitTunnel (
bufbe32toh (clearText + BUILD_REQUEST_RECORD_RECEIVE_TUNNEL_OFFSET),

0
I2NPProtocol.h → libi2pd/I2NPProtocol.h

0
I2PEndian.cpp → libi2pd/I2PEndian.cpp

0
I2PEndian.h → libi2pd/I2PEndian.h

0
Identity.cpp → libi2pd/Identity.cpp

0
Identity.h → libi2pd/Identity.h

2
LeaseSet.cpp → libi2pd/LeaseSet.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include "Crypto.h"
#include "Log.h"
#include "Timestamp.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "Tunnel.h"
#include "LeaseSet.h"

0
LeaseSet.h → libi2pd/LeaseSet.h

0
LittleBigEndian.h → libi2pd/LittleBigEndian.h

0
Log.cpp → libi2pd/Log.cpp

0
Log.h → libi2pd/Log.h

268
NTCPSession.cpp → libi2pd/NTCPSession.cpp

@ -10,8 +10,10 @@ @@ -10,8 +10,10 @@
#include "I2NPProtocol.h"
#include "RouterContext.h"
#include "Transports.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "NTCPSession.h"
#include "HTTP.h"
#include "util.h"
#ifdef WITH_EVENTS
#include "Event.h"
#endif
@ -788,7 +790,8 @@ namespace transport @@ -788,7 +790,8 @@ namespace transport
//-----------------------------------------
NTCPServer::NTCPServer ():
m_IsRunning (false), m_Thread (nullptr), m_Work (m_Service),
m_TerminationTimer (m_Service), m_NTCPAcceptor (nullptr), m_NTCPV6Acceptor (nullptr)
m_TerminationTimer (m_Service), m_NTCPAcceptor (nullptr), m_NTCPV6Acceptor (nullptr),
m_ProxyType(eNoProxy), m_Resolver(m_Service), m_ProxyEndpoint(nullptr)
{
}
@ -803,6 +806,24 @@ namespace transport @@ -803,6 +806,24 @@ namespace transport
{
m_IsRunning = true;
m_Thread = new std::thread (std::bind (&NTCPServer::Run, this));
// we are using a proxy, don't create any acceptors
if(UsingProxy())
{
// TODO: resolve proxy until it is resolved
boost::asio::ip::tcp::resolver::query q(m_ProxyAddress, std::to_string(m_ProxyPort));
boost::system::error_code e;
auto itr = m_Resolver.resolve(q, e);
if(e)
{
LogPrint(eLogError, "NTCP: Failed to resolve proxy ", e.message());
}
else
{
m_ProxyEndpoint = new boost::asio::ip::tcp::endpoint(*itr);
}
}
else
{
// create acceptors
auto& addresses = context.GetRouterInfo ().GetAddresses ();
for (const auto& address: addresses)
@ -814,8 +835,7 @@ namespace transport @@ -814,8 +835,7 @@ namespace transport
{
try
{
m_NTCPAcceptor = new boost::asio::ip::tcp::acceptor (m_Service,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), address->port));
m_NTCPAcceptor = new boost::asio::ip::tcp::acceptor (m_Service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), address->port));
} catch ( std::exception & ex ) {
/** fail to bind ip4 */
LogPrint(eLogError, "NTCP: Failed to bind to ip4 port ",address->port, ex.what());
@ -824,8 +844,7 @@ namespace transport @@ -824,8 +844,7 @@ namespace transport
LogPrint (eLogInfo, "NTCP: Start listening TCP port ", address->port);
auto conn = std::make_shared<NTCPSession>(*this);
m_NTCPAcceptor->async_accept(conn->GetSocket (), std::bind (&NTCPServer::HandleAccept, this,
conn, std::placeholders::_1));
m_NTCPAcceptor->async_accept(conn->GetSocket (), std::bind (&NTCPServer::HandleAccept, this, conn, std::placeholders::_1));
}
else if (address->host.is_v6() && context.SupportsV6 ())
{
@ -834,14 +853,12 @@ namespace transport @@ -834,14 +853,12 @@ namespace transport
{
m_NTCPV6Acceptor->open (boost::asio::ip::tcp::v6());
m_NTCPV6Acceptor->set_option (boost::asio::ip::v6_only (true));
m_NTCPV6Acceptor->bind (boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), address->port));
m_NTCPV6Acceptor->listen ();
LogPrint (eLogInfo, "NTCP: Start listening V6 TCP port ", address->port);
auto conn = std::make_shared<NTCPSession> (*this);
m_NTCPV6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCPServer::HandleAcceptV6,
this, conn, std::placeholders::_1));
m_NTCPV6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCPServer::HandleAcceptV6, this, conn, std::placeholders::_1));
} catch ( std::exception & ex ) {
LogPrint(eLogError, "NTCP: failed to bind to ip6 port ", address->port);
continue;
@ -849,6 +866,7 @@ namespace transport @@ -849,6 +866,7 @@ namespace transport
}
}
}
}
ScheduleTermination ();
}
}
@ -886,6 +904,11 @@ namespace transport @@ -886,6 +904,11 @@ namespace transport
delete m_Thread;
m_Thread = nullptr;
}
if(m_ProxyEndpoint)
{
delete m_ProxyEndpoint;
m_ProxyEndpoint = nullptr;
}
}
}
@ -989,25 +1012,50 @@ namespace transport @@ -989,25 +1012,50 @@ namespace transport
}
}
void NTCPServer::Connect (const boost::asio::ip::address& address, int port, std::shared_ptr<NTCPSession> conn)
void NTCPServer::Connect(const boost::asio::ip::address & address, uint16_t port, std::shared_ptr<NTCPSession> conn)
{
LogPrint (eLogDebug, "NTCP: Connecting to ", address ,":", port);
m_Service.post([=]()
{
m_Service.post([=]() {
if (this->AddNTCPSession (conn))
{
auto timer = std::make_shared<boost::asio::deadline_timer>(m_Service);
timer->expires_from_now (boost::posix_time::seconds(NTCP_CONNECT_TIMEOUT));
timer->async_wait ([conn](const boost::system::error_code& ecode)
{
timer->async_wait ([conn](const boost::system::error_code& ecode) {
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint (eLogInfo, "NTCP: Not connected in ", NTCP_CONNECT_TIMEOUT, " seconds");
conn->Terminate ();
}
});
conn->GetSocket ().async_connect (boost::asio::ip::tcp::endpoint (address, port),
std::bind (&NTCPServer::HandleConnect, this, std::placeholders::_1, conn, timer));
conn->GetSocket ().async_connect (boost::asio::ip::tcp::endpoint (address, port), std::bind (&NTCPServer::HandleConnect, this, std::placeholders::_1, conn, timer));
}
});
}
void NTCPServer::ConnectWithProxy (const std::string& host, uint16_t port, RemoteAddressType addrtype, std::shared_ptr<NTCPSession> conn)
{
if(m_ProxyEndpoint == nullptr)
{
return;
}
m_Service.post([=]() {
if (this->AddNTCPSession (conn))
{
auto timer = std::make_shared<boost::asio::deadline_timer>(m_Service);
auto timeout = NTCP_CONNECT_TIMEOUT * 5;
conn->SetTerminationTimeout(timeout * 2);
timer->expires_from_now (boost::posix_time::seconds(timeout));
timer->async_wait ([conn, timeout](const boost::system::error_code& ecode) {
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint (eLogInfo, "NTCP: Not connected in ", timeout, " seconds");
i2p::data::netdb.SetUnreachable (conn->GetRemoteIdentity ()->GetIdentHash (), true);
conn->Terminate ();
}
});
conn->GetSocket ().async_connect (*m_ProxyEndpoint, std::bind (&NTCPServer::HandleProxyConnect, this, std::placeholders::_1, conn, timer, host, port, addrtype));
}
});
}
@ -1031,6 +1079,191 @@ namespace transport @@ -1031,6 +1079,191 @@ namespace transport
}
}
void NTCPServer::UseProxy(ProxyType proxytype, const std::string & addr, uint16_t port)
{
m_ProxyType = proxytype;
m_ProxyAddress = addr;
m_ProxyPort = port;
}
void NTCPServer::HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr<NTCPSession> conn, std::shared_ptr<boost::asio::deadline_timer> timer, const std::string & host, uint16_t port, RemoteAddressType addrtype)
{
if(ecode)
{
LogPrint(eLogWarning, "NTCP: failed to connect to proxy ", ecode.message());
timer->cancel();
conn->Terminate();
return;
}
if(m_ProxyType == eSocksProxy)
{
// TODO: support username/password auth etc
uint8_t buff[3] = {0x05, 0x01, 0x00};
boost::asio::async_write(conn->GetSocket(), boost::asio::buffer(buff, 3), boost::asio::transfer_all(), [=] (const boost::system::error_code & ec, std::size_t transferred) {
(void) transferred;
if(ec)
{
LogPrint(eLogWarning, "NTCP: socks5 write error ", ec.message());
}
});
uint8_t readbuff[2];
boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff, 2), [=](const boost::system::error_code & ec, std::size_t transferred) {
if(ec)
{
LogPrint(eLogError, "NTCP: socks5 read error ", ec.message());
timer->cancel();
conn->Terminate();
return;
}
else if(transferred == 2)
{
if(readbuff[1] == 0x00)
{
AfterSocksHandshake(conn, timer, host, port, addrtype);
return;
}
else if (readbuff[1] == 0xff)
{
LogPrint(eLogError, "NTCP: socks5 proxy rejected authentication");
timer->cancel();
conn->Terminate();
return;
}
}
LogPrint(eLogError, "NTCP: socks5 server gave invalid response");
timer->cancel();
conn->Terminate();
});
}
else if(m_ProxyType == eHTTPProxy)
{
i2p::http::HTTPReq req;
req.method = "CONNECT";
req.version ="HTTP/1.1";
if(addrtype == eIP6Address)
req.uri = "[" + host + "]:" + std::to_string(port);
else
req.uri = host + ":" + std::to_string(port);
boost::asio::streambuf writebuff;
std::ostream out(&writebuff);
out << req.to_string();
boost::asio::async_write(conn->GetSocket(), writebuff.data(), boost::asio::transfer_all(), [=](const boost::system::error_code & ec, std::size_t transferred) {
(void) transferred;
if(ec)
LogPrint(eLogError, "NTCP: http proxy write error ", ec.message());
});
boost::asio::streambuf * readbuff = new boost::asio::streambuf;
boost::asio::async_read_until(conn->GetSocket(), *readbuff, "\r\n\r\n", [=] (const boost::system::error_code & ec, std::size_t transferred) {
if(ec)
{
LogPrint(eLogError, "NTCP: http proxy read error ", ec.message());
timer->cancel();
conn->Terminate();
}
else
{
readbuff->commit(transferred);
i2p::http::HTTPRes res;
if(res.parse(boost::asio::buffer_cast<const char*>(readbuff->data()), readbuff->size()) > 0)
{
if(res.code == 200)
{
timer->cancel();
conn->ClientLogin();
delete readbuff;
return;
}
else
{
LogPrint(eLogError, "NTCP: http proxy rejected request ", res.code);
}
}
else
LogPrint(eLogError, "NTCP: http proxy gave malformed response");
timer->cancel();
conn->Terminate();
delete readbuff;
}
});
}
else
LogPrint(eLogError, "NTCP: unknown proxy type, invalid state");
}
void NTCPServer::AfterSocksHandshake(std::shared_ptr<NTCPSession> conn, std::shared_ptr<boost::asio::deadline_timer> timer, const std::string & host, uint16_t port, RemoteAddressType addrtype)
{
// build request
size_t sz = 0;
uint8_t buff[256];
uint8_t readbuff[256];
buff[0] = 0x05;
buff[1] = 0x01;
buff[2] = 0x00;
if(addrtype == eIP4Address)
{
buff[3] = 0x01;
auto addr = boost::asio::ip::address::from_string(host).to_v4();
auto addrbytes = addr.to_bytes();
auto addrsize = addrbytes.size();
memcpy(buff+4, addrbytes.data(), addrsize);
}
else if (addrtype == eIP6Address)
{
buff[3] = 0x04;
auto addr = boost::asio::ip::address::from_string(host).to_v6();
auto addrbytes = addr.to_bytes();
auto addrsize = addrbytes.size();
memcpy(buff+4, addrbytes.data(), addrsize);
}
else if (addrtype == eHostname)
{
buff[3] = 0x03;
size_t addrsize = host.size();
sz = addrsize + 1 + 4;
if (2 + sz > sizeof(buff))
{
// too big
return;
}
buff[4] = (uint8_t) addrsize;
memcpy(buff+4, host.c_str(), addrsize);
}
htobe16buf(buff+sz, port);
sz += 2;
boost::asio::async_write(conn->GetSocket(), boost::asio::buffer(buff, sz), boost::asio::transfer_all(), [=](const boost::system::error_code & ec, std::size_t written) {
if(ec)
{
LogPrint(eLogError, "NTCP: failed to write handshake to socks proxy ", ec.message());
return;
}
});
boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff, sz), [=](const boost::system::error_code & e, std::size_t transferred) {
if(e)
{
LogPrint(eLogError, "NTCP: socks proxy read error ", e.message());
}
else if(transferred == sz)
{
if( readbuff[1] == 0x00)
{
timer->cancel();
conn->ClientLogin();
return;
}
}
if(!e)
i2p::data::netdb.SetUnreachable (conn->GetRemoteIdentity ()->GetIdentHash (), true);
timer->cancel();
conn->Terminate();
});
}
void NTCPServer::ScheduleTermination ()
{
m_TerminationTimer.expires_from_now (boost::posix_time::seconds(NTCP_TERMINATION_CHECK_TIMEOUT));
@ -1049,8 +1282,7 @@ namespace transport @@ -1049,8 +1282,7 @@ namespace transport
{
auto session = it.second;
// Termniate modifies m_NTCPSession, so we postpone it
m_Service.post ([session]
{
m_Service.post ([session] {
LogPrint (eLogDebug, "NTCP: No activity for ", session->GetTerminationTimeout (), " seconds");
session->Terminate ();
});

30
NTCPSession.h → libi2pd/NTCPSession.h

@ -131,6 +131,21 @@ namespace transport @@ -131,6 +131,21 @@ namespace transport
{
public:
enum RemoteAddressType
{
eIP4Address,
eIP6Address,
eHostname
};
enum ProxyType
{
eNoProxy,
eSocksProxy,
eHTTPProxy
};
NTCPServer ();
~NTCPServer ();
@ -140,10 +155,15 @@ namespace transport @@ -140,10 +155,15 @@ namespace transport
bool AddNTCPSession (std::shared_ptr<NTCPSession> session);
void RemoveNTCPSession (std::shared_ptr<NTCPSession> session);
std::shared_ptr<NTCPSession> FindNTCPSession (const i2p::data::IdentHash& ident);
void Connect (const boost::asio::ip::address& address, int port, std::shared_ptr<NTCPSession> conn);
void ConnectWithProxy (const std::string& addr, uint16_t port, RemoteAddressType addrtype, std::shared_ptr<NTCPSession> conn);
void Connect(const boost::asio::ip::address & address, uint16_t port, std::shared_ptr<NTCPSession> conn);
bool IsBoundV4() const { return m_NTCPAcceptor != nullptr; };
bool IsBoundV6() const { return m_NTCPV6Acceptor != nullptr; };
bool NetworkIsReady() const { return IsBoundV4() || IsBoundV6() || UsingProxy(); };
bool UsingProxy() const { return m_ProxyType != eNoProxy; };
void UseProxy(ProxyType proxy, const std::string & address, uint16_t port);
boost::asio::io_service& GetService () { return m_Service; };
@ -155,6 +175,9 @@ namespace transport @@ -155,6 +175,9 @@ namespace transport
void HandleConnect (const boost::system::error_code& ecode, std::shared_ptr<NTCPSession> conn, std::shared_ptr<boost::asio::deadline_timer> timer);
void HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr<NTCPSession> conn, std::shared_ptr<boost::asio::deadline_timer> timer, const std::string & host, uint16_t port, RemoteAddressType adddrtype);
void AfterSocksHandshake(std::shared_ptr<NTCPSession> conn, std::shared_ptr<boost::asio::deadline_timer> timer, const std::string & host, uint16_t port, RemoteAddressType adddrtype);
// timer
void ScheduleTermination ();
void HandleTerminationTimer (const boost::system::error_code& ecode);
@ -170,6 +193,11 @@ namespace transport @@ -170,6 +193,11 @@ namespace transport
std::map<i2p::data::IdentHash, std::shared_ptr<NTCPSession> > m_NTCPSessions; // access from m_Thread only
std::list<std::shared_ptr<NTCPSession> > m_PendingIncomingSessions;
ProxyType m_ProxyType;
std::string m_ProxyAddress;
uint16_t m_ProxyPort;
boost::asio::ip::tcp::resolver m_Resolver;
boost::asio::ip::tcp::endpoint * m_ProxyEndpoint;
public:
// for HTTP/I2PControl

2
NetDb.cpp → libi2pd/NetDb.cpp

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
#include "Transports.h"
#include "RouterContext.h"
#include "Garlic.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "Config.h"
using namespace i2p::transport;

2
NetDb.h → libi2pd/NetDb.hpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#ifndef NETDB_H__
#define NETDB_H__
// this file is called NetDb.hpp to resolve conflict with libc's netdb.h on case insensitive fs
#include <inttypes.h>
#include <set>
#include <map>

2
NetDbRequests.cpp → libi2pd/NetDbRequests.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include "Log.h"
#include "I2NPProtocol.h"
#include "Transports.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "NetDbRequests.h"
namespace i2p

0
NetDbRequests.h → libi2pd/NetDbRequests.h

0
Profiling.cpp → libi2pd/Profiling.cpp

0
Profiling.h → libi2pd/Profiling.h

0
Queue.h → libi2pd/Queue.h

2
Reseed.cpp → libi2pd/Reseed.cpp

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
#include "FS.h"
#include "Log.h"
#include "Identity.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "HTTP.h"
#include "util.h"
#include "Config.h"

0
Reseed.h → libi2pd/Reseed.h

13
RouterContext.cpp → libi2pd/RouterContext.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include "Crypto.h"
#include "Timestamp.h"
#include "I2NPProtocol.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "FS.h"
#include "util.h"
#include "version.h"
@ -17,8 +17,8 @@ namespace i2p @@ -17,8 +17,8 @@ namespace i2p
RouterContext::RouterContext ():
m_LastUpdateTime (0), m_AcceptsTunnels (true), m_IsFloodfill (false),
m_StartupTime (0), m_Status (eRouterStatusOK), m_Error (eRouterErrorNone),
m_NetID (I2PD_NET_ID)
m_StartupTime (0), m_ShareRatio (100), m_Status (eRouterStatusOK),
m_Error (eRouterErrorNone), m_NetID (I2PD_NET_ID)
{
}
@ -246,6 +246,13 @@ namespace i2p @@ -246,6 +246,13 @@ namespace i2p
else { SetBandwidth('K'); }
}
void RouterContext::SetShareRatio (int percents)
{
if (percents < 0) percents = 0;
if (percents > 100) percents = 100;
m_ShareRatio = percents;
}
bool RouterContext::IsUnreachable () const
{
return m_RouterInfo.GetCaps () & i2p::data::RouterInfo::eUnreachable;

5
RouterContext.h → libi2pd/RouterContext.h

@ -54,6 +54,7 @@ namespace i2p @@ -54,6 +54,7 @@ namespace i2p
uint32_t GetStartupTime () const { return m_StartupTime; };
uint64_t GetLastUpdateTime () const { return m_LastUpdateTime; };
uint64_t GetBandwidthLimit () const { return m_BandwidthLimit; };
uint64_t GetTransitBandwidthLimit () const { return (m_BandwidthLimit*m_ShareRatio)/100LL; };
RouterStatus GetStatus () const { return m_Status; };
void SetStatus (RouterStatus status);
RouterError GetError () const { return m_Error; };
@ -74,6 +75,7 @@ namespace i2p @@ -74,6 +75,7 @@ namespace i2p
std::string GetFamily () const;
void SetBandwidth (int limit); /* in kilobytes */
void SetBandwidth (char L); /* by letter */
void SetShareRatio (int percents); // 0 - 100
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; };
bool SupportsV6 () const { return m_RouterInfo.IsV6 (); };
@ -116,7 +118,8 @@ namespace i2p @@ -116,7 +118,8 @@ namespace i2p
uint64_t m_LastUpdateTime;
bool m_AcceptsTunnels, m_IsFloodfill;
uint64_t m_StartupTime; // in seconds since epoch
uint32_t m_BandwidthLimit; // allowed bandwidth
uint64_t m_BandwidthLimit; // allowed bandwidth
int m_ShareRatio;
RouterStatus m_Status;
RouterError m_Error;
int m_NetID;

16
RouterInfo.cpp → libi2pd/RouterInfo.cpp

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
#include "Base.h"
#include "Timestamp.h"
#include "Log.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "RouterContext.h"
#include "RouterInfo.h"
@ -264,6 +264,8 @@ namespace data @@ -264,6 +264,8 @@ namespace data
introducer.iTag = boost::lexical_cast<uint32_t>(value);
else if (!strcmp (key, "ikey"))
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
else if (!strcmp (key, "iexp"))
introducer.iExp = boost::lexical_cast<uint32_t>(value);
}
if (!s) return;
}
@ -478,6 +480,18 @@ namespace data @@ -478,6 +480,18 @@ namespace data
properties << ';';
i++;
}
i = 0;
for (const auto& introducer: address.ssu->introducers)
{
if (introducer.iExp) // expiration is specified
{
WriteString ("iexp" + boost::lexical_cast<std::string>(i), properties);
properties << '=';
WriteString (boost::lexical_cast<std::string>(introducer.iExp), properties);
properties << ';';
}
i++;
}
}
// write intro key
WriteString ("key", properties);

2
RouterInfo.h → libi2pd/RouterInfo.h

@ -73,10 +73,12 @@ namespace data @@ -73,10 +73,12 @@ namespace data
typedef Tag<32> IntroKey; // should be castable to MacKey and AESKey
struct Introducer
{
Introducer (): iExp (0) {};
boost::asio::ip::address iHost;
int iPort;
IntroKey iKey;
uint32_t iTag;
uint32_t iExp;
};
struct SSUExt

2
SSU.cpp → libi2pd/SSU.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include "Log.h"
#include "Timestamp.h"
#include "RouterContext.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "SSU.h"
namespace i2p

0
SSU.h → libi2pd/SSU.h

2
SSUData.cpp → libi2pd/SSUData.cpp

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
#include <boost/bind.hpp>
#include "Log.h"
#include "Timestamp.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "SSU.h"
#include "SSUData.h"
#ifdef WITH_EVENTS

0
SSUData.h → libi2pd/SSUData.h

2
SSUSession.cpp → libi2pd/SSUSession.cpp

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#include "Timestamp.h"
#include "RouterContext.h"
#include "Transports.h"
#include "NetDb.h"
#include "NetDb.hpp"
#include "SSU.h"
#include "SSUSession.h"

0
SSUSession.h → libi2pd/SSUSession.h

0
Signature.cpp → libi2pd/Signature.cpp

0
Signature.h → libi2pd/Signature.h

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save