Compare commits

..

102 Commits

Author SHA1 Message Date
orignal
bd8166e630 2.14.0 2017-06-01 10:05:20 -04:00
orignal
03d1519b39 2.14.0 2017-06-01 10:04:02 -04:00
orignal
36c4719570 Merge pull request #881 from majestrate/ntcp-socks
NTCP SOCKS/HTTP Proxy support
2017-05-29 10:36:46 -04:00
Jeff Becker
7c970771c5 fix 2017-05-29 10:09:24 -04:00
orignal
3f64c042bd Fixed #880. Print if AESNI or AVX enabled 2017-05-29 10:08:49 -04:00
Jeff Becker
e336cbfb2d add http proxy, change socks4a to socks5 2017-05-29 09:57:30 -04:00
Jeff Becker
24eec76428 more 2017-05-29 02:16:57 -04:00
Jeff Becker
71c9b15ff1 more 2017-05-29 02:12:16 -04:00
Jeff Becker
2940f0d67c capture by value not reference 2017-05-29 01:53:34 -04:00
Jeff Becker
cbb1d2d3b5 more whitespace bullshit 2017-05-29 01:44:06 -04:00
Jeff Becker
36dd11a899 more whitespace bullshit 2017-05-29 01:39:11 -04:00
Jeff Becker
be88969b79 more whitespace bullshit 2017-05-29 01:38:32 -04:00
Jeff Becker
d91ad54ed9 more whitespace bullshit 2017-05-29 01:37:19 -04:00
Jeff Becker
1330228080 fix whitespace bullshit 2017-05-29 01:35:11 -04:00
Jeff Becker
3ea1eca350 ntcp socks proxy (initial) 2017-05-29 01:28:16 -04:00
orignal
a4e6d8120b handle iexp 2017-05-24 12:49:36 -04:00
orignal
3219de235c Merge pull request #875 from majestrate/cmake-avx
add AVX option to cmake build system
2017-05-22 14:37:42 -04:00
Jeff Becker
4e5c2ff620 add AVX option to cmake build system 2017-05-22 11:12:08 -04:00
Jeff
63e25f0ff9 Merge pull request #873 from majestrate/fix-addressbook
try fixing issue #871
2017-05-22 10:51:48 -04:00
Jeff Becker
840225b580 try fixing issue #871 2017-05-22 10:34:29 -04:00
Jeff
bd221d60d6 Merge pull request #872 from majestrate/fix-websocket-cmake
fix cmake compile error with websockets
2017-05-21 08:38:07 -04:00
Jeff Becker
8a3bb50143 fix cmake compile error with websockets 2017-05-21 08:18:16 -04:00
orignal
e4cd1a465c ignore comments 2017-05-10 09:36:58 -04:00
orignal
2173a9f246 Merge pull request #869 from bit/patch-1
Build depends on zlib.h (zlib1g-dev)
2017-05-08 14:58:33 -04:00
bit
973a838e2a Build depends on zlib.h (zlib1g-dev) 2017-05-08 12:54:08 +02:00
orignal
d95ee55497 skip comment address line 2017-05-05 13:54:21 -04:00
orignal
124e2e759c fix #846. ability to limit transit bandwidth 2017-05-04 14:58:12 -04:00
orignal
ac918e3618 0.9.30 2017-05-04 09:40:00 -04:00
orignal
009a720c32 disabled dead reseed 2017-05-02 21:08:51 -04:00
orignal
0dbfa43dad moveable to SD card 2017-05-02 19:25:34 -04:00
orignal
e0b4d36a74 changed target sdk back to 25 2017-05-02 18:06:06 -04:00
orignal
a441474d75 show transit bandwidth 2017-05-02 14:20:00 -04:00
orignal
cfd3c3628e count and show transit traffic 2017-04-27 16:11:37 -04:00
orignal
474d52f805 minor performance improvements 2017-04-27 10:12:22 -04:00
orignal
7ee8bdf2f3 Merge branch 'master' of https://github.com/PurpleI2P/i2pd into openssl 2017-04-27 10:11:45 -04:00
orignal
8a9757111f enable SAM by default 2017-04-24 12:20:15 -04:00
Darknet Villain
65dda4a70b Merge pull request #865 from l-n-s/update_config
Sample config: enable SAM by default + update description for notransit
2017-04-24 15:10:57 +00:00
Darknet Villain
1ed39dbbed Sample config: enable SAM by default + update description for notransit 2017-04-24 11:07:54 -04:00
orignal
8162c2e4e4 GST added 2017-04-23 06:52:37 -04:00
r4sas
a7d74f3f98 update debian stuff 2017-04-23 07:09:12 +03:00
orignal
ad83ae1e7a removed stdafx 2017-04-22 14:52:19 -04:00
R4SAS
066374906e Merge pull request #862 from r4sas/makefile
update Makefile, tunnels.conf, android platform
2017-04-22 05:35:53 +04:00
orignal
ec79a4a6f6 Merge pull request #861 from majestrate/fix-case-insensative-include
remove uneeded lines in qt build file
2017-04-21 21:34:02 -04:00
R4SAS
9fae215db4 update android platform to 14 2017-04-22 04:20:22 +03:00
R4SAS
92b40c9485 update tunnels.conf 2017-04-22 04:19:32 +03:00
R4SAS
19fc59739f update makefile-s 2017-04-22 04:17:01 +03:00
Jeff Becker
7e0ae4c601 remove uneeded lines in qt build file 2017-04-21 21:01:48 -04:00
orignal
81c2f4b30b Merge pull request #860 from majestrate/fix-case-insensative-include
NetDb.h -> NetDb.hpp
2017-04-21 20:46:56 -04:00
Jeff Becker
e238f7ed37 NetDb.h -> NetDb.hpp for case insensative file systems clashing with libc's netdb.h 2017-04-21 20:04:16 -04:00
orignal
2756f3332c changed android target sdk to 25 2017-04-21 12:05:58 -04:00
orignal
14b3eefbaf change minimal requirement to android 4.0 2017-04-21 11:54:08 -04:00
orignal
dc946582a4 generic path to sdk 2017-04-21 09:54:35 -04:00
orignal
dfa14a73a8 Merge pull request #858 from majestrate/restructure
Restructure
2017-04-21 08:52:59 -04:00
Jeff Becker
112aa845f4 use correct #include in Win32 2017-04-21 07:20:50 -04:00
Jeff Becker
150a309175 include daemon directory for Win32 mingw 2017-04-21 07:08:31 -04:00
orignal
55c14819a3 Merge pull request #859 from PurpleI2P/openssl
recent changes
2017-04-21 06:53:56 -04:00
Jeff Becker
598897caa6 fix mingw build 2017-04-21 06:48:57 -04:00
Jeff Becker
cf3f8a796a fix path 2017-04-21 06:36:49 -04:00
Jeff Becker
bffc294b13 fix path 2017-04-21 06:35:39 -04:00
Jeff Becker
4cc3b7f9fb restructure build to separate the 3 main components into 3 subdirectories
libi2pd for core libs

libi2pd_client for i2pd client libs

daemon for i2pd daemon libs
2017-04-21 06:33:45 -04:00
orignal
b3161dde93 Merge pull request #855 from v2e/patch-2
kbps --> KBps
2017-04-19 07:05:29 -04:00
v2e
5550eabac1 kbs -- KBs in i2pd.conf 2017-04-19 11:39:01 +03:00
v2e
b2b320174b kbps -- KBps in Config.cpp 2017-04-19 11:36:19 +03:00
orignal
dd79348b35 delete used tag before update 2017-04-14 22:08:43 -04:00
orignal
bd6ce7d4da reduced memory usage 2017-04-14 10:19:26 -04:00
orignal
7a67670e1a Fixed #846. httpproxy.addresshelper config parameter added 2017-04-11 14:36:28 -04:00
orignal
539bf482b9 Merge pull request #844 from majestrate/datagram-fixes
Datagram fixes
2017-04-09 09:16:37 -04:00
Jeff Becker
ed67ce7f33 tabifty 2017-04-09 08:53:47 -04:00
Jeff Becker
d91c7e5e79 fix datagram bugs 2017-04-09 08:52:42 -04:00
orignal
4f1dfe2ef7 fixed android build 2017-04-08 17:21:56 -04:00
orignal
36ea6c13df Merge pull request #843 from majestrate/obep-ibgw
Allow point to point client tunnels to use OB tunnels that share OBEP and IBGW of remote destination
2017-04-08 15:32:26 -04:00
Jeff Becker
3acb0aac98 tabify 2017-04-08 15:16:51 -04:00
Jeff Becker
fdf4b3878f tabify 2017-04-08 15:15:59 -04:00
Jeff Becker
2fe71782a7 tabify 2017-04-08 15:14:47 -04:00
Jeff Becker
89dfe2b763 delay request 2017-04-08 15:10:16 -04:00
Jeff Becker
9b62f238ed add option for client tunnels to build tunnels such that OBEP==IBGW 2017-04-08 15:10:06 -04:00
orignal
987688f196 GOST hash of a Little Endian stream 2017-04-07 11:17:40 -04:00
orignal
46cb95f16c Merge pull request #842 from PurpleI2P/openssl
2.13.0
2017-04-06 10:02:54 -04:00
r4sas
4e1fcbb706 update appveyor tag to 2.13 2017-04-06 17:01:39 +03:00
orignal
b2d2c56a09 Merge pull request #839 from PurpleI2P/openssl
recent changes
2017-04-03 11:47:31 -04:00
orignal
3afed3b316 Merge pull request #832 from PurpleI2P/openssl
recent changes
2017-03-19 11:02:36 -04:00
orignal
a8196d1f33 Merge pull request #816 from PurpleI2P/openssl
recent changes
2017-02-26 09:29:14 -05:00
orignal
29cc1cf390 Merge pull request #805 from PurpleI2P/openssl
2.12.0
2017-02-14 12:38:32 -05:00
orignal
040585bf3d Merge pull request #791 from PurpleI2P/openssl
recent changes
2017-02-01 14:18:41 -05:00
orignal
26e7821aaa Merge pull request #781 from PurpleI2P/openssl
recent changes
2017-01-19 21:57:08 -05:00
orignal
e0879fbccb Merge pull request #779 from PurpleI2P/openssl
recent changes
2017-01-16 22:06:32 -05:00
orignal
b3ab85f3b5 Merge pull request #768 from PurpleI2P/openssl
recent changes
2017-01-05 15:47:04 -05:00
orignal
d4f5871e74 Merge pull request #764 from PurpleI2P/openssl
recent changes
2017-01-02 16:16:51 -05:00
orignal
fc08d15a79 Merge pull request #743 from PurpleI2P/openssl
2.11.0
2016-12-18 18:11:22 -05:00
orignal
0ea5fbfe0a Merge pull request #731 from PurpleI2P/openssl
recent changes
2016-12-03 09:38:28 -05:00
orignal
2756cb8b8f Merge pull request #729 from PurpleI2P/openssl
recent changes
2016-11-29 13:39:26 -05:00
orignal
c166bc9b18 Merge pull request #719 from PurpleI2P/openssl
recent changes
2016-11-23 11:31:58 -05:00
orignal
fb59d80897 Merge pull request #712 from PurpleI2P/openssl
recent changes
2016-11-16 14:40:50 -05:00
orignal
7419f992e7 Merge pull request #703 from PurpleI2P/openssl
recent changes
2016-11-09 14:49:12 -05:00
orignal
4a4292a0dc Merge pull request #700 from PurpleI2P/openssl
recent changes
2016-11-06 14:40:43 -05:00
orignal
bc92586323 Merge pull request #684 from PurpleI2P/openssl
recent changes
2016-10-22 20:05:28 -04:00
orignal
40456ebaae Merge pull request #669 from PurpleI2P/openssl
recent changes
2016-10-12 11:54:51 -04:00
orignal
7c34c45983 Merge pull request #646 from PurpleI2P/openssl
recent changes
2016-09-27 16:19:01 -04:00
orignal
31f6d13cd8 Merge pull request #639 from PurpleI2P/openssl
recent changes
2016-09-18 07:43:21 -04:00
orignal
502e6b0ce5 Merge pull request #631 from rabits/patch-1
Fixed upstart i2pd forking
2016-09-10 19:35:02 -04:00
Rabit
516380f979 Fixed upstart forking
Upstart can't track daemonize fork without expect fork
2016-09-11 01:15:22 +04:00
orignal
63edc60753 Merge pull request #618 from PurpleI2P/openssl
recent changes
2016-08-24 11:12:04 -04:00
162 changed files with 2049 additions and 1418 deletions

10
.gitignore vendored
View File

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

View File

@@ -1,6 +1,17 @@
# for this file format description, # for this file format description,
# see https://github.com/olivierlacan/keep-a-changelog # 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 ## [2.13.0] - 2017-04-06
### Added ### Added
- Persist local destination's tags - Persist local destination's tags

View File

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

View File

@@ -9,9 +9,9 @@ LDFLAGS = -L${SSLROOT}/lib -L${BOOSTROOT}/lib
LDLIBS = -lz -lcrypto -lssl -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread LDLIBS = -lz -lcrypto -lssl -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread
ifeq ($(USE_UPNP),yes) ifeq ($(USE_UPNP),yes)
LDFLAGS += -ldl LDFLAGS += -ldl
CXXFLAGS += -DUSE_UPNP CXXFLAGS += -DUSE_UPNP
LDLIBS += -lminiupnpc LDLIBS += -lminiupnpc
endif endif
# OSX Notes # OSX Notes
@@ -20,7 +20,7 @@ endif
# Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic # Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic
# note from psi: 2009 macbook does not have aesni # note from psi: 2009 macbook does not have aesni
#ifeq ($(USE_AESNI),yes) #ifeq ($(USE_AESNI),yes)
# CXXFLAGS += -maes -DAESNI # CXXFLAGS += -maes -DAESNI
#endif #endif
# Disabled, since it will be the default make rule. I think its better # Disabled, since it will be the default make rule. I think its better

View File

@@ -12,7 +12,7 @@ INCFLAGS ?=
# detect proper flag for c++11 support by compilers # detect proper flag for c++11 support by compilers
CXXVER := $(shell $(CXX) -dumpversion) CXXVER := $(shell $(CXX) -dumpversion)
ifeq ($(shell expr match $(CXX) 'clang'),5) ifeq ($(shell expr match $(CXX) 'clang'),5)
NEEDED_CXXFLAGS += -std=c++11 NEEDED_CXXFLAGS += -std=c++11
else ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # gcc >= 4.10 else ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # gcc >= 4.10
NEEDED_CXXFLAGS += -std=c++11 NEEDED_CXXFLAGS += -std=c++11
else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7 else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7
@@ -31,27 +31,27 @@ ifeq ($(USE_STATIC),yes)
# NOTE: on glibc you will get this warning: # NOTE: on glibc you will get this warning:
# Using 'getaddrinfo' in statically linked applications requires at runtime # Using 'getaddrinfo' in statically linked applications requires at runtime
# the shared libraries from the glibc version used for linking # the shared libraries from the glibc version used for linking
LIBDIR := /usr/lib LIBDIR := /usr/lib
LDLIBS = $(LIBDIR)/libboost_system.a LDLIBS = $(LIBDIR)/libboost_system.a
LDLIBS += $(LIBDIR)/libboost_date_time.a LDLIBS += $(LIBDIR)/libboost_date_time.a
LDLIBS += $(LIBDIR)/libboost_filesystem.a LDLIBS += $(LIBDIR)/libboost_filesystem.a
LDLIBS += $(LIBDIR)/libboost_program_options.a LDLIBS += $(LIBDIR)/libboost_program_options.a
LDLIBS += $(LIBDIR)/libssl.a LDLIBS += $(LIBDIR)/libssl.a
LDLIBS += $(LIBDIR)/libcrypto.a LDLIBS += $(LIBDIR)/libcrypto.a
LDLIBS += $(LIBDIR)/libz.a LDLIBS += $(LIBDIR)/libz.a
LDLIBS += -lpthread -static-libstdc++ -static-libgcc -lrt -ldl LDLIBS += -lpthread -static-libstdc++ -static-libgcc -lrt -ldl
USE_AESNI := no USE_AESNI := no
else else
LDLIBS = -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread LDLIBS = -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread
endif endif
# UPNP Support (miniupnpc 1.5 and higher) # UPNP Support (miniupnpc 1.5 and higher)
ifeq ($(USE_UPNP),yes) ifeq ($(USE_UPNP),yes)
CXXFLAGS += -DUSE_UPNP CXXFLAGS += -DUSE_UPNP
ifeq ($(USE_STATIC),yes) ifeq ($(USE_STATIC),yes)
LDLIBS += $(LIBDIR)/libminiupnpc.a LDLIBS += $(LIBDIR)/libminiupnpc.a
else else
LDLIBS += -lminiupnpc LDLIBS += -lminiupnpc
endif endif
endif endif

View File

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

View File

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

View File

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

View File

@@ -1,13 +1,13 @@
#include <string.h> #include <string.h>
#include <windows.h> #include <windows.h>
#include <shellapi.h> #include <shellapi.h>
#include "../ClientContext.h" #include "ClientContext.h"
#include "../Config.h" #include "Config.h"
#include "../NetDb.h" #include "NetDb.hpp"
#include "../RouterContext.h" #include "RouterContext.h"
#include "../Transports.h" #include "Transports.h"
#include "../Tunnel.h" #include "Tunnel.h"
#include "../version.h" #include "version.h"
#include "resource.h" #include "resource.h"
#include "Win32App.h" #include "Win32App.h"
#include <stdio.h> #include <stdio.h>
@@ -80,7 +80,7 @@ namespace win32
Shell_NotifyIcon (NIM_DELETE, &nid); Shell_NotifyIcon (NIM_DELETE, &nid);
} }
static void ShowUptime (std::stringstream& s, int seconds) static void ShowUptime (std::stringstream& s, int seconds)
{ {
int num; int num;
@@ -125,8 +125,8 @@ namespace win32
{ {
case eRouterStatusOK: s << "OK"; break; case eRouterStatusOK: s << "OK"; break;
case eRouterStatusTesting: s << "Testing"; break; case eRouterStatusTesting: s << "Testing"; break;
case eRouterStatusFirewalled: s << "Firewalled"; break; case eRouterStatusFirewalled: s << "Firewalled"; break;
case eRouterStatusError: case eRouterStatusError:
{ {
switch (i2p::context.GetError()) switch (i2p::context.GetError())
{ {

View File

@@ -7,8 +7,8 @@
#include <strsafe.h> #include <strsafe.h>
#include <windows.h> #include <windows.h>
#include "../Daemon.h" #include "Daemon.h"
#include "../Log.h" #include "Log.h"
I2PService *I2PService::s_service = NULL; I2PService *I2PService::s_service = NULL;
@@ -100,7 +100,7 @@ I2PService::I2PService(PSTR pszServiceName,
m_fStopping = FALSE; m_fStopping = FALSE;
// Create a manual-reset event that is not signaled at first to indicate // Create a manual-reset event that is not signaled at first to indicate
// the stopped signal of the service. // the stopped signal of the service.
m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (m_hStoppedEvent == NULL) if (m_hStoppedEvent == NULL)

View File

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

View File

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

View File

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

1
android/.gitignore vendored
View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := i2pd LOCAL_MODULE := i2pd
LOCAL_CPP_FEATURES := rtti exceptions 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 := \ LOCAL_STATIC_LIBRARIES := \
boost_system \ boost_system \
boost_date_time \ boost_date_time \
@@ -12,58 +12,13 @@ LOCAL_STATIC_LIBRARIES := \
miniupnpc miniupnpc
LOCAL_LDLIBS := -lz LOCAL_LDLIBS := -lz
LOCAL_SRC_FILES := DaemonAndroid.cpp i2pd_android.cpp \ LOCAL_SRC_FILES := DaemonAndroid.cpp i2pd_android.cpp $(IFADDRS_PATH)/ifaddrs.c \
$(IFADDRS_PATH)/ifaddrs.c \ $(wildcard $(LIB_SRC_PATH)/*.cpp)\
../../HTTPServer.cpp ../../I2PControl.cpp ../../Daemon.cpp ../../Config.cpp \ $(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp)\
../../AddressBook.cpp \ $(DAEMON_SRC_PATH)/Daemon.cpp \
../../api.cpp \ $(DAEMON_SRC_PATH)/UPnP.cpp \
../../Base.cpp \ $(DAEMON_SRC_PATH)/HTTPServer.cpp \
../../BOB.cpp \ $(DAEMON_SRC_PATH)/I2PControl.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 \
../../util.cpp \
../../i2pd.cpp ../../UPnP.cpp
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View File

@@ -3,7 +3,7 @@
#APP_ABI := x86 #APP_ABI := x86
APP_ABI := armeabi-v7a 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. #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 # http://stackoverflow.com/a/21386866/529442 http://stackoverflow.com/a/15616255/529442 to enable c++11 support in Eclipse
NDK_TOOLCHAIN_VERSION := 4.9 NDK_TOOLCHAIN_VERSION := 4.9
@@ -25,8 +25,15 @@ APP_OPTIM := debug
# git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git # git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git
# git clone https://github.com/PurpleI2P/android-ifaddrs.git # git clone https://github.com/PurpleI2P/android-ifaddrs.git
# change to your own # 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 BOOST_PATH = $(I2PD_LIBS_PATH)/Boost-for-Android-Prebuilt
OPENSSL_PATH = $(I2PD_LIBS_PATH)/OpenSSL-for-Android-Prebuilt OPENSSL_PATH = $(I2PD_LIBS_PATH)/OpenSSL-for-Android-Prebuilt
MINIUPNP_PATH = $(I2PD_LIBS_PATH)/MiniUPnP-for-Android-Prebuilt MINIUPNP_PATH = $(I2PD_LIBS_PATH)/MiniUPnP-for-Android-Prebuilt
IFADDRS_PATH = $(I2PD_LIBS_PATH)/android-ifaddrs 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

View File

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

View File

@@ -3,8 +3,8 @@
#include <jni.h> #include <jni.h>
#include "org_purplei2p_i2pd_I2PD_JNI.h" #include "org_purplei2p_i2pd_I2PD_JNI.h"
#include "DaemonAndroid.h" #include "DaemonAndroid.h"
#include "../../RouterContext.h" #include "RouterContext.h"
#include "../../Transports.h" #include "Transports.h"
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
(JNIEnv * env, jclass clazz) { (JNIEnv * env, jclass clazz) {
@@ -59,8 +59,8 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels
} }
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
(JNIEnv * env, jclass clazz, jboolean isConnected) (JNIEnv * env, jclass clazz, jboolean isConnected)
{ {
bool isConnectedBool = (bool) isConnected; bool isConnectedBool = (bool) isConnected;
i2p::transport::transports.SetOnline (isConnectedBool); i2p::transport::transports.SetOnline (isConnectedBool);
} }

View File

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

Binary file not shown.

View File

@@ -6,7 +6,6 @@ import android.app.Service;
import android.content.Intent; import android.content.Intent;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
public class ForegroundService extends Service { public class ForegroundService extends Service {
@@ -72,7 +71,7 @@ public class ForegroundService extends Service {
new Intent(this, I2PD.class), 0); new Intent(this, I2PD.class), 0);
// Set the info for the views that show in the notification panel. // 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 .setSmallIcon(R.drawable.itoopie_notification_icon) // the status icon
.setTicker(text) // the status text .setTicker(text) // the status text
.setWhen(System.currentTimeMillis()) // the time stamp .setWhen(System.currentTimeMillis()) // the time stamp
@@ -85,4 +84,4 @@ public class ForegroundService extends Service {
//mNM.notify(NOTIFICATION, notification); //mNM.notify(NOTIFICATION, notification);
startForeground(NOTIFICATION, notification); startForeground(NOTIFICATION, notification);
} }
} }

View File

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

View File

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

View File

@@ -64,12 +64,13 @@ ipv6 = false
# nat = true # nat = true
## Bandwidth configuration ## Bandwidth configuration
## L limit bandwidth to 32Kbs/sec, O - to 256Kbs/sec, P - to 2048Kbs/sec, ## L limit bandwidth to 32KBs/sec, O - to 256KBs/sec, P - to 2048KBs/sec,
## X - unlimited ## X - unlimited
## Default is X for floodfill, L for regular node ## Default is X for floodfill, L for regular node
# bandwidth = L # bandwidth = L
## Router will not accept transit tunnels at startup ## Router will not accept transit tunnels, disabling transit traffic completely
## (default = false)
# notransit = true # notransit = true
## Router will be floodfill ## Router will be floodfill
@@ -141,7 +142,7 @@ port = 4447
[sam] [sam]
## Uncomment and set to 'true' to enable SAM Bridge ## Uncomment and set to 'true' to enable SAM Bridge
# enabled = false enabled = true
## Address and port service will listen on ## Address and port service will listen on
# address = 127.0.0.1 # address = 127.0.0.1
# port = 7656 # port = 7656

View File

@@ -1,4 +1,4 @@
[IRC] [IRC-IRC2P]
type = client type = client
address = 127.0.0.1 address = 127.0.0.1
port = 6668 port = 6668
@@ -6,6 +6,14 @@ destination = irc.postman.i2p
destinationport = 6667 destinationport = 6667
keys = irc-keys.dat 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] #[SMTP]
#type = client #type = client
#address = 127.0.0.1 #address = 127.0.0.1
@@ -22,12 +30,4 @@ keys = irc-keys.dat
#destinationport = 110 #destinationport = 110
#keys = pop3-keys.dat #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 # see more examples in /usr/share/doc/i2pd/configuration.md.gz

View File

@@ -14,7 +14,7 @@
#include "RouterContext.h" #include "RouterContext.h"
#include "Tunnel.h" #include "Tunnel.h"
#include "HTTP.h" #include "HTTP.h"
#include "NetDb.h" #include "NetDb.hpp"
#include "Garlic.h" #include "Garlic.h"
#include "Streaming.h" #include "Streaming.h"
#include "Destination.h" #include "Destination.h"
@@ -115,6 +115,12 @@ namespace i2p
} }
LogPrint(eLogInfo, "i2pd v", VERSION, " starting"); 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: main config file: ", config);
LogPrint(eLogDebug, "FS: data directory: ", datadir); LogPrint(eLogDebug, "FS: data directory: ", datadir);
@@ -140,7 +146,7 @@ namespace i2p
} }
i2p::context.SetSupportsV6 (ipv6); i2p::context.SetSupportsV6 (ipv6);
i2p::context.SetSupportsV4 (ipv4); i2p::context.SetSupportsV4 (ipv4);
bool transit; i2p::config::GetOption("notransit", transit); bool transit; i2p::config::GetOption("notransit", transit);
i2p::context.SetAcceptsTunnels (!transit); i2p::context.SetAcceptsTunnels (!transit);
uint16_t transitTunnels; i2p::config::GetOption("limits.transittunnels", transitTunnels); uint16_t transitTunnels; i2p::config::GetOption("limits.transittunnels", transitTunnels);
@@ -157,17 +163,17 @@ namespace i2p
/* this section also honors 'floodfill' flag, if set above */ /* this section also honors 'floodfill' flag, if set above */
std::string bandwidth; i2p::config::GetOption("bandwidth", bandwidth); std::string bandwidth; i2p::config::GetOption("bandwidth", bandwidth);
if (bandwidth.length () > 0) if (bandwidth.length () > 0)
{ {
if (bandwidth[0] >= 'K' && bandwidth[0] <= 'X') if (bandwidth[0] >= 'K' && bandwidth[0] <= 'X')
{ {
i2p::context.SetBandwidth (bandwidth[0]); i2p::context.SetBandwidth (bandwidth[0]);
LogPrint(eLogInfo, "Daemon: bandwidth set to ", i2p::context.GetBandwidthLimit (), "KBps"); LogPrint(eLogInfo, "Daemon: bandwidth set to ", i2p::context.GetBandwidthLimit (), "KBps");
} }
else else
{ {
auto value = std::atoi(bandwidth.c_str()); auto value = std::atoi(bandwidth.c_str());
if (value > 0) if (value > 0)
{ {
i2p::context.SetBandwidth (value); i2p::context.SetBandwidth (value);
LogPrint(eLogInfo, "Daemon: bandwidth set to ", i2p::context.GetBandwidthLimit (), " KBps"); LogPrint(eLogInfo, "Daemon: bandwidth set to ", i2p::context.GetBandwidthLimit (), " KBps");
} }
@@ -175,24 +181,27 @@ namespace i2p
{ {
LogPrint(eLogInfo, "Daemon: unexpected bandwidth ", bandwidth, ". Set to 'low'"); LogPrint(eLogInfo, "Daemon: unexpected bandwidth ", bandwidth, ". Set to 'low'");
i2p::context.SetBandwidth (i2p::data::CAPS_FLAG_LOW_BANDWIDTH2); i2p::context.SetBandwidth (i2p::data::CAPS_FLAG_LOW_BANDWIDTH2);
} }
} }
} }
else if (isFloodfill) else if (isFloodfill)
{ {
LogPrint(eLogInfo, "Daemon: floodfill bandwidth set to 'extra'"); LogPrint(eLogInfo, "Daemon: floodfill bandwidth set to 'extra'");
i2p::context.SetBandwidth (i2p::data::CAPS_FLAG_EXTRA_BANDWIDTH1); i2p::context.SetBandwidth (i2p::data::CAPS_FLAG_EXTRA_BANDWIDTH1);
} }
else else
{ {
LogPrint(eLogInfo, "Daemon: bandwidth set to 'low'"); LogPrint(eLogInfo, "Daemon: bandwidth set to 'low'");
i2p::context.SetBandwidth (i2p::data::CAPS_FLAG_LOW_BANDWIDTH2); 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); std::string family; i2p::config::GetOption("family", family);
i2p::context.SetFamily (family); i2p::context.SetFamily (family);
if (family.length () > 0) if (family.length () > 0)
LogPrint(eLogInfo, "Daemon: family set to ", family); LogPrint(eLogInfo, "Daemon: family set to ", family);
bool trust; i2p::config::GetOption("trust.enabled", trust); bool trust; i2p::config::GetOption("trust.enabled", trust);
if (trust) if (trust)
@@ -211,7 +220,7 @@ namespace i2p
fams.insert (fam.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos)); fams.insert (fam.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos));
pos = comma + 1; pos = comma + 1;
} }
while (comma != std::string::npos); while (comma != std::string::npos);
i2p::transport::transports.RestrictRoutesToFamilies(fams); i2p::transport::transports.RestrictRoutesToFamilies(fams);
restricted = fams.size() > 0; restricted = fams.size() > 0;
} }
@@ -222,11 +231,11 @@ namespace i2p
{ {
comma = routers.find (',', pos); comma = routers.find (',', pos);
i2p::data::IdentHash ident; i2p::data::IdentHash ident;
ident.FromBase64 (routers.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos)); ident.FromBase64 (routers.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos));
idents.insert (ident); idents.insert (ident);
pos = comma + 1; pos = comma + 1;
} }
while (comma != std::string::npos); while (comma != std::string::npos);
LogPrint(eLogInfo, "Daemon: setting restricted routes to use ", idents.size(), " trusted routesrs"); LogPrint(eLogInfo, "Daemon: setting restricted routes to use ", idents.size(), " trusted routesrs");
i2p::transport::transports.RestrictRoutesToRouters(idents); i2p::transport::transports.RestrictRoutesToRouters(idents);
restricted = idents.size() > 0; restricted = idents.size() > 0;
@@ -242,7 +251,7 @@ namespace i2p
} }
return true; return true;
} }
bool Daemon_Singleton::start() bool Daemon_Singleton::start()
{ {
i2p::log::Logger().Start(); i2p::log::Logger().Start();
@@ -260,6 +269,7 @@ namespace i2p
LogPrint(eLogInfo, "Daemon: starting Transports"); LogPrint(eLogInfo, "Daemon: starting Transports");
if(!ssu) LogPrint(eLogInfo, "Daemon: ssu disabled"); if(!ssu) LogPrint(eLogInfo, "Daemon: ssu disabled");
if(!ntcp) LogPrint(eLogInfo, "Daemon: ntcp disabled"); if(!ntcp) LogPrint(eLogInfo, "Daemon: ntcp disabled");
i2p::transport::transports.Start(ntcp, ssu); i2p::transport::transports.Start(ntcp, ssu);
if (i2p::transport::transports.IsBoundNTCP() || i2p::transport::transports.IsBoundSSU()) { if (i2p::transport::transports.IsBoundNTCP() || i2p::transport::transports.IsBoundSSU()) {
LogPrint(eLogInfo, "Daemon: Transports started"); LogPrint(eLogInfo, "Daemon: Transports started");
@@ -270,7 +280,7 @@ namespace i2p
i2p::data::netdb.Stop(); i2p::data::netdb.Stop();
return false; return false;
} }
bool http; i2p::config::GetOption("http.enabled", http); bool http; i2p::config::GetOption("http.enabled", http);
if (http) { if (http) {
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr); std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
@@ -280,7 +290,7 @@ namespace i2p
d.httpServer->Start(); d.httpServer->Start();
} }
LogPrint(eLogInfo, "Daemon: starting Tunnels"); LogPrint(eLogInfo, "Daemon: starting Tunnels");
i2p::tunnel::tunnels.Start(); i2p::tunnel::tunnels.Start();

View File

@@ -11,9 +11,8 @@
#include "Log.h" #include "Log.h"
#include "Config.h" #include "Config.h"
#include "Tunnel.h" #include "Tunnel.h"
#include "TransitTunnel.h"
#include "Transports.h" #include "Transports.h"
#include "NetDb.h" #include "NetDb.hpp"
#include "HTTP.h" #include "HTTP.h"
#include "LeaseSet.h" #include "LeaseSet.h"
#include "Destination.h" #include "Destination.h"
@@ -109,6 +108,18 @@ namespace http {
s << seconds << " seconds"; 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) static void ShowTunnelDetails (std::stringstream& s, enum i2p::tunnel::TunnelState eState, int bytes)
{ {
std::string state; std::string state;
@@ -212,24 +223,14 @@ namespace http {
s << "<b>Family:</b> " << family << "<br>\r\n"; s << "<b>Family:</b> " << family << "<br>\r\n";
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n"; s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
s << "<b>Received:</b> "; s << "<b>Received:</b> ";
s << std::fixed << std::setprecision(2); ShowTraffic (s, i2p::transport::transports.GetTotalReceivedBytes ());
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";
s << " (" << (double) i2p::transport::transports.GetInBandwidth () / 1024 << " KiB/s)<br>\r\n"; s << " (" << (double) i2p::transport::transports.GetInBandwidth () / 1024 << " KiB/s)<br>\r\n";
s << "<b>Sent:</b> "; s << "<b>Sent:</b> ";
auto numKBytesSent = (double) i2p::transport::transports.GetTotalSentBytes () / 1024; ShowTraffic (s, i2p::transport::transports.GetTotalSentBytes ());
if (numKBytesSent < 1024)
s << numKBytesSent << " KiB";
else if (numKBytesSent < 1024 * 1024)
s << numKBytesSent / 1024 << " MiB";
else
s << numKBytesSent / 1024 / 1024 << " GiB";
s << " (" << (double) i2p::transport::transports.GetOutBandwidth () / 1024 << " KiB/s)<br>\r\n"; 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 << "<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 << "<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"; s << "<b>Router Ident:</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";

View File

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

View File

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

11
debian/changelog vendored
View File

@@ -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 i2pd (2.13.0-1) unstable; urgency=low
* updated to version 2.13.0/0.9.29 * updated to version 2.13.0/0.9.29
@@ -5,7 +14,7 @@ i2pd (2.13.0-1) unstable; urgency=low
* renamed logrotate to i2pd.logrotate * renamed logrotate to i2pd.logrotate
* fixed init.d script * 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 i2pd (2.12.0-1) unstable; urgency=low

4
debian/control vendored
View File

@@ -2,7 +2,7 @@ Source: i2pd
Section: net Section: net
Priority: optional Priority: optional
Maintainer: R4SAS <r4sas@i2pmail.org> 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 Standards-Version: 3.9.6
Homepage: http://i2pd.website/ Homepage: http://i2pd.website/
Vcs-Git: git://github.com/PurpleI2P/i2pd.git Vcs-Git: git://github.com/PurpleI2P/i2pd.git
@@ -13,7 +13,7 @@ Architecture: any
Pre-Depends: adduser Pre-Depends: adduser
Depends: ${shlibs:Depends}, ${misc:Depends} Depends: ${shlibs:Depends}, ${misc:Depends}
Suggests: tor, privoxy 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 I2P (Invisible Internet Protocol) is a universal anonymous network layer. All
communications over I2P are anonymous and end-to-end encrypted, participants communications over I2P are anonymous and end-to-end encrypted, participants
don't reveal their real IP addresses. don't reveal their real IP addresses.

2
debian/i2pd.upstart vendored
View File

@@ -6,4 +6,6 @@ stop on runlevel [016] or unmounting-filesystem
# these can be overridden in /etc/init/i2pd.override # these can be overridden in /etc/init/i2pd.override
env LOGFILE="/var/log/i2pd/i2pd.log" env LOGFILE="/var/log/i2pd/i2pd.log"
expect fork
exec /usr/sbin/i2pd --daemon --service --log=file --logfile=$LOGFILE exec /usr/sbin/i2pd --daemon --service --log=file --logfile=$LOGFILE

View File

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

View File

@@ -48,21 +48,23 @@ namespace config {
("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections (default: auto)") ("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections (default: auto)")
("ipv4", value<bool>()->zero_tokens()->default_value(true), "Enable communication through ipv4") ("ipv4", value<bool>()->zero_tokens()->default_value(true), "Enable communication through ipv4")
("ipv6", value<bool>()->zero_tokens()->default_value(false), "Enable communication through ipv6") ("ipv6", value<bool>()->zero_tokens()->default_value(false), "Enable communication through ipv6")
("netid", value<int>()->default_value(I2PD_NET_ID), "Specify NetID. Main I2P is 2") ("netid", value<int>()->default_value(I2PD_NET_ID), "Specify NetID. Main I2P is 2")
("daemon", value<bool>()->zero_tokens()->default_value(false), "Router will go to background after start") ("daemon", value<bool>()->zero_tokens()->default_value(false), "Router will go to background after start")
("service", value<bool>()->zero_tokens()->default_value(false), "Router will use system folders like '/var/lib/i2pd'") ("service", value<bool>()->zero_tokens()->default_value(false), "Router will use system folders like '/var/lib/i2pd'")
("notransit", value<bool>()->zero_tokens()->default_value(false), "Router will not accept transit tunnels at startup") ("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") ("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)") ("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") ("ntcp", value<bool>()->zero_tokens()->default_value(true), "Enable NTCP transport")
("ssu", value<bool>()->zero_tokens()->default_value(true), "Enable SSU 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 #ifdef _WIN32
("svcctl", value<std::string>()->default_value(""), "Windows service management ('install' or 'remove')") ("svcctl", value<std::string>()->default_value(""), "Windows service management ('install' or 'remove')")
("insomnia", value<bool>()->zero_tokens()->default_value(false), "Prevent system from sleeping") ("insomnia", value<bool>()->zero_tokens()->default_value(false), "Prevent system from sleeping")
("close", value<std::string>()->default_value("ask"), "Action on close: minimize, exit, ask") // TODO: add custom validator or something ("close", value<std::string>()->default_value("ask"), "Action on close: minimize, exit, ask") // TODO: add custom validator or something
#endif #endif
; ;
options_description limits("Limits options"); options_description limits("Limits options");
limits.add_options() limits.add_options()
("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)") ("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)")
@@ -86,14 +88,15 @@ namespace config {
("httpproxy.address", value<std::string>()->default_value("127.0.0.1"), "HTTP Proxy listen address") ("httpproxy.address", value<std::string>()->default_value("127.0.0.1"), "HTTP Proxy listen address")
("httpproxy.port", value<uint16_t>()->default_value(4444), "HTTP Proxy listen port") ("httpproxy.port", value<uint16_t>()->default_value(4444), "HTTP Proxy listen port")
("httpproxy.keys", value<std::string>()->default_value(""), "File to persist HTTP Proxy keys") ("httpproxy.keys", value<std::string>()->default_value(""), "File to persist HTTP Proxy keys")
("httpproxy.signaturetype", value<i2p::data::SigningKeyType>()->default_value(i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519), "Signature type for new keys. 7 (EdDSA) by default") ("httpproxy.signaturetype", value<i2p::data::SigningKeyType>()->default_value(i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519), "Signature type for new keys. 7 (EdDSA) by default")
("httpproxy.inbound.length", value<std::string>()->default_value("3"), "HTTP proxy inbound tunnel length") ("httpproxy.inbound.length", value<std::string>()->default_value("3"), "HTTP proxy inbound tunnel length")
("httpproxy.outbound.length", value<std::string>()->default_value("3"), "HTTP proxy outbound tunnel length") ("httpproxy.outbound.length", value<std::string>()->default_value("3"), "HTTP proxy outbound tunnel length")
("httpproxy.inbound.quantity", value<std::string>()->default_value("5"), "HTTP proxy inbound tunnels quantity") ("httpproxy.inbound.quantity", value<std::string>()->default_value("5"), "HTTP proxy inbound tunnels quantity")
("httpproxy.outbound.quantity", value<std::string>()->default_value("5"), "HTTP proxy outbound tunnels quantity") ("httpproxy.outbound.quantity", value<std::string>()->default_value("5"), "HTTP proxy outbound tunnels quantity")
("httpproxy.latency.min", value<std::string>()->default_value("0"), "HTTP proxy min latency for tunnels") ("httpproxy.latency.min", value<std::string>()->default_value("0"), "HTTP proxy min latency for tunnels")
("httpproxy.latency.max", value<std::string>()->default_value("0"), "HTTP proxy max latency for tunnels") ("httpproxy.latency.max", value<std::string>()->default_value("0"), "HTTP proxy max latency for tunnels")
("httpproxy.outproxy", value<std::string>()->default_value(""), "HTTP proxy upstream out proxy url") ("httpproxy.outproxy", value<std::string>()->default_value(""), "HTTP proxy upstream out proxy url")
("httpproxy.addresshelper", value<bool>()->default_value(true), "Enable or disable addresshelper")
; ;
options_description socksproxy("SOCKS Proxy options"); options_description socksproxy("SOCKS Proxy options");
@@ -102,20 +105,20 @@ namespace config {
("socksproxy.address", value<std::string>()->default_value("127.0.0.1"), "SOCKS Proxy listen address") ("socksproxy.address", value<std::string>()->default_value("127.0.0.1"), "SOCKS Proxy listen address")
("socksproxy.port", value<uint16_t>()->default_value(4447), "SOCKS Proxy listen port") ("socksproxy.port", value<uint16_t>()->default_value(4447), "SOCKS Proxy listen port")
("socksproxy.keys", value<std::string>()->default_value(""), "File to persist SOCKS Proxy keys") ("socksproxy.keys", value<std::string>()->default_value(""), "File to persist SOCKS Proxy keys")
("socksproxy.signaturetype", value<i2p::data::SigningKeyType>()->default_value(i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519), "Signature type for new keys. 7 (EdDSA) by default") ("socksproxy.signaturetype", value<i2p::data::SigningKeyType>()->default_value(i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519), "Signature type for new keys. 7 (EdDSA) by default")
("socksproxy.inbound.length", value<std::string>()->default_value("3"), "SOCKS proxy inbound tunnel length") ("socksproxy.inbound.length", value<std::string>()->default_value("3"), "SOCKS proxy inbound tunnel length")
("socksproxy.outbound.length", value<std::string>()->default_value("3"), "SOCKS proxy outbound tunnel length") ("socksproxy.outbound.length", value<std::string>()->default_value("3"), "SOCKS proxy outbound tunnel length")
("socksproxy.inbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy inbound tunnels quantity") ("socksproxy.inbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy inbound tunnels quantity")
("socksproxy.outbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy outbound tunnels quantity") ("socksproxy.outbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy outbound tunnels quantity")
("socksproxy.latency.min", value<std::string>()->default_value("0"), "SOCKS proxy min latency for tunnels") ("socksproxy.latency.min", value<std::string>()->default_value("0"), "SOCKS proxy min latency for tunnels")
("socksproxy.latency.max", value<std::string>()->default_value("0"), "SOCKS proxy max latency for tunnels") ("socksproxy.latency.max", value<std::string>()->default_value("0"), "SOCKS proxy max latency for tunnels")
("socksproxy.outproxy", value<std::string>()->default_value("127.0.0.1"), "Upstream outproxy address for SOCKS Proxy") ("socksproxy.outproxy", value<std::string>()->default_value("127.0.0.1"), "Upstream outproxy address for SOCKS Proxy")
("socksproxy.outproxyport", value<uint16_t>()->default_value(9050), "Upstream outproxy port for SOCKS Proxy") ("socksproxy.outproxyport", value<uint16_t>()->default_value(9050), "Upstream outproxy port for SOCKS Proxy")
; ;
options_description sam("SAM bridge options"); options_description sam("SAM bridge options");
sam.add_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.address", value<std::string>()->default_value("127.0.0.1"), "SAM listen address")
("sam.port", value<uint16_t>()->default_value(7656), "SAM listen port") ("sam.port", value<uint16_t>()->default_value(7656), "SAM listen port")
; ;
@@ -146,26 +149,26 @@ namespace config {
bool upnp_default = false; bool upnp_default = false;
#if (defined(USE_UPNP) && (defined(WIN32_APP) || defined(ANDROID))) #if (defined(USE_UPNP) && (defined(WIN32_APP) || defined(ANDROID)))
upnp_default = true; // enable UPNP for windows GUI and android by default upnp_default = true; // enable UPNP for windows GUI and android by default
#endif #endif
options_description upnp("UPnP options"); options_description upnp("UPnP options");
upnp.add_options() upnp.add_options()
("upnp.enabled", value<bool>()->default_value(upnp_default), "Enable or disable UPnP: automatic port forwarding") ("upnp.enabled", value<bool>()->default_value(upnp_default), "Enable or disable UPnP: automatic port forwarding")
("upnp.name", value<std::string>()->default_value("I2Pd"), "Name i2pd appears in UPnP forwardings list") ("upnp.name", value<std::string>()->default_value("I2Pd"), "Name i2pd appears in UPnP forwardings list")
; ;
options_description precomputation("Precomputation options"); options_description precomputation("Precomputation options");
precomputation.add_options() precomputation.add_options()
("precomputation.elgamal", ("precomputation.elgamal",
#if defined(__x86_64__) #if defined(__x86_64__)
value<bool>()->default_value(false), value<bool>()->default_value(false),
#else #else
value<bool>()->default_value(true), value<bool>()->default_value(true),
#endif #endif
"Enable or disable elgamal precomputation table") "Enable or disable elgamal precomputation table")
; ;
options_description reseed("Reseed options"); options_description reseed("Reseed options");
reseed.add_options() reseed.add_options()
("reseed.verify", value<bool>()->default_value(false), "Verify .su3 signature") ("reseed.verify", value<bool>()->default_value(false), "Verify .su3 signature")
("reseed.threshold", value<uint16_t>()->default_value(25), "Minimum number of known routers before requesting reseed") ("reseed.threshold", value<uint16_t>()->default_value(25), "Minimum number of known routers before requesting reseed")
@@ -185,17 +188,17 @@ namespace config {
"https://reseed.atomike.ninja/," "https://reseed.atomike.ninja/,"
"https://reseed.memcpy.io/," "https://reseed.memcpy.io/,"
"https://reseed.onion.im/," "https://reseed.onion.im/,"
"https://itoopie.atomike.ninja/," "https://itoopie.atomike.ninja/"
"https://randomrng.ddns.net/" // "https://randomrng.ddns.net/" // dead
), "Reseed URLs, separated by comma") ), "Reseed URLs, separated by comma")
; ;
options_description addressbook("AddressBook options"); options_description addressbook("AddressBook options");
addressbook.add_options() addressbook.add_options()
("addressbook.defaulturl", value<std::string>()->default_value( ("addressbook.defaulturl", value<std::string>()->default_value(
"http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt" "http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt"
), "AddressBook subscription URL for initial setup") ), "AddressBook subscription URL for initial setup")
("addressbook.subscriptions", value<std::string>()->default_value(""), ("addressbook.subscriptions", value<std::string>()->default_value(""),
"AddressBook subscriptions URLs, separated by comma"); "AddressBook subscriptions URLs, separated by comma");
options_description trust("Trust options"); options_description trust("Trust options");
@@ -204,7 +207,7 @@ namespace config {
("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops") ("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops")
("trust.routers", value<std::string>()->default_value(""), "Only Connect to these routers") ("trust.routers", value<std::string>()->default_value(""), "Only Connect to these routers")
("trust.hidden", value<bool>()->default_value(false), "Should we hide our router from other routers?"); ("trust.hidden", value<bool>()->default_value(false), "Should we hide our router from other routers?");
options_description websocket("Websocket Options"); options_description websocket("Websocket Options");
websocket.add_options() websocket.add_options()
("websockets.enabled", value<bool>()->default_value(false), "enable websocket server") ("websockets.enabled", value<bool>()->default_value(false), "enable websocket server")
@@ -213,50 +216,50 @@ namespace config {
options_description exploratory("Exploratory Options"); options_description exploratory("Exploratory Options");
exploratory.add_options() exploratory.add_options()
("exploratory.inbound.length", value<int>()->default_value(2), "Exploratory inbound tunnel length") ("exploratory.inbound.length", value<int>()->default_value(2), "Exploratory inbound tunnel length")
("exploratory.outbound.length", value<int>()->default_value(2), "Exploratory outbound tunnel length") ("exploratory.outbound.length", value<int>()->default_value(2), "Exploratory outbound tunnel length")
("exploratory.inbound.quantity", value<int>()->default_value(3), "Exploratory inbound tunnels quantity") ("exploratory.inbound.quantity", value<int>()->default_value(3), "Exploratory inbound tunnels quantity")
("exploratory.outbound.quantity", value<int>()->default_value(3), "Exploratory outbound tunnels quantity"); ("exploratory.outbound.quantity", value<int>()->default_value(3), "Exploratory outbound tunnels quantity");
m_OptionsDesc m_OptionsDesc
.add(general) .add(general)
.add(limits) .add(limits)
.add(httpserver) .add(httpserver)
.add(httpproxy) .add(httpproxy)
.add(socksproxy) .add(socksproxy)
.add(sam) .add(sam)
.add(bob) .add(bob)
.add(i2cp) .add(i2cp)
.add(i2pcontrol) .add(i2pcontrol)
.add(upnp) .add(upnp)
.add(precomputation) .add(precomputation)
.add(reseed) .add(reseed)
.add(addressbook) .add(addressbook)
.add(trust) .add(trust)
.add(websocket) .add(websocket)
.add(exploratory) .add(exploratory)
; ;
} }
void ParseCmdline(int argc, char* argv[], bool ignoreUnknown) void ParseCmdline(int argc, char* argv[], bool ignoreUnknown)
{ {
try try
{ {
auto style = boost::program_options::command_line_style::unix_style auto style = boost::program_options::command_line_style::unix_style
| boost::program_options::command_line_style::allow_long_disguise; | boost::program_options::command_line_style::allow_long_disguise;
style &= ~ boost::program_options::command_line_style::allow_guessing; style &= ~ boost::program_options::command_line_style::allow_guessing;
if (ignoreUnknown) if (ignoreUnknown)
store(command_line_parser(argc, argv).options(m_OptionsDesc).style (style).allow_unregistered().run(), m_Options); store(command_line_parser(argc, argv).options(m_OptionsDesc).style (style).allow_unregistered().run(), m_Options);
else else
store(parse_command_line(argc, argv, m_OptionsDesc, style), m_Options); store(parse_command_line(argc, argv, m_OptionsDesc, style), m_Options);
} }
catch (boost::program_options::error& e) catch (boost::program_options::error& e)
{ {
std::cerr << "args: " << e.what() << std::endl; std::cerr << "args: " << e.what() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!ignoreUnknown && (m_Options.count("help") || m_Options.count("h"))) if (!ignoreUnknown && (m_Options.count("help") || m_Options.count("h")))
{ {
std::cout << "i2pd version " << I2PD_VERSION << " (" << I2P_VERSION << ")" << std::endl; std::cout << "i2pd version " << I2PD_VERSION << " (" << I2P_VERSION << ")" << std::endl;
std::cout << m_OptionsDesc; std::cout << m_OptionsDesc;
@@ -269,17 +272,17 @@ namespace config {
std::ifstream config(path, std::ios::in); std::ifstream config(path, std::ios::in);
if (!config.is_open()) if (!config.is_open())
{ {
std::cerr << "missing/unreadable config file: " << path << std::endl; std::cerr << "missing/unreadable config file: " << path << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
try try
{ {
store(boost::program_options::parse_config_file(config, m_OptionsDesc), m_Options); store(boost::program_options::parse_config_file(config, m_OptionsDesc), m_Options);
} }
catch (boost::program_options::error& e) catch (boost::program_options::error& e)
{ {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View File

@@ -255,9 +255,11 @@ namespace datagram
} }
if(m_CurrentRemoteLease && m_CurrentRemoteLease->ExpiresWithin(DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW)) { if(m_CurrentRemoteLease && m_CurrentRemoteLease->ExpiresWithin(DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW)) {
// bad lease, switch to next one // bad lease, switch to next one
if(m_RemoteLeaseSet && m_RemoteLeaseSet->IsExpired())
m_RemoteLeaseSet = m_LocalDestination->FindLeaseSet(m_RemoteIdent);
if(m_RemoteLeaseSet) { if(m_RemoteLeaseSet) {
auto ls = m_RemoteLeaseSet->GetNonExpiredLeasesExcluding([&](const i2p::data::Lease& l) -> bool { auto ls = m_RemoteLeaseSet->GetNonExpiredLeasesExcluding([&](const i2p::data::Lease& l) -> bool {
return l.tunnelGateway == m_CurrentRemoteLease->tunnelGateway; return l.tunnelID == m_CurrentRemoteLease->tunnelID;
}); });
auto sz = ls.size(); auto sz = ls.size();
if (sz) { if (sz) {
@@ -278,7 +280,7 @@ namespace datagram
m_CurrentOutboundTunnel = m_LocalDestination->GetTunnelPool()->GetNextOutboundTunnel(m_CurrentOutboundTunnel); m_CurrentOutboundTunnel = m_LocalDestination->GetTunnelPool()->GetNextOutboundTunnel(m_CurrentOutboundTunnel);
} }
// switch lease if bad // switch lease if bad
if(m_CurrentRemoteLease == nullptr || m_CurrentRemoteLease->ExpiresWithin(DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW)) { if(m_CurrentRemoteLease && m_CurrentRemoteLease->ExpiresWithin(DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW)) {
if(!m_RemoteLeaseSet) { if(!m_RemoteLeaseSet) {
m_RemoteLeaseSet = m_LocalDestination->FindLeaseSet(m_RemoteIdent); m_RemoteLeaseSet = m_LocalDestination->FindLeaseSet(m_RemoteIdent);
} }
@@ -299,6 +301,17 @@ namespace datagram
LogPrint(eLogWarning, "DatagramSession: no remote lease set found for ", m_RemoteIdent.ToBase32()); LogPrint(eLogWarning, "DatagramSession: no remote lease set found for ", m_RemoteIdent.ToBase32());
return nullptr; return nullptr;
} }
} else if (!m_CurrentRemoteLease) {
if(!m_RemoteLeaseSet) m_RemoteLeaseSet = m_LocalDestination->FindLeaseSet(m_RemoteIdent);
if (m_RemoteLeaseSet)
{
auto ls = m_RemoteLeaseSet->GetNonExpiredLeases();
auto sz = ls.size();
if (sz) {
auto idx = rand() % sz;
m_CurrentRemoteLease = ls[idx];
}
}
} }
path->outboundTunnel = m_CurrentOutboundTunnel; path->outboundTunnel = m_CurrentOutboundTunnel;
path->remoteLease = m_CurrentRemoteLease; path->remoteLease = m_CurrentRemoteLease;
@@ -346,7 +359,7 @@ namespace datagram
void DatagramSession::ScheduleFlushSendQueue() void DatagramSession::ScheduleFlushSendQueue()
{ {
boost::posix_time::milliseconds dlt(100); boost::posix_time::milliseconds dlt(10);
m_SendQueueTimer.expires_from_now(dlt); m_SendQueueTimer.expires_from_now(dlt);
auto self = shared_from_this(); auto self = shared_from_this();
m_SendQueueTimer.async_wait([self](const boost::system::error_code & ec) { if(ec) return; self->FlushSendQueue(); }); m_SendQueueTimer.async_wait([self](const boost::system::error_code & ec) { if(ec) return; self->FlushSendQueue(); });

View File

@@ -19,28 +19,28 @@ namespace client
} }
namespace datagram namespace datagram
{ {
// milliseconds for max session idle time // milliseconds for max session idle time
const uint64_t DATAGRAM_SESSION_MAX_IDLE = 10 * 60 * 1000; const uint64_t DATAGRAM_SESSION_MAX_IDLE = 10 * 60 * 1000;
// milliseconds for how long we try sticking to a dead routing path before trying to switch // milliseconds for how long we try sticking to a dead routing path before trying to switch
const uint64_t DATAGRAM_SESSION_PATH_TIMEOUT = 10 * 1000; const uint64_t DATAGRAM_SESSION_PATH_TIMEOUT = 10 * 1000;
// milliseconds interval a routing path is used before switching // milliseconds interval a routing path is used before switching
const uint64_t DATAGRAM_SESSION_PATH_SWITCH_INTERVAL = 20 * 60 * 1000; const uint64_t DATAGRAM_SESSION_PATH_SWITCH_INTERVAL = 20 * 60 * 1000;
// milliseconds before lease expire should we try switching leases // milliseconds before lease expire should we try switching leases
const uint64_t DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW = 10 * 1000; const uint64_t DATAGRAM_SESSION_LEASE_HANDOVER_WINDOW = 30 * 1000;
// milliseconds fudge factor for leases handover // milliseconds fudge factor for leases handover
const uint64_t DATAGRAM_SESSION_LEASE_HANDOVER_FUDGE = 1000; const uint64_t DATAGRAM_SESSION_LEASE_HANDOVER_FUDGE = 1000;
// milliseconds minimum time between path switches // milliseconds minimum time between path switches
const uint64_t DATAGRAM_SESSION_PATH_MIN_LIFETIME = 5 * 1000; const uint64_t DATAGRAM_SESSION_PATH_MIN_LIFETIME = 5 * 1000;
// max 64 messages buffered in send queue for each datagram session // max 64 messages buffered in send queue for each datagram session
const size_t DATAGRAM_SEND_QUEUE_MAX_SIZE = 64; const size_t DATAGRAM_SEND_QUEUE_MAX_SIZE = 64;
class DatagramSession : public std::enable_shared_from_this<DatagramSession> class DatagramSession : public std::enable_shared_from_this<DatagramSession>
{ {
public: public:
DatagramSession(i2p::client::ClientDestination * localDestination, const i2p::data::IdentHash & remoteIdent); DatagramSession(i2p::client::ClientDestination * localDestination, const i2p::data::IdentHash & remoteIdent);
void Start (); void Start ();
void Stop (); void Stop ();
/** @brief ack the garlic routing path */ /** @brief ack the garlic routing path */
@@ -56,7 +56,7 @@ namespace datagram
std::shared_ptr<const i2p::data::IdentHash> IBGW; std::shared_ptr<const i2p::data::IdentHash> IBGW;
std::shared_ptr<const i2p::data::IdentHash> OBEP; std::shared_ptr<const i2p::data::IdentHash> OBEP;
const uint64_t activity; const uint64_t activity;
Info() : IBGW(nullptr), OBEP(nullptr), activity(0) {} Info() : IBGW(nullptr), OBEP(nullptr), activity(0) {}
Info(const uint8_t * ibgw, const uint8_t * obep, const uint64_t a) : Info(const uint8_t * ibgw, const uint8_t * obep, const uint64_t a) :
activity(a) { activity(a) {
@@ -77,7 +77,7 @@ namespace datagram
void HandleSend(std::shared_ptr<I2NPMessage> msg); void HandleSend(std::shared_ptr<I2NPMessage> msg);
std::shared_ptr<i2p::garlic::GarlicRoutingPath> GetSharedRoutingPath(); std::shared_ptr<i2p::garlic::GarlicRoutingPath> GetSharedRoutingPath();
void HandleLeaseSetUpdated(std::shared_ptr<i2p::data::LeaseSet> ls); void HandleLeaseSetUpdated(std::shared_ptr<i2p::data::LeaseSet> ls);
private: private:
@@ -95,16 +95,16 @@ namespace datagram
typedef std::shared_ptr<DatagramSession> DatagramSession_ptr; typedef std::shared_ptr<DatagramSession> DatagramSession_ptr;
const size_t MAX_DATAGRAM_SIZE = 32768; const size_t MAX_DATAGRAM_SIZE = 32768;
class DatagramDestination class DatagramDestination
{ {
typedef std::function<void (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)> Receiver; typedef std::function<void (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)> Receiver;
public: public:
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner); DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner);
~DatagramDestination (); ~DatagramDestination ();
void SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash & ident, uint16_t fromPort = 0, uint16_t toPort = 0); void SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash & ident, uint16_t fromPort = 0, uint16_t toPort = 0);
void HandleDataMessagePayload (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len); void HandleDataMessagePayload (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
@@ -116,21 +116,21 @@ namespace datagram
void ResetReceiver (uint16_t port) { std::lock_guard<std::mutex> lock(m_ReceiversMutex); m_ReceiversByPorts.erase (port); }; void ResetReceiver (uint16_t port) { std::lock_guard<std::mutex> lock(m_ReceiversMutex); m_ReceiversByPorts.erase (port); };
std::shared_ptr<DatagramSession::Info> GetInfoForRemote(const i2p::data::IdentHash & remote); std::shared_ptr<DatagramSession::Info> GetInfoForRemote(const i2p::data::IdentHash & remote);
// clean up stale sessions // clean up stale sessions
void CleanUp (); void CleanUp ();
private: private:
std::shared_ptr<DatagramSession> ObtainSession(const i2p::data::IdentHash & ident); std::shared_ptr<DatagramSession> ObtainSession(const i2p::data::IdentHash & ident);
std::shared_ptr<I2NPMessage> CreateDataMessage (const uint8_t * payload, size_t len, uint16_t fromPort, uint16_t toPort); std::shared_ptr<I2NPMessage> CreateDataMessage (const uint8_t * payload, size_t len, uint16_t fromPort, uint16_t toPort);
void HandleDatagram (uint16_t fromPort, uint16_t toPort, uint8_t *const& buf, size_t len); void HandleDatagram (uint16_t fromPort, uint16_t toPort, uint8_t *const& buf, size_t len);
/** find a receiver by port, if none by port is found try default receiever, otherwise returns nullptr */ /** find a receiver by port, if none by port is found try default receiever, otherwise returns nullptr */
Receiver FindReceiver(uint16_t port); Receiver FindReceiver(uint16_t port);
private: private:
i2p::client::ClientDestination * m_Owner; i2p::client::ClientDestination * m_Owner;
i2p::data::IdentityEx m_Identity; i2p::data::IdentityEx m_Identity;
@@ -142,9 +142,8 @@ namespace datagram
i2p::data::GzipInflator m_Inflator; i2p::data::GzipInflator m_Inflator;
i2p::data::GzipDeflator m_Deflator; i2p::data::GzipDeflator m_Deflator;
}; };
} }
} }
#endif #endif

View File

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

View File

@@ -17,7 +17,7 @@
#include "Crypto.h" #include "Crypto.h"
#include "LeaseSet.h" #include "LeaseSet.h"
#include "Garlic.h" #include "Garlic.h"
#include "NetDb.h" #include "NetDb.hpp"
#include "Streaming.h" #include "Streaming.h"
#include "Datagram.h" #include "Datagram.h"
@@ -27,16 +27,16 @@ namespace client
{ {
const uint8_t PROTOCOL_TYPE_STREAMING = 6; const uint8_t PROTOCOL_TYPE_STREAMING = 6;
const uint8_t PROTOCOL_TYPE_DATAGRAM = 17; const uint8_t PROTOCOL_TYPE_DATAGRAM = 17;
const uint8_t PROTOCOL_TYPE_RAW = 18; const uint8_t PROTOCOL_TYPE_RAW = 18;
const int PUBLISH_CONFIRMATION_TIMEOUT = 5; // in seconds const int PUBLISH_CONFIRMATION_TIMEOUT = 5; // in seconds
const int PUBLISH_VERIFICATION_TIMEOUT = 10; // in seconds after successfull publish const int PUBLISH_VERIFICATION_TIMEOUT = 10; // in seconds after successfull publish
const int PUBLISH_MIN_INTERVAL = 20; // in seconds const int PUBLISH_MIN_INTERVAL = 20; // in seconds
const int PUBLISH_REGULAR_VERIFICATION_INTERNAL = 100; // in seconds periodically const int PUBLISH_REGULAR_VERIFICATION_INTERNAL = 100; // in seconds periodically
const int LEASESET_REQUEST_TIMEOUT = 5; // in seconds const int LEASESET_REQUEST_TIMEOUT = 5; // in seconds
const int MAX_LEASESET_REQUEST_TIMEOUT = 40; // in seconds const int MAX_LEASESET_REQUEST_TIMEOUT = 40; // in seconds
const int DESTINATION_CLEANUP_TIMEOUT = 3; // in minutes const int DESTINATION_CLEANUP_TIMEOUT = 3; // in minutes
const unsigned int MAX_NUM_FLOODFILLS_PER_REQUEST = 7; const unsigned int MAX_NUM_FLOODFILLS_PER_REQUEST = 7;
// I2CP // I2CP
const char I2CP_PARAM_INBOUND_TUNNEL_LENGTH[] = "inbound.length"; const char I2CP_PARAM_INBOUND_TUNNEL_LENGTH[] = "inbound.length";
const int DEFAULT_INBOUND_TUNNEL_LENGTH = 3; const int DEFAULT_INBOUND_TUNNEL_LENGTH = 3;
@@ -56,7 +56,7 @@ namespace client
const int DEFAULT_MIN_TUNNEL_LATENCY = 0; const int DEFAULT_MIN_TUNNEL_LATENCY = 0;
const char I2CP_PARAM_MAX_TUNNEL_LATENCY[] = "latency.max"; const char I2CP_PARAM_MAX_TUNNEL_LATENCY[] = "latency.max";
const int DEFAULT_MAX_TUNNEL_LATENCY = 0; const int DEFAULT_MAX_TUNNEL_LATENCY = 0;
typedef std::function<void (std::shared_ptr<i2p::stream::Stream> stream)> StreamRequestComplete; typedef std::function<void (std::shared_ptr<i2p::stream::Stream> stream)> StreamRequestComplete;
class LeaseSetDestination: public i2p::garlic::GarlicDestination, class LeaseSetDestination: public i2p::garlic::GarlicDestination,
@@ -78,24 +78,24 @@ namespace client
{ {
for (auto& it: requestComplete) it (ls); for (auto& it: requestComplete) it (ls);
requestComplete.clear (); requestComplete.clear ();
} }
}; };
public: public:
LeaseSetDestination (bool isPublic, const std::map<std::string, std::string> * params = nullptr); LeaseSetDestination (bool isPublic, const std::map<std::string, std::string> * params = nullptr);
~LeaseSetDestination (); ~LeaseSetDestination ();
virtual bool Start (); virtual bool Start ();
virtual bool Stop (); virtual bool Stop ();
bool IsRunning () const { return m_IsRunning; }; bool IsRunning () const { return m_IsRunning; };
boost::asio::io_service& GetService () { return m_Service; }; boost::asio::io_service& GetService () { return m_Service; };
std::shared_ptr<i2p::tunnel::TunnelPool> GetTunnelPool () { return m_Pool; }; std::shared_ptr<i2p::tunnel::TunnelPool> GetTunnelPool () { return m_Pool; };
bool IsReady () const { return m_LeaseSet && !m_LeaseSet->IsExpired () && m_Pool->GetOutboundTunnels ().size () > 0; }; bool IsReady () const { return m_LeaseSet && !m_LeaseSet->IsExpired () && m_Pool->GetOutboundTunnels ().size () > 0; };
std::shared_ptr<const i2p::data::LeaseSet> FindLeaseSet (const i2p::data::IdentHash& ident); std::shared_ptr<const i2p::data::LeaseSet> FindLeaseSet (const i2p::data::IdentHash& ident);
bool RequestDestination (const i2p::data::IdentHash& dest, RequestComplete requestComplete = nullptr); bool RequestDestination (const i2p::data::IdentHash& dest, RequestComplete requestComplete = nullptr);
void CancelDestinationRequest (const i2p::data::IdentHash& dest, bool notify = true); void CancelDestinationRequest (const i2p::data::IdentHash& dest, bool notify = true);
// implements GarlicDestination // implements GarlicDestination
std::shared_ptr<const i2p::data::LocalLeaseSet> GetLeaseSet (); std::shared_ptr<const i2p::data::LocalLeaseSet> GetLeaseSet ();
@@ -105,7 +105,7 @@ namespace client
// override GarlicDestination // override GarlicDestination
bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag); bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag);
void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg); void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
void ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg); void ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
void SetLeaseSetUpdated (); void SetLeaseSetUpdated ();
protected: protected:
@@ -115,10 +115,10 @@ namespace client
// I2CP // I2CP
virtual void HandleDataMessage (const uint8_t * buf, size_t len) = 0; virtual void HandleDataMessage (const uint8_t * buf, size_t len) = 0;
virtual void CreateNewLeaseSet (std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels) = 0; virtual void CreateNewLeaseSet (std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels) = 0;
private: private:
void Run (); void Run ();
void UpdateLeaseSet (); void UpdateLeaseSet ();
void Publish (); void Publish ();
void HandlePublishConfirmationTimer (const boost::system::error_code& ecode); void HandlePublishConfirmationTimer (const boost::system::error_code& ecode);
@@ -126,18 +126,18 @@ namespace client
void HandlePublishDelayTimer (const boost::system::error_code& ecode); void HandlePublishDelayTimer (const boost::system::error_code& ecode);
void HandleDatabaseStoreMessage (const uint8_t * buf, size_t len); void HandleDatabaseStoreMessage (const uint8_t * buf, size_t len);
void HandleDatabaseSearchReplyMessage (const uint8_t * buf, size_t len); void HandleDatabaseSearchReplyMessage (const uint8_t * buf, size_t len);
void HandleDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg); void HandleDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
void RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete); void RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete);
bool SendLeaseSetRequest (const i2p::data::IdentHash& dest, std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request); bool SendLeaseSetRequest (const i2p::data::IdentHash& dest, std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request);
void HandleRequestTimoutTimer (const boost::system::error_code& ecode, const i2p::data::IdentHash& dest); void HandleRequestTimoutTimer (const boost::system::error_code& ecode, const i2p::data::IdentHash& dest);
void HandleCleanupTimer (const boost::system::error_code& ecode); void HandleCleanupTimer (const boost::system::error_code& ecode);
void CleanupRemoteLeaseSets (); void CleanupRemoteLeaseSets ();
private: private:
volatile bool m_IsRunning; volatile bool m_IsRunning;
std::thread * m_Thread; std::thread * m_Thread;
boost::asio::io_service m_Service; boost::asio::io_service m_Service;
mutable std::mutex m_RemoteLeaseSetsMutex; mutable std::mutex m_RemoteLeaseSetsMutex;
std::map<i2p::data::IdentHash, std::shared_ptr<i2p::data::LeaseSet> > m_RemoteLeaseSets; std::map<i2p::data::IdentHash, std::shared_ptr<i2p::data::LeaseSet> > m_RemoteLeaseSets;
@@ -150,16 +150,16 @@ namespace client
uint32_t m_PublishReplyToken; uint32_t m_PublishReplyToken;
uint64_t m_LastSubmissionTime; // in seconds uint64_t m_LastSubmissionTime; // in seconds
std::set<i2p::data::IdentHash> m_ExcludedFloodfills; // for publishing std::set<i2p::data::IdentHash> m_ExcludedFloodfills; // for publishing
boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer, boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer,
m_PublishDelayTimer, m_CleanupTimer; m_PublishDelayTimer, m_CleanupTimer;
public: public:
// for HTTP only // for HTTP only
int GetNumRemoteLeaseSets () const { return m_RemoteLeaseSets.size (); }; int GetNumRemoteLeaseSets () const { return m_RemoteLeaseSets.size (); };
const decltype(m_RemoteLeaseSets)& GetLeaseSets () const { return m_RemoteLeaseSets; }; const decltype(m_RemoteLeaseSets)& GetLeaseSets () const { return m_RemoteLeaseSets; };
}; };
class ClientDestination: public LeaseSetDestination class ClientDestination: public LeaseSetDestination
{ {
@@ -171,16 +171,16 @@ namespace client
// if cancelled before ready, informs promise with nullptr // if cancelled before ready, informs promise with nullptr
void Ready(ReadyPromise & p); void Ready(ReadyPromise & p);
#endif #endif
ClientDestination (const i2p::data::PrivateKeys& keys, bool isPublic, const std::map<std::string, std::string> * params = nullptr); ClientDestination (const i2p::data::PrivateKeys& keys, bool isPublic, const std::map<std::string, std::string> * params = nullptr);
~ClientDestination (); ~ClientDestination ();
bool Start (); virtual bool Start ();
bool Stop (); virtual bool Stop ();
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; }; const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
void Sign (const uint8_t * buf, int len, uint8_t * signature) const { m_Keys.Sign (buf, len, signature); }; void Sign (const uint8_t * buf, int len, uint8_t * signature) const { m_Keys.Sign (buf, len, signature); };
// streaming // streaming
std::shared_ptr<i2p::stream::StreamingDestination> CreateStreamingDestination (int port, bool gzip = true); // additional std::shared_ptr<i2p::stream::StreamingDestination> CreateStreamingDestination (int port, bool gzip = true); // additional
std::shared_ptr<i2p::stream::StreamingDestination> GetStreamingDestination (int port = 0) const; std::shared_ptr<i2p::stream::StreamingDestination> GetStreamingDestination (int port = 0) const;
@@ -191,31 +191,31 @@ namespace client
void StopAcceptingStreams (); void StopAcceptingStreams ();
bool IsAcceptingStreams () const; bool IsAcceptingStreams () const;
void AcceptOnce (const i2p::stream::StreamingDestination::Acceptor& acceptor); void AcceptOnce (const i2p::stream::StreamingDestination::Acceptor& acceptor);
// datagram // datagram
i2p::datagram::DatagramDestination * GetDatagramDestination () const { return m_DatagramDestination; }; i2p::datagram::DatagramDestination * GetDatagramDestination () const { return m_DatagramDestination; };
i2p::datagram::DatagramDestination * CreateDatagramDestination (); i2p::datagram::DatagramDestination * CreateDatagramDestination ();
// implements LocalDestination // implements LocalDestination
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; }; const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
std::shared_ptr<const i2p::data::IdentityEx> GetIdentity () const { return m_Keys.GetPublic (); }; std::shared_ptr<const i2p::data::IdentityEx> GetIdentity () const { return m_Keys.GetPublic (); };
protected: protected:
void CleanupDestination (); void CleanupDestination ();
// I2CP // I2CP
void HandleDataMessage (const uint8_t * buf, size_t len); void HandleDataMessage (const uint8_t * buf, size_t len);
void CreateNewLeaseSet (std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels); void CreateNewLeaseSet (std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels);
private: private:
std::shared_ptr<ClientDestination> GetSharedFromThis () std::shared_ptr<ClientDestination> GetSharedFromThis ()
{ return std::static_pointer_cast<ClientDestination>(shared_from_this ()); } { return std::static_pointer_cast<ClientDestination>(shared_from_this ()); }
void PersistTemporaryKeys (); void PersistTemporaryKeys ();
#ifdef I2LUA #ifdef I2LUA
void ScheduleCheckForReady(ReadyPromise * p); void ScheduleCheckForReady(ReadyPromise * p);
void HandleCheckForReady(const boost::system::error_code & ecode, ReadyPromise * p); void HandleCheckForReady(const boost::system::error_code & ecode, ReadyPromise * p);
#endif #endif
private: private:
i2p::data::PrivateKeys m_Keys; i2p::data::PrivateKeys m_Keys;
@@ -226,13 +226,13 @@ namespace client
i2p::datagram::DatagramDestination * m_DatagramDestination; i2p::datagram::DatagramDestination * m_DatagramDestination;
boost::asio::deadline_timer m_ReadyChecker; boost::asio::deadline_timer m_ReadyChecker;
public: public:
// for HTTP only // for HTTP only
std::vector<std::shared_ptr<const i2p::stream::Stream> > GetAllStreams () const; std::vector<std::shared_ptr<const i2p::stream::Stream> > GetAllStreams () const;
}; };
} }
} }
#endif #endif

View File

View File

@@ -437,17 +437,18 @@ namespace garlic
if (it != m_Tags.end ()) if (it != m_Tags.end ())
{ {
// tag found. Use AES // tag found. Use AES
auto decryption = it->second;
m_Tags.erase (it); // tag might be used only once
if (length >= 32) if (length >= 32)
{ {
uint8_t iv[32]; // IV is first 16 bytes uint8_t iv[32]; // IV is first 16 bytes
SHA256(buf, 32, iv); SHA256(buf, 32, iv);
it->second->SetIV (iv); decryption->SetIV (iv);
it->second->Decrypt (buf + 32, length - 32, buf + 32); decryption->Decrypt (buf + 32, length - 32, buf + 32);
HandleAESBlock (buf + 32, length - 32, it->second, msg->from); HandleAESBlock (buf + 32, length - 32, decryption, msg->from);
} }
else else
LogPrint (eLogWarning, "Garlic: message length ", length, " is less than 32 bytes"); LogPrint (eLogWarning, "Garlic: message length ", length, " is less than 32 bytes");
m_Tags.erase (it); // tag might be used only once
} }
else else
{ {

View File

@@ -323,7 +323,7 @@ namespace crypto
for (int i = 63; i >= 0; i--) for (int i = 63; i >= 0; i--)
{ {
uint16_t sum = buf[i] + other.buf[i] + carry; uint16_t sum = buf[i] + other.buf[i] + carry;
ret.buf[i] = sum & 0xFF; ret.buf[i] = sum;
carry = sum >> 8; carry = sum >> 8;
} }
return ret; return ret;
@@ -333,9 +333,10 @@ namespace crypto
{ {
for (int i = 63; i >= 0; i--) for (int i = 63; i >= 0; i--)
{ {
if (!c) return;
c += buf[i]; c += buf[i];
buf[i] = c; buf[i] = c;
c >>= 8; c >>= 8;
} }
} }
@@ -438,5 +439,92 @@ namespace crypto
memset (iv, 0, 64); memset (iv, 0, 64);
H (iv, buf, len, digest); H (iv, buf, len, digest);
} }
// reverse order
struct GOSTR3411_2012_CTX
{
GOST3411Block h, N, s, m;
size_t len;
bool is512;
};
GOSTR3411_2012_CTX * GOSTR3411_2012_CTX_new ()
{
return new GOSTR3411_2012_CTX;
}
void GOSTR3411_2012_CTX_free (GOSTR3411_2012_CTX * ctx)
{
delete ctx;
}
void GOSTR3411_2012_CTX_Init (GOSTR3411_2012_CTX * ctx, bool is512)
{
uint8_t iv[64];
memset (iv, is512 ? 0 : 1, 64);
memcpy (ctx->h.buf, iv, 64);
memset (ctx->N.buf, 0, 64);
memset (ctx->s.buf, 0, 64);
ctx->len = 0;
ctx->is512 = is512;
}
void GOSTR3411_2012_CTX_Update (const uint8_t * buf, size_t len, GOSTR3411_2012_CTX * ctx)
{
if (!len) return;
if (ctx->len > 0) // something left from buffer
{
size_t l = 64 - ctx->len;
if (len < l) l = len;
for (size_t i = 0; i < l; i++)
ctx->m.buf[ctx->len + i] = buf[l-i-1]; // invert
ctx->len += l; len -= l; buf += l;
ctx->h = gN (ctx->N, ctx->h, ctx->m);
ctx->N.Add (512);
ctx->s = ctx->m + ctx->s;
}
while (len >= 64)
{
for (size_t i = 0; i < 64; i++)
ctx->m.buf[i] = buf[63-i]; // invert
len -= 64; buf += 64;
ctx->h = gN (ctx->N, ctx->h, ctx->m);
ctx->N.Add (512);
ctx->s = ctx->m + ctx->s;
}
if (len > 0) // carry remaining
{
for (size_t i = 0; i < len; i++)
ctx->m.buf[i] = buf[len-i-1]; // invert
}
ctx->len = len;
}
void GOSTR3411_2012_CTX_Finish (uint8_t * digest, GOSTR3411_2012_CTX * ctx)
{
GOST3411Block m;
size_t padding = 64 - ctx->len;
if (padding)
{
memset (m.buf, 0, padding - 1);
m.buf[padding - 1] = 1;
}
memcpy (m.buf + padding, ctx->m.buf, ctx->len);
ctx->h = gN (ctx->N, ctx->h, m);
ctx->N.Add (ctx->len*8);
ctx->s = m + ctx->s;
GOST3411Block N0;
memset (N0.buf, 0, 64);
ctx->h = gN (N0, ctx->h, ctx->N);
ctx->h = gN (N0, ctx->h, ctx->s);
size_t sz = ctx->is512 ? 64 : 32;
for (size_t i = 0; i < sz; i++)
digest[i] = ctx->h.buf[sz - i - 1];
}
} }
} }

View File

@@ -45,8 +45,17 @@ namespace crypto
std::unique_ptr<GOSTR3410Curve>& GetGOSTR3410Curve (GOSTR3410ParamSet paramSet); std::unique_ptr<GOSTR3410Curve>& GetGOSTR3410Curve (GOSTR3410ParamSet paramSet);
// Big Endian
void GOSTR3411_2012_256 (const uint8_t * buf, size_t len, uint8_t * digest); void GOSTR3411_2012_256 (const uint8_t * buf, size_t len, uint8_t * digest);
void GOSTR3411_2012_512 (const uint8_t * buf, size_t len, uint8_t * digest); void GOSTR3411_2012_512 (const uint8_t * buf, size_t len, uint8_t * digest);
// Little Endian
struct GOSTR3411_2012_CTX;
GOSTR3411_2012_CTX * GOSTR3411_2012_CTX_new ();
void GOSTR3411_2012_CTX_Init (GOSTR3411_2012_CTX * ctx, bool is512 = true);
void GOSTR3411_2012_CTX_Update (const uint8_t * buf, size_t len, GOSTR3411_2012_CTX * ctx);
void GOSTR3411_2012_CTX_Finish (uint8_t * digest, GOSTR3411_2012_CTX * ctx);
void GOSTR3411_2012_CTX_free (GOSTR3411_2012_CTX * ctx);
} }
} }

View File

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

View File

@@ -209,6 +209,7 @@ namespace tunnel
std::shared_ptr<I2NPMessage> NewI2NPMessage (); std::shared_ptr<I2NPMessage> NewI2NPMessage ();
std::shared_ptr<I2NPMessage> NewI2NPShortMessage (); std::shared_ptr<I2NPMessage> NewI2NPShortMessage ();
std::shared_ptr<I2NPMessage> NewI2NPTunnelMessage ();
std::shared_ptr<I2NPMessage> NewI2NPMessage (size_t len); std::shared_ptr<I2NPMessage> NewI2NPMessage (size_t len);
std::shared_ptr<I2NPMessage> CreateI2NPMessage (I2NPMessageType msgType, const uint8_t * buf, size_t len, uint32_t replyMsgID = 0); std::shared_ptr<I2NPMessage> CreateI2NPMessage (I2NPMessageType msgType, const uint8_t * buf, size_t len, uint32_t replyMsgID = 0);

View File

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

View File

@@ -30,7 +30,8 @@ namespace data
bool ExpiresWithin( const uint64_t t, const uint64_t fudge = 1000 ) const { bool ExpiresWithin( const uint64_t t, const uint64_t fudge = 1000 ) const {
auto expire = i2p::util::GetMillisecondsSinceEpoch (); auto expire = i2p::util::GetMillisecondsSinceEpoch ();
if(fudge) expire += rand() % fudge; if(fudge) expire += rand() % fudge;
return endDate - expire >= t; if (endDate < expire) return true;
return (endDate - expire) < t;
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -21,8 +21,8 @@ namespace transport
{ {
uint8_t pubKey[256]; uint8_t pubKey[256];
uint8_t HXxorHI[32]; uint8_t HXxorHI[32];
}; };
struct NTCPPhase2 struct NTCPPhase2
{ {
uint8_t pubKey[256]; uint8_t pubKey[256];
@@ -31,17 +31,17 @@ namespace transport
uint8_t hxy[32]; uint8_t hxy[32];
uint8_t timestamp[4]; uint8_t timestamp[4];
uint8_t filler[12]; uint8_t filler[12];
} encrypted; } encrypted;
}; };
const size_t NTCP_MAX_MESSAGE_SIZE = 16384; const size_t NTCP_MAX_MESSAGE_SIZE = 16384;
const size_t NTCP_BUFFER_SIZE = 1028; // fits 1 tunnel data message const size_t NTCP_BUFFER_SIZE = 1028; // fits 1 tunnel data message
const int NTCP_CONNECT_TIMEOUT = 5; // 5 seconds const int NTCP_CONNECT_TIMEOUT = 5; // 5 seconds
const int NTCP_ESTABLISH_TIMEOUT = 10; // 10 seconds const int NTCP_ESTABLISH_TIMEOUT = 10; // 10 seconds
const int NTCP_TERMINATION_TIMEOUT = 120; // 2 minutes const int NTCP_TERMINATION_TIMEOUT = 120; // 2 minutes
const int NTCP_TERMINATION_CHECK_TIMEOUT = 30; // 30 seconds const int NTCP_TERMINATION_CHECK_TIMEOUT = 30; // 30 seconds
const size_t NTCP_DEFAULT_PHASE3_SIZE = 2/*size*/ + i2p::data::DEFAULT_IDENTITY_SIZE/*387*/ + 4/*ts*/ + 15/*padding*/ + 40/*signature*/; // 448 const size_t NTCP_DEFAULT_PHASE3_SIZE = 2/*size*/ + i2p::data::DEFAULT_IDENTITY_SIZE/*387*/ + 4/*ts*/ + 15/*padding*/ + 40/*signature*/; // 448
const int NTCP_CLOCK_SKEW = 60; // in seconds const int NTCP_CLOCK_SKEW = 60; // in seconds
const int NTCP_MAX_OUTGOING_QUEUE_SIZE = 200; // how many messages we can queue up const int NTCP_MAX_OUTGOING_QUEUE_SIZE = 200; // how many messages we can queue up
class NTCPServer; class NTCPServer;
@@ -55,13 +55,13 @@ namespace transport
void Done (); void Done ();
boost::asio::ip::tcp::socket& GetSocket () { return m_Socket; }; boost::asio::ip::tcp::socket& GetSocket () { return m_Socket; };
bool IsEstablished () const { return m_IsEstablished; }; bool IsEstablished () const { return m_IsEstablished; };
bool IsTerminated () const { return m_IsTerminated; }; bool IsTerminated () const { return m_IsTerminated; };
void ClientLogin (); void ClientLogin ();
void ServerLogin (); void ServerLogin ();
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs); void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
private: private:
void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs); void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs);
@@ -70,7 +70,7 @@ namespace transport
void SetIsEstablished (bool isEstablished) { m_IsEstablished = isEstablished; } void SetIsEstablished (bool isEstablished) { m_IsEstablished = isEstablished; }
void CreateAESKey (uint8_t * pubKey); void CreateAESKey (uint8_t * pubKey);
// client // client
void SendPhase3 (); void SendPhase3 ();
void HandlePhase1Sent (const boost::system::error_code& ecode, std::size_t bytes_transferred); void HandlePhase1Sent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
@@ -88,35 +88,35 @@ namespace transport
void HandlePhase3ExtraReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred, uint32_t tsB, size_t paddingLen); void HandlePhase3ExtraReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred, uint32_t tsB, size_t paddingLen);
void HandlePhase3 (uint32_t tsB, size_t paddingLen); void HandlePhase3 (uint32_t tsB, size_t paddingLen);
void HandlePhase4Sent (const boost::system::error_code& ecode, std::size_t bytes_transferred); void HandlePhase4Sent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
// common // common
void Receive (); void Receive ();
void HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred); void HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred);
bool DecryptNextBlock (const uint8_t * encrypted); bool DecryptNextBlock (const uint8_t * encrypted);
void Send (std::shared_ptr<i2p::I2NPMessage> msg); void Send (std::shared_ptr<i2p::I2NPMessage> msg);
boost::asio::const_buffers_1 CreateMsgBuffer (std::shared_ptr<I2NPMessage> msg); boost::asio::const_buffers_1 CreateMsgBuffer (std::shared_ptr<I2NPMessage> msg);
void Send (const std::vector<std::shared_ptr<I2NPMessage> >& msgs); void Send (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
void HandleSent (const boost::system::error_code& ecode, std::size_t bytes_transferred, std::vector<std::shared_ptr<I2NPMessage> > msgs); void HandleSent (const boost::system::error_code& ecode, std::size_t bytes_transferred, std::vector<std::shared_ptr<I2NPMessage> > msgs);
private: private:
NTCPServer& m_Server; NTCPServer& m_Server;
boost::asio::ip::tcp::socket m_Socket; boost::asio::ip::tcp::socket m_Socket;
bool m_IsEstablished, m_IsTerminated; bool m_IsEstablished, m_IsTerminated;
i2p::crypto::CBCDecryption m_Decryption; i2p::crypto::CBCDecryption m_Decryption;
i2p::crypto::CBCEncryption m_Encryption; i2p::crypto::CBCEncryption m_Encryption;
struct Establisher struct Establisher
{ {
NTCPPhase1 phase1; NTCPPhase1 phase1;
NTCPPhase2 phase2; NTCPPhase2 phase2;
} * m_Establisher; } * m_Establisher;
i2p::crypto::AESAlignedBuffer<NTCP_BUFFER_SIZE + 16> m_ReceiveBuffer; i2p::crypto::AESAlignedBuffer<NTCP_BUFFER_SIZE + 16> m_ReceiveBuffer;
i2p::crypto::AESAlignedBuffer<16> m_TimeSyncBuffer; i2p::crypto::AESAlignedBuffer<16> m_TimeSyncBuffer;
int m_ReceiveBufferOffset; int m_ReceiveBufferOffset;
std::shared_ptr<I2NPMessage> m_NextMessage; std::shared_ptr<I2NPMessage> m_NextMessage;
size_t m_NextMessageOffset; size_t m_NextMessageOffset;
@@ -124,13 +124,28 @@ namespace transport
bool m_IsSending; bool m_IsSending;
std::vector<std::shared_ptr<I2NPMessage> > m_SendQueue; std::vector<std::shared_ptr<I2NPMessage> > m_SendQueue;
}; };
// TODO: move to NTCP.h/.cpp // TODO: move to NTCP.h/.cpp
class NTCPServer class NTCPServer
{ {
public: public:
enum RemoteAddressType
{
eIP4Address,
eIP6Address,
eHostname
};
enum ProxyType
{
eNoProxy,
eSocksProxy,
eHTTPProxy
};
NTCPServer (); NTCPServer ();
~NTCPServer (); ~NTCPServer ();
@@ -140,12 +155,17 @@ namespace transport
bool AddNTCPSession (std::shared_ptr<NTCPSession> session); bool AddNTCPSession (std::shared_ptr<NTCPSession> session);
void RemoveNTCPSession (std::shared_ptr<NTCPSession> session); void RemoveNTCPSession (std::shared_ptr<NTCPSession> session);
std::shared_ptr<NTCPSession> FindNTCPSession (const i2p::data::IdentHash& ident); 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 IsBoundV4() const { return m_NTCPAcceptor != nullptr; };
bool IsBoundV6() const { return m_NTCPV6Acceptor != nullptr; }; bool IsBoundV6() const { return m_NTCPV6Acceptor != nullptr; };
bool NetworkIsReady() const { return IsBoundV4() || IsBoundV6() || UsingProxy(); };
boost::asio::io_service& GetService () { return m_Service; }; 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; };
private: private:
@@ -155,14 +175,17 @@ namespace transport
void HandleConnect (const boost::system::error_code& ecode, std::shared_ptr<NTCPSession> conn, std::shared_ptr<boost::asio::deadline_timer> timer); 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 // timer
void ScheduleTermination (); void ScheduleTermination ();
void HandleTerminationTimer (const boost::system::error_code& ecode); void HandleTerminationTimer (const boost::system::error_code& ecode);
private: private:
bool m_IsRunning; bool m_IsRunning;
std::thread * m_Thread; std::thread * m_Thread;
boost::asio::io_service m_Service; boost::asio::io_service m_Service;
boost::asio::io_service::work m_Work; boost::asio::io_service::work m_Work;
boost::asio::deadline_timer m_TerminationTimer; boost::asio::deadline_timer m_TerminationTimer;
@@ -170,12 +193,17 @@ namespace transport
std::map<i2p::data::IdentHash, std::shared_ptr<NTCPSession> > m_NTCPSessions; // access from m_Thread only std::map<i2p::data::IdentHash, std::shared_ptr<NTCPSession> > m_NTCPSessions; // access from m_Thread only
std::list<std::shared_ptr<NTCPSession> > m_PendingIncomingSessions; 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: public:
// for HTTP/I2PControl // for HTTP/I2PControl
const decltype(m_NTCPSessions)& GetNTCPSessions () const { return m_NTCPSessions; }; const decltype(m_NTCPSessions)& GetNTCPSessions () const { return m_NTCPSessions; };
}; };
} }
} }
#endif #endif

View File

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

View File

@@ -1,6 +1,6 @@
#ifndef NETDB_H__ #ifndef NETDB_H__
#define 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 <inttypes.h>
#include <set> #include <set>
#include <map> #include <map>

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,7 +12,7 @@
#include "Base.h" #include "Base.h"
#include "Timestamp.h" #include "Timestamp.h"
#include "Log.h" #include "Log.h"
#include "NetDb.h" #include "NetDb.hpp"
#include "RouterContext.h" #include "RouterContext.h"
#include "RouterInfo.h" #include "RouterInfo.h"
@@ -264,6 +264,8 @@ namespace data
introducer.iTag = boost::lexical_cast<uint32_t>(value); introducer.iTag = boost::lexical_cast<uint32_t>(value);
else if (!strcmp (key, "ikey")) else if (!strcmp (key, "ikey"))
Base64ToByteStream (value, strlen (value), introducer.iKey, 32); Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
else if (!strcmp (key, "iexp"))
introducer.iExp = boost::lexical_cast<uint32_t>(value);
} }
if (!s) return; if (!s) return;
} }
@@ -478,6 +480,18 @@ namespace data
properties << ';'; properties << ';';
i++; 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 // write intro key
WriteString ("key", properties); WriteString ("key", properties);

View File

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

View File

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

View File

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

View File

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

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