[-]
[+]
|
Changed |
_service:tar_git:i2pd.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/nephros/i2pd</param>
<param name="branch"></param>
- <param name="revision">2.41.0+git4</param>
+ <param name="revision">2.43.0+git1</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/icons/icons/graphic-i2p-banner-dots.png
^
|
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/icons/icons/graphic-i2p-banner.png
^
|
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/icons/icons/icon-m-i2p.png
^
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/upstream/contrib/android_binary_only/.gitignore
^
|
@@ -1,18 +0,0 @@
-gen
-tests
-bin
-libs
-log*
-obj
-.gradle
-.idea
-.externalNativeBuild
-ant.properties
-local.properties
-build.sh
-android.iml
-build
-gradle
-gradlew
-gradlew.bat
-
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/upstream/contrib/android_binary_only/jni/Android.mk
^
|
@@ -1,74 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := i2pd
-LOCAL_CPP_FEATURES := rtti exceptions
-LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(DAEMON_SRC_PATH)
-LOCAL_STATIC_LIBRARIES := \
- boost_system \
- boost_date_time \
- boost_filesystem \
- boost_program_options \
- crypto ssl \
- miniupnpc
-LOCAL_LDLIBS := -lz
-
-LOCAL_SRC_FILES := $(IFADDRS_PATH)/ifaddrs.c \
- $(wildcard $(LIB_SRC_PATH)/*.cpp)\
- $(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp)\
- $(DAEMON_SRC_PATH)/UnixDaemon.cpp \
- $(DAEMON_SRC_PATH)/Daemon.cpp \
- $(DAEMON_SRC_PATH)/UPnP.cpp \
- $(DAEMON_SRC_PATH)/HTTPServer.cpp \
- $(DAEMON_SRC_PATH)/I2PControl.cpp \
- $(DAEMON_SRC_PATH)/i2pd.cpp
-include $(BUILD_EXECUTABLE)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := boost_system
-LOCAL_SRC_FILES := $(BOOST_PATH)/boost-1_72_0/$(TARGET_ARCH_ABI)/lib/libboost_system.a
-LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/boost-1_72_0/include
-include $(PREBUILT_STATIC_LIBRARY)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := boost_date_time
-LOCAL_SRC_FILES := $(BOOST_PATH)/boost-1_72_0/$(TARGET_ARCH_ABI)/lib/libboost_date_time.a
-LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/boost-1_72_0/include
-include $(PREBUILT_STATIC_LIBRARY)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := boost_filesystem
-LOCAL_SRC_FILES := $(BOOST_PATH)/boost-1_72_0/$(TARGET_ARCH_ABI)/lib/libboost_filesystem.a
-LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/boost-1_72_0/include
-include $(PREBUILT_STATIC_LIBRARY)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := boost_program_options
-LOCAL_SRC_FILES := $(BOOST_PATH)/boost-1_72_0/$(TARGET_ARCH_ABI)/lib/libboost_program_options.a
-LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/boost-1_72_0/include
-include $(PREBUILT_STATIC_LIBRARY)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := crypto
-LOCAL_SRC_FILES := $(OPENSSL_PATH)/openssl-1.1.1a-clang/$(TARGET_ARCH_ABI)/lib/libcrypto.a
-LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/openssl-1.1.1a-clang/include
-include $(PREBUILT_STATIC_LIBRARY)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := ssl
-LOCAL_SRC_FILES := $(OPENSSL_PATH)/openssl-1.1.1a-clang/$(TARGET_ARCH_ABI)/lib/libssl.a
-LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/openssl-1.1.1a-clang/include
-LOCAL_STATIC_LIBRARIES := crypto
-include $(PREBUILT_STATIC_LIBRARY)
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := miniupnpc
-LOCAL_SRC_FILES := $(MINIUPNP_PATH)/miniupnpc-2.1/$(TARGET_ARCH_ABI)/lib/libminiupnpc.a
-LOCAL_EXPORT_C_INCLUDES := $(MINIUPNP_PATH)/miniupnpc-2.1/include
-include $(PREBUILT_STATIC_LIBRARY)
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/upstream/contrib/android_binary_only/jni/Application.mk
^
|
@@ -1,40 +0,0 @@
-APP_ABI := all
-#APP_ABI += x86
-#APP_ABI += x86_64
-#APP_ABI += armeabi-v7a
-#APP_ABI += arm64-v8a
-#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-14
-
-NDK_TOOLCHAIN_VERSION := clang
-APP_STL := c++_static
-
-# Enable c++17 extensions in source code
-APP_CPPFLAGS += -std=c++17 -fvisibility=default -fPIE
-
-APP_CPPFLAGS += -DANDROID_BINARY -DANDROID -D__ANDROID__ -DUSE_UPNP
-APP_LDFLAGS += -rdynamic -fPIE -pie
-ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
-APP_CPPFLAGS += -DANDROID_ARM7A
-endif
-
-# Forcing debug optimization. Use `ndk-build NDK_DEBUG=1` instead.
-#APP_OPTIM := debug
-
-# git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git -b boost-1_72_0
-# git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git
-# git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git
-# git clone https://github.com/PurpleI2P/android-ifaddrs.git
-# change to your own
-I2PD_LIBS_PATH = /path/to/libraries
-BOOST_PATH = $(I2PD_LIBS_PATH)/Boost-for-Android-Prebuilt
-OPENSSL_PATH = $(I2PD_LIBS_PATH)/OpenSSL-for-Android-Prebuilt
-MINIUPNP_PATH = $(I2PD_LIBS_PATH)/MiniUPnP-for-Android-Prebuilt
-IFADDRS_PATH = $(I2PD_LIBS_PATH)/android-ifaddrs
-
-# don't change me
-I2PD_SRC_PATH = $(PWD)/../..
-
-LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd
-LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client
-DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/upstream/contrib/android_binary_pack/.gitignore
^
|
@@ -1,2 +0,0 @@
-archive
-i2pd_*_android_binary.zip
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/upstream/contrib/android_binary_pack/build-archive
^
|
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-# Copyright (c) 2013-2020, The PurpleI2P Project
-#
-# This file is part of Purple i2pd project and licensed under BSD3
-#
-# See full license text in LICENSE file at top of project tree
-
-GITDESC=$(git describe --tags)
-
-declare -A ABILIST=(
- ["armeabi-v7a"]="armv7l"
- ["arm64-v8a"]="aarch64"
- ["x86"]="x86"
- ["x86_64"]="x86_64"
-)
-
-# Remove old files and archives
-if [ -d archive ]; then
- rm -r archive
-fi
-
-if [ -f ../i2pd_*_android_binary.zip ]; then
- rm i2pd_*_android_binary.zip
-fi
-
-# Prepare files for package
-mkdir archive
-
-for ABI in "${!ABILIST[@]}"; do
- if [ -f ../android_binary_only/libs/${ABI}/i2pd ]; then
- cp ../android_binary_only/libs/${ABI}/i2pd archive/i2pd-${ABILIST[$ABI]}
- fi
-done
-
-cp i2pd archive/i2pd
-cp -rH ../android/assets/certificates archive/
-cp -rH ../android/assets/tunnels.conf.d archive/
-cp -H ../android/assets/i2pd.conf archive/
-cp -H ../android/assets/tunnels.conf archive/
-
-# Compress files
-cd archive
-zip -r6 ../i2pd_${GITDESC}_android_binary.zip .
-
-# Remove temporary folder
-cd ..
-rm -r archive
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.41.0+git4.tar.gz/upstream/contrib/android_binary_pack/i2pd
^
|
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2013-2020, The PurpleI2P Project
-#
-# This file is part of Purple i2pd project and licensed under BSD3
-#
-# See full license text in LICENSE file at top of project tree
-#
-# That script written for use with Termux.
-
-# https://stackoverflow.com/a/246128
-SOURCE="${0}"
-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
- DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
- SOURCE="$(readlink "$SOURCE")"
- [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
-done
-DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
-
-arch=$(uname -m)
-
-screenfind=$(which screen)
-if [ -z $screenfind ]; then
- echo "Can't find 'screen' installed. That script needs it!";
- exit 1;
-fi
-
-if [ -z i2pd-$arch ]; then
- echo "Can't find i2pd binary for your archtecture.";
- exit 1;
-fi
-
-screen -AmdS i2pd ./i2pd-$arch --datadir=$DIR
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/ui/jolla-settings/pages/i2p/EnableSwitch.qml
^
|
@@ -16,24 +16,15 @@
property bool activeState
- onActiveStateChanged: {
- busy = false
- }
-
name: "I2P"
- activeText: "active"
+ activeText: "I2P"
icon.source: "image://theme/icon-m-i2p"
active: activeState
checked: activeState
- //busy:
-
menu: ContextMenu {
- SettingsMenuItem {
- onClicked: enableSwitch.goToSettings()
- }
-
+ SettingsMenuItem { onClicked: enableSwitch.goToSettings() }
MenuItem {
text: "Open Web Console"
onClicked: Qt.openUrlExternally("http://127.0.0.1:7070")
@@ -49,10 +40,9 @@
systemdServiceIface.updateProperties()
}
-
Timer {
id: checkState
- interval: 1000
+ interval: 2000
repeat: true
onTriggered: {
systemdServiceIface.updateProperties()
@@ -74,11 +64,12 @@
activeState = true
checkState.stop()
}
- else if (activeProperty === "inactive") {
+ else if (activeProperty === "inactive" || activeProperty === "failed") {
activeState = false
checkState.stop()
}
else {
+ enableSwitch.busy = false
checkState.start()
}
}
@@ -98,6 +89,7 @@
Component.onCompleted: systemdServiceIface.updateProperties()
}
+ /*
DBusInterface {
bus: DBus.SystemBus
service: "org.freedesktop.systemd1"
@@ -112,6 +104,7 @@
}
}
}
+ */
Component.onCompleted: systemdServiceIface.updateProperties()
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/.github/workflows/build-freebsd.yml
^
|
@@ -4,13 +4,13 @@
jobs:
build:
- runs-on: macos-10.15
+ runs-on: macos-12
name: with UPnP
steps:
- uses: actions/checkout@v2
- name: Test in FreeBSD
id: test
- uses: vmactions/freebsd-vm@v0.1.5
+ uses: vmactions/freebsd-vm@v0.2.0
with:
usesh: true
mem: 2048
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/.github/workflows/build-windows.yml
^
|
@@ -35,3 +35,41 @@
with:
name: i2pd-${{ matrix.arch_short }}.exe
path: i2pd.exe
+ build-xp:
+ name: Building for Windows XP
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup MSYS2
+ uses: msys2/setup-msys2@v2
+ with:
+ msystem: MINGW32
+ install: base-devel git mingw-w64-i686-gcc mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-miniupnpc
+ update: true
+ - name: Build WinXP-capable CRT packages
+ run: |
+ git clone https://github.com/msys2/MINGW-packages
+ pushd MINGW-packages
+ pushd mingw-w64-headers-git
+ sed -i 's/0x601/0x501/' PKGBUILD
+ MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm
+ pacman --noconfirm -U mingw-w64-i686-headers-git-*-any.pkg.tar.zst
+ popd
+ pushd mingw-w64-crt-git
+ MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm
+ pacman --noconfirm -U mingw-w64-i686-crt-git-*-any.pkg.tar.zst
+ popd
+ pushd mingw-w64-winpthreads-git
+ MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm
+ pacman --noconfirm -U mingw-w64-i686-libwinpthread-git-*-any.pkg.tar.zst mingw-w64-i686-winpthreads-git-*-any.pkg.tar.zst
+ popd
+ popd
+ - name: Build application
+ run: |
+ mkdir -p obj/Win32 obj/libi2pd obj/libi2pd_client obj/daemon
+ make USE_UPNP=yes DEBUG=no USE_GIT_VERSION=yes USE_WINXP_FLAGS=yes -j3
+ - name: Upload artifacts
+ uses: actions/upload-artifact@v2
+ with:
+ name: i2pd-xp.exe
+ path: i2pd.exe
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/.github/workflows/docker.yml
^
|
@@ -1,6 +1,11 @@
name: Build containers
-on: [push]
+on:
+ push:
+ branches:
+ - openssl
+ tags:
+ - '*'
jobs:
docker:
@@ -58,6 +63,8 @@
push: true
tags: |
purplei2p/i2pd:latest
+ purplei2p/i2pd:latest-release
purplei2p/i2pd:release-${{ env.RELEASE_VERSION }}
ghcr.io/purplei2p/i2pd:latest
+ ghcr.io/purplei2p/i2pd:latest-release
ghcr.io/purplei2p/i2pd:release-${{ env.RELEASE_VERSION }}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/ChangeLog
^
|
@@ -1,6 +1,70 @@
# for this file format description,
# see https://github.com/olivierlacan/keep-a-changelog
+## [2.43.0] - 2022-08-22
+### Added
+- Complete SSU2 implementation
+- Localization to Chinese
+- Send RouterInfo update for long live sessions
+- Explicit ipv6 ranges of known tunnel brokers for MTU detection
+- Always send "Connection: close" and strip out Keep-Alive for server HTTP tunnel
+- Show ports for all transports in web console
+- Translation of webconsole site title
+- Support for Windows ProgramData path when running as service
+- Ability to turn off address book
+- Handle signals TSTP and CONT to stop and resume network
+### Changed
+- Case insensitive headers for server HTTP tunnel
+- Do not show 'Address registration' line if LeaseSet is encrypted
+- SSU2 transports have higher priority than SSU
+- Disable ElGamal precalculated table if no SSU
+- Deprecate limits.ntcpsoft, limits.ntcphard and limits.ntcpthreads config options
+- SSU2 is enabled and SSU is disabled by default for new installations
+### Fixed
+- Typo with Referer header name in HTTP proxy
+- Can't handle garlic message from an exploratory tunnel
+- Incorrect encryption key for exploratory lookup reply
+- Bound checks issues in LeaseSets code
+- MTU detection on Windows
+- Crash on stop of active server tunnel
+- Send datagram to wrong destination in SAM
+- Incorrect static key in RouterInfo if the keys were regenerated
+- Duplicated sessions in BOB
+
+## [2.42.1] - 2022-05-24
+### Fixed
+- Incorrect jump link in HTTP Proxy
+
+## [2.42.0] - 2022-05-22
+### Added
+- Preliminary SSU2 implementation
+- Tunnel length variance
+- Localization to French
+- Daily cleanup of obsolete peer profiles
+- Ordered jump services list in HTTP proxy
+- Win32 service
+- Show port for local non-published SSU addresses in web console
+### Changed
+- Maximum RouterInfo length increased to 3K
+- Skip unknown addresses in RouterInfo
+- Don't pick own router for peer test
+- Reseeds list
+- Internal numeric id for families
+- Use ipv6 preference only when netinet headers not used
+- Close stream if delete requested
+- Remove version from title in web console
+- Drop MESHNET build option
+- Set data path before initialization
+- Don't show registration block in web console if token is not provided
+### Fixed
+- Encrypted LeaseSet for EdDSA signature
+- Clients tunnels are not built if clock is not synced on start
+- Incorrect processing of i2cp.dontPublishLeaseSet param
+- UDP tunnels reload
+- Build for LibreSSL 3.5.2
+- Race condition in short tunnel build message
+- Race condition in local RouterInfo buffer allocation
+
## [2.41.0] - 2022-02-20
### Added
- Clock syncronization through SSU
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Makefile
^
|
@@ -4,7 +4,7 @@
ifneq (, $(findstring darwin, $(SYS)))
SHARED_SUFFIX = dylib
-else ifneq (, $(findstring mingw, $(SYS))$(findstring cygwin, $(SYS)))
+else ifneq (, $(findstring mingw, $(SYS))$(findstring windows-gnu, $(SYS))$(findstring cygwin, $(SYS)))
SHARED_SUFFIX = dll
else
SHARED_SUFFIX = so
@@ -31,7 +31,6 @@
USE_AESNI := $(or $(USE_AESNI),yes)
USE_STATIC := $(or $(USE_STATIC),no)
-USE_MESHNET := $(or $(USE_MESHNET),no)
USE_UPNP := $(or $(USE_UPNP),no)
DEBUG := $(or $(DEBUG),yes)
@@ -61,23 +60,19 @@
else ifneq (, $(findstring freebsd, $(SYS))$(findstring openbsd, $(SYS)))
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
include Makefile.bsd
-else ifneq (, $(findstring mingw, $(SYS))$(findstring cygwin, $(SYS)))
- DAEMON_SRC += Win32/DaemonWin32.cpp Win32/Win32App.cpp Win32/Win32NetState.cpp
+else ifneq (, $(findstring mingw, $(SYS))$(findstring windows-gnu, $(SYS))$(findstring cygwin, $(SYS)))
+ DAEMON_SRC += Win32/DaemonWin32.cpp Win32/Win32App.cpp Win32/Win32Service.cpp Win32/Win32NetState.cpp
include Makefile.mingw
else # not supported
$(error Not supported platform)
endif
-ifeq ($(USE_MESHNET),yes)
- NEEDED_CXXFLAGS += -DMESHNET
-endif
-
ifeq ($(USE_GIT_VERSION),yes)
GIT_VERSION := $(shell git describe --tags)
NEEDED_CXXFLAGS += -DGITVER=\"$(GIT_VERSION)\"
endif
-NEEDED_CXXFLAGS += -MMD -MP -I$(LIB_SRC_DIR) -I$(LIB_CLIENT_SRC_DIR) -I$(LANG_SRC_DIR)
+NEEDED_CXXFLAGS += -MMD -MP -I$(LIB_SRC_DIR) -I$(LIB_CLIENT_SRC_DIR) -I$(LANG_SRC_DIR) -DOPENSSL_SUPPRESS_DEPRECATED
LIB_OBJS += $(patsubst %.cpp,obj/%.o,$(LIB_SRC))
LIB_CLIENT_OBJS += $(patsubst %.cpp,obj/%.o,$(LIB_CLIENT_SRC))
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Makefile.homebrew
^
|
@@ -39,13 +39,19 @@
endif
install: all
- install -d ${PREFIX}/bin ${PREFIX}/etc/i2pd ${PREFIX}/share/doc/i2pd ${PREFIX}/share/i2pd ${PREFIX}/share/man/man1 ${PREFIX}/var/lib/i2pd
- install -m 755 ${I2PD} ${PREFIX}/bin/
+ install -d ${PREFIX}/bin
+ install -m 755 ${I2PD} ${PREFIX}/bin
+ install -d ${PREFIX}/etc ${PREFIX}/etc/i2pd ${PREFIX}/etc/i2pd/tunnels.conf.d
install -m 644 contrib/i2pd.conf contrib/subscriptions.txt contrib/tunnels.conf ${PREFIX}/etc/i2pd
- @cp -R contrib/certificates ${PREFIX}/share/i2pd/
+ install -d ${PREFIX}/share ${PREFIX}/share/doc ${PREFIX}/share/doc/i2pd
install -m 644 ChangeLog LICENSE README.md contrib/i2pd.conf contrib/subscriptions.txt contrib/tunnels.conf ${PREFIX}/share/doc/i2pd
+ install -d ${PREFIX}/share/i2pd
+ @cp -R contrib/certificates ${PREFIX}/share/i2pd/
+ install -d ${PREFIX}/share/man ${PREFIX}/share/man/man1
@gzip -kf debian/i2pd.1 && install debian/i2pd.1.gz ${PREFIX}/share/man/man1
- @ln -sf ${PREFIX}/share/i2pd/certificates ${PREFIX}/var/lib/i2pd/
+ install -d ${PREFIX}/var ${PREFIX}/var/lib ${PREFIX}/var/lib/i2pd
+ @ln -sf ${PREFIX}/share/i2pd/certificates ${PREFIX}/var/lib/i2pd/certificates
+ @ln -sf ${PREFIX}/etc/i2pd/tunnels.conf.d ${PREFIX}/var/lib/i2pd/tunnels.d
@ln -sf ${PREFIX}/etc/i2pd/i2pd.conf ${PREFIX}/var/lib/i2pd/i2pd.conf
@ln -sf ${PREFIX}/etc/i2pd/subscriptions.txt ${PREFIX}/var/lib/i2pd/subscriptions.txt
@ln -sf ${PREFIX}/etc/i2pd/tunnels.conf ${PREFIX}/var/lib/i2pd/tunnels.conf
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Makefile.linux
^
|
@@ -62,3 +62,21 @@
NEEDED_CXXFLAGS += -D__AES__ -maes
endif
endif
+
+install: all
+ install -d ${PREFIX}/bin
+ install -m 755 ${I2PD} ${PREFIX}/bin
+ install -d ${PREFIX}/etc ${PREFIX}/etc/i2pd ${PREFIX}/etc/i2pd/tunnels.conf.d
+ install -m 644 contrib/i2pd.conf contrib/subscriptions.txt contrib/tunnels.conf ${PREFIX}/etc/i2pd
+ install -d ${PREFIX}/share ${PREFIX}/share/doc ${PREFIX}/share/doc/i2pd
+ install -m 644 ChangeLog LICENSE README.md contrib/i2pd.conf contrib/subscriptions.txt contrib/tunnels.conf ${PREFIX}/share/doc/i2pd
+ install -d ${PREFIX}/share/i2pd
+ @cp -R contrib/certificates ${PREFIX}/share/i2pd/
+ install -d ${PREFIX}/share/man ${PREFIX}/share/man/man1
+ @gzip -kf debian/i2pd.1 && install debian/i2pd.1.gz ${PREFIX}/share/man/man1
+ install -d ${PREFIX}/var ${PREFIX}/var/lib ${PREFIX}/var/lib/i2pd
+ @ln -sf ${PREFIX}/share/i2pd/certificates ${PREFIX}/var/lib/i2pd/certificates
+ @ln -sf ${PREFIX}/etc/i2pd/tunnels.conf.d ${PREFIX}/var/lib/i2pd/tunnels.d
+ @ln -sf ${PREFIX}/etc/i2pd/i2pd.conf ${PREFIX}/var/lib/i2pd/i2pd.conf
+ @ln -sf ${PREFIX}/etc/i2pd/subscriptions.txt ${PREFIX}/var/lib/i2pd/subscriptions.txt
+ @ln -sf ${PREFIX}/etc/i2pd/tunnels.conf ${PREFIX}/var/lib/i2pd/tunnels.conf
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Makefile.mingw
^
|
@@ -3,19 +3,11 @@
WINDRES = windres
-CXXFLAGS := $(CXX_DEBUG) -DWIN32_LEAN_AND_MEAN -fPIC -msse
+CXXFLAGS := $(CXX_DEBUG) -fPIC -msse
INCFLAGS = -I$(DAEMON_SRC_DIR) -IWin32
LDFLAGS := ${LD_DEBUG} -static
-# detect proper flag for c++11 support by compilers
-CXXVER := $(shell $(CXX) -dumpversion)
-ifeq ($(shell expr match ${CXXVER} "[4]\.[7-9]\|4\.1[0-9]\|[5-6]"),4) # gcc 4.7 - 6
- NEEDED_CXXFLAGS += -std=c++11
-else ifeq ($(shell expr match ${CXXVER} "[1,7-9]"),1) # gcc >= 7
- NEEDED_CXXFLAGS += -std=c++17
-else # not supported
-$(error Compiler too old)
-endif
+NEEDED_CXXFLAGS += -std=c++17 -DWIN32_LEAN_AND_MEAN
# Boost libraries suffix
BOOST_SUFFIX = -mt
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Win32/DaemonWin32.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -14,6 +14,7 @@
#include "Log.h"
#ifdef _WIN32
+#include "Win32Service.h"
#ifdef WIN32_APP
#include <windows.h>
#include "Win32App.h"
@@ -39,6 +40,19 @@
if (!Daemon_Singleton::init(argc, argv))
return false;
+
+ if (isDaemon)
+ {
+ LogPrint(eLogDebug, "Daemon: running as service");
+ I2PService service((PSTR)SERVICE_NAME);
+ if (!I2PService::Run(service))
+ {
+ LogPrint(eLogError, "Daemon: Service failed to run w/err 0x%08lx\n", GetLastError());
+ return false;
+ }
+ return false;
+ }
+
return true;
}
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Win32/Win32Service.cpp
^
|
@@ -0,0 +1,283 @@
+/*
+* Copyright (c) 2013-2022, The PurpleI2P Project
+*
+* This file is part of Purple i2pd project and licensed under BSD3
+*
+* See full license text in LICENSE file at top of project tree
+*/
+
+#include "Win32Service.h"
+#include <assert.h>
+#include <windows.h>
+
+#include "Daemon.h"
+#include "Log.h"
+
+I2PService *I2PService::s_service = NULL;
+
+BOOL I2PService::isService()
+{
+ BOOL bIsService = FALSE;
+ HWINSTA hWinStation = GetProcessWindowStation();
+ if (hWinStation != NULL)
+ {
+ USEROBJECTFLAGS uof = { 0 };
+ if (GetUserObjectInformation(hWinStation, UOI_FLAGS, &uof, sizeof(USEROBJECTFLAGS), NULL) && ((uof.dwFlags & WSF_VISIBLE) == 0))
+ {
+ bIsService = TRUE;
+ }
+ }
+ return bIsService;
+}
+
+BOOL I2PService::Run(I2PService &service)
+{
+ s_service = &service;
+ SERVICE_TABLE_ENTRY serviceTable[] =
+ {
+ { service.m_name, ServiceMain },
+ { NULL, NULL }
+ };
+ return StartServiceCtrlDispatcher(serviceTable);
+}
+
+void WINAPI I2PService::ServiceMain(DWORD dwArgc, PSTR *pszArgv)
+{
+ assert(s_service != NULL);
+ s_service->m_statusHandle = RegisterServiceCtrlHandler(
+ s_service->m_name, ServiceCtrlHandler);
+ if (s_service->m_statusHandle == NULL)
+ {
+ throw GetLastError();
+ }
+ s_service->Start(dwArgc, pszArgv);
+}
+
+
+void WINAPI I2PService::ServiceCtrlHandler(DWORD dwCtrl)
+{
+ switch (dwCtrl)
+ {
+ case SERVICE_CONTROL_STOP: s_service->Stop(); break;
+ case SERVICE_CONTROL_PAUSE: s_service->Pause(); break;
+ case SERVICE_CONTROL_CONTINUE: s_service->Continue(); break;
+ case SERVICE_CONTROL_SHUTDOWN: s_service->Shutdown(); break;
+ case SERVICE_CONTROL_INTERROGATE: break;
+ default: break;
+ }
+}
+
+I2PService::I2PService(PSTR pszServiceName,
+ BOOL fCanStop,
+ BOOL fCanShutdown,
+ BOOL fCanPauseContinue)
+{
+ m_name = (pszServiceName == NULL) ? (PSTR)"" : pszServiceName;
+ m_statusHandle = NULL;
+ m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ m_status.dwCurrentState = SERVICE_START_PENDING;
+
+ DWORD dwControlsAccepted = 0;
+ if (fCanStop)
+ dwControlsAccepted |= SERVICE_ACCEPT_STOP;
+ if (fCanShutdown)
+ dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN;
+ if (fCanPauseContinue)
+ dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
+
+ m_status.dwControlsAccepted = dwControlsAccepted;
+ m_status.dwWin32ExitCode = NO_ERROR;
+ m_status.dwServiceSpecificExitCode = 0;
+ m_status.dwCheckPoint = 0;
+ m_status.dwWaitHint = 0;
+ m_fStopping = FALSE;
+ // Create a manual-reset event that is not signaled at first to indicate
+ // the stopped signal of the service.
+ m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (m_hStoppedEvent == NULL)
+ {
+ throw GetLastError();
+ }
+}
+
+I2PService::~I2PService(void)
+{
+ if (m_hStoppedEvent)
+ {
+ CloseHandle(m_hStoppedEvent);
+ m_hStoppedEvent = NULL;
+ }
+}
+
+void I2PService::Start(DWORD dwArgc, PSTR *pszArgv)
+{
+ try
+ {
+ SetServiceStatus(SERVICE_START_PENDING);
+ OnStart(dwArgc, pszArgv);
+ SetServiceStatus(SERVICE_RUNNING);
+ }
+ catch (DWORD dwError)
+ {
+ LogPrint(eLogError, "Win32Service: Start error: ", dwError);
+ SetServiceStatus(SERVICE_STOPPED, dwError);
+ }
+ catch (...)
+ {
+ LogPrint(eLogError, "Win32Service: failed to start: ", EVENTLOG_ERROR_TYPE);
+ SetServiceStatus(SERVICE_STOPPED);
+ }
+}
+
+void I2PService::OnStart(DWORD dwArgc, PSTR *pszArgv)
+{
+ LogPrint(eLogInfo, "Win32Service: in OnStart (", EVENTLOG_INFORMATION_TYPE, ")");
+ Daemon.start();
+ _worker = new std::thread(std::bind(&I2PService::WorkerThread, this));
+}
+
+void I2PService::WorkerThread()
+{
+ while (!m_fStopping)
+ {
+ ::Sleep(1000); // Simulate some lengthy operations.
+ }
+ // Signal the stopped event.
+ SetEvent(m_hStoppedEvent);
+}
+
+void I2PService::Stop()
+{
+ DWORD dwOriginalState = m_status.dwCurrentState;
+ try
+ {
+ SetServiceStatus(SERVICE_STOP_PENDING);
+ OnStop();
+ SetServiceStatus(SERVICE_STOPPED);
+ }
+ catch (DWORD dwError)
+ {
+ LogPrint(eLogInfo, "Win32Service: Stop error: ", dwError);
+ SetServiceStatus(dwOriginalState);
+ }
+ catch (...)
+ {
+ LogPrint(eLogError, "Win32Service: Failed to stop: ", EVENTLOG_ERROR_TYPE);
+ SetServiceStatus(dwOriginalState);
+ }
+}
+
+void I2PService::OnStop()
+{
+ // Log a service stop message to the Application log.
+ LogPrint(eLogInfo, "Win32Service: in OnStop (", EVENTLOG_INFORMATION_TYPE, ")");
+ Daemon.stop();
+ m_fStopping = TRUE;
+ if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0)
+ {
+ throw GetLastError();
+ }
+ _worker->join();
+ delete _worker;
+}
+
+void I2PService::Pause()
+{
+ try
+ {
+ SetServiceStatus(SERVICE_PAUSE_PENDING);
+ OnPause();
+ SetServiceStatus(SERVICE_PAUSED);
+ }
+ catch (DWORD dwError)
+ {
+ LogPrint(eLogError, "Win32Service: Pause error: ", dwError);
+ SetServiceStatus(SERVICE_RUNNING);
+ }
+ catch (...)
+ {
+ LogPrint(eLogError, "Win32Service: Failed to pause: ", EVENTLOG_ERROR_TYPE);
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/Win32/Win32Service.h
^
|
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2013-2022, The PurpleI2P Project
+*
+* This file is part of Purple i2pd project and licensed under BSD3
+*
+* See full license text in LICENSE file at top of project tree
+*/
+
+#ifndef WIN_32_SERVICE_H__
+#define WIN_32_SERVICE_H__
+
+#include <thread>
+#include <windows.h>
+
+#define SERVICE_NAME "i2pdService"
+
+class I2PService
+{
+ public:
+
+ I2PService(PSTR pszServiceName,
+ BOOL fCanStop = TRUE,
+ BOOL fCanShutdown = TRUE,
+ BOOL fCanPauseContinue = FALSE);
+
+ virtual ~I2PService(void);
+
+ static BOOL isService();
+ static BOOL Run(I2PService &service);
+ void Stop();
+
+ protected:
+
+ virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
+ virtual void OnStop();
+ virtual void OnPause();
+ virtual void OnContinue();
+ virtual void OnShutdown();
+ void SetServiceStatus(DWORD dwCurrentState,
+ DWORD dwWin32ExitCode = NO_ERROR,
+ DWORD dwWaitHint = 0);
+
+ private:
+
+ static void WINAPI ServiceMain(DWORD dwArgc, LPSTR *lpszArgv);
+ static void WINAPI ServiceCtrlHandler(DWORD dwCtrl);
+ void WorkerThread();
+ void Start(DWORD dwArgc, PSTR *pszArgv);
+ void Pause();
+ void Continue();
+ void Shutdown();
+ static I2PService* s_service;
+ PSTR m_name;
+ SERVICE_STATUS m_status;
+ SERVICE_STATUS_HANDLE m_statusHandle;
+
+ BOOL m_fStopping;
+ HANDLE m_hStoppedEvent;
+
+ std::thread* _worker;
+};
+
+#endif // WIN_32_SERVICE_H__
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/build/CMakeLists.txt
^
|
@@ -17,13 +17,13 @@
option(WITH_BINARY "Build binary" ON)
option(WITH_STATIC "Static build" OFF)
option(WITH_UPNP "Include support for UPnP client" OFF)
-option(WITH_MESHNET "Build for cjdns test network" OFF)
+option(WITH_GIT_VERSION "Use git commit info as version" OFF)
option(WITH_ADDRSANITIZER "Build with address sanitizer unix only" OFF)
option(WITH_THREADSANITIZER "Build with thread sanitizer unix only" OFF)
# paths
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
-set(CMAKE_SOURCE_DIR "..")
+set(CMAKE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
#Handle paths nicely
include(GNUInstallDirs)
@@ -89,14 +89,16 @@
"${DAEMON_SRC_DIR}/UPnP.cpp"
)
-if(WITH_MESHNET)
- add_definitions(-DMESHNET)
-endif()
-
if(WITH_UPNP)
add_definitions(-DUSE_UPNP)
endif()
+if(WITH_GIT_VERSION)
+ include(GetGitRevisionDescription)
+ git_describe(GIT_VERSION)
+ add_definitions(-DGITVER="${GIT_VERSION}")
+endif()
+
if(APPLE)
add_definitions(-DMAC_OSX)
endif()
@@ -170,24 +172,13 @@
# libraries
-# TODO: once CMake 3.1+ becomes mainstream, see e.g. http://stackoverflow.com/a/29871891/673826
-# use imported Threads::Threads instead
set(THREADS_PREFER_PTHREAD_FLAG ON)
-if(IOS)
- set(CMAKE_THREAD_LIBS_INIT "-lpthread")
- set(CMAKE_HAVE_THREADS_LIBRARY 1)
- set(CMAKE_USE_WIN32_THREADS_INIT 0)
- set(CMAKE_USE_PTHREADS_INIT 1)
-else()
- find_package(Threads REQUIRED)
-endif()
-if(THREADS_HAVE_PTHREAD_ARG) # compile time flag
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
-endif()
+find_package(Threads REQUIRED)
if(WITH_STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
+ set(OPENSSL_USE_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF)
if(${CMAKE_CXX_COMPILER} MATCHES ".*-openwrt-.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
@@ -202,8 +193,6 @@
add_definitions(-DBOOST_SYSTEM_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_REGEX_DYN_LINK)
endif()
-target_link_libraries(libi2pdclient libi2pd libi2pdlang)
-
find_package(Boost COMPONENTS system filesystem program_options date_time REQUIRED)
if(NOT DEFINED Boost_INCLUDE_DIRS)
message(SEND_ERROR "Boost is not found, or your boost version was below 1.46. Please download Boost!")
@@ -215,7 +204,7 @@
endif()
if(OPENSSL_VERSION VERSION_GREATER_EQUAL "3.0.0")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
+ add_definitions(-DOPENSSL_SUPPRESS_DEPRECATED)
endif()
if(WITH_UPNP)
@@ -235,12 +224,6 @@
# load includes
include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
-# warn if for meshnet
-if(WITH_MESHNET)
- message(STATUS "Building for testnet")
- message(WARNING "This build will NOT work on mainline i2p")
-endif()
-
include(CheckAtomic)
# show summary
@@ -258,15 +241,11 @@
message(STATUS " BINARY : ${WITH_BINARY}")
message(STATUS " STATIC BUILD : ${WITH_STATIC}")
message(STATUS " UPnP : ${WITH_UPNP}")
-message(STATUS " MESHNET : ${WITH_MESHNET}")
+message(STATUS " GIT VERSION : ${WITH_GIT_VERSION}")
message(STATUS " ADDRSANITIZER : ${WITH_ADDRSANITIZER}")
message(STATUS " THREADSANITIZER : ${WITH_THREADSANITIZER}")
message(STATUS "---------------------------------------")
-if(WITH_MESHNET)
- message(STATUS "WARNING: Using the MESHNET option will make it impossible to use the application with the main network!!!")
-endif()
-
if(WITH_BINARY)
add_executable("${PROJECT_NAME}" ${DAEMON_SRC})
@@ -278,23 +257,17 @@
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-z relro -z now")
endif()
- if(WITH_UPNP)
- set(UPNP_LIB ${MINIUPNPC_LIBRARY})
- endif()
-
# FindBoost pulls pthread for thread which is broken for static linking at least on Ubuntu 15.04
list(GET Boost_LIBRARIES -1 LAST_Boost_LIBRARIES)
if(${LAST_Boost_LIBRARIES} MATCHES ".*pthread.*")
list(REMOVE_AT Boost_LIBRARIES -1)
endif()
-
if(WITH_STATIC)
set(DL_LIB ${CMAKE_DL_LIBS})
endif()
- target_link_libraries(libi2pd ${Boost_LIBRARIES} ${ZLIB_LIBRARY})
- target_link_libraries("${PROJECT_NAME}" libi2pd libi2pdclient libi2pdlang ${DL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${UPNP_LIB} ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${DL_LIB} ${CMAKE_REQUIRED_LIBRARIES})
+ target_link_libraries("${PROJECT_NAME}" libi2pd libi2pdclient libi2pdlang ${DL_LIB} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto ${MINIUPNPC_LIBRARY} ZLIB::ZLIB Threads::Threads ${DL_LIB} ${CMAKE_REQUIRED_LIBRARIES})
install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime)
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/build/build_mingw.cmd
^
|
@@ -52,22 +52,28 @@
%xSH% "unix2dos contrib/i2pd.conf contrib/tunnels.conf contrib/tunnels.d/* contrib/webconsole/style.css" >> build\build.log 2>&1
REM Prepare binary signing command if signing key and password provided
-if defined SIGNKEY (
- if defined SIGNPASS (
- echo Signing options found
+if defined SIGN (
+ echo Signing enabled
- for %%X in (signtool.exe) do (set xSIGNTOOL=%%~$PATH:X)
- if not defined xSIGNTOOL (
- if not defined SIGNTOOL (
- echo Error: Can't find signtool. Please provide path to binary using SIGNTOOL variable.
- exit /b 1
- ) else (
- set "xSIGNTOOL=%SIGNTOOL%"
- )
+ for %%X in (signtool.exe) do (set xSIGNTOOL=%%~$PATH:X)
+ if not defined xSIGNTOOL (
+ if not defined SIGNTOOL (
+ echo Error: Can't find signtool. Please provide path to binary using SIGNTOOL variable.
+ exit /b 1
+ ) else (
+ set "xSIGNTOOL=%SIGNTOOL%"
)
+ )
+
+ if defined SIGNKEY (
+ set "xSIGNKEYOPTS=/f ^"%SIGNKEY%^""
+ )
- set "xSIGNOPTS=sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /f ^"%SIGNKEY%^" /p ^"%SIGNPASS%^""
+ if defined SIGNPASS (
+ set "xSIGNPASSOPTS=/p ^"%SIGNPASS%^""
)
+
+ set "xSIGNOPTS=sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 %xSIGNKEYOPTS% %xSIGNPASSOPTS%"
)
REM starting building
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/build/cmake_modules/GetGitRevisionDescription.cmake
^
|
@@ -0,0 +1,284 @@
+# - Returns a version string from Git
+#
+# These functions force a re-configure on each git commit so that you can
+# trust the values of the variables in your build system.
+#
+# get_git_head_revision(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR])
+#
+# Returns the refspec and sha hash of the current head revision
+#
+# git_describe(<var> [<additional arguments to git describe> ...])
+#
+# Returns the results of git describe on the source tree, and adjusting
+# the output so that it tests false if an error occurs.
+#
+# git_describe_working_tree(<var> [<additional arguments to git describe> ...])
+#
+# Returns the results of git describe on the working tree (--dirty option),
+# and adjusting the output so that it tests false if an error occurs.
+#
+# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
+#
+# Returns the results of git describe --exact-match on the source tree,
+# and adjusting the output so that it tests false if there was no exact
+# matching tag.
+#
+# git_local_changes(<var>)
+#
+# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
+# Uses the return code of "git diff-index --quiet HEAD --".
+# Does not regard untracked files.
+#
+# Requires CMake 2.6 or newer (uses the 'function' command)
+#
+# Original Author:
+# 2009-2020 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+#
+# Copyright 2009-2013, Iowa State University.
+# Copyright 2013-2020, Ryan Pavlik
+# Copyright 2013-2020, Contributors
+# SPDX-License-Identifier: BSL-1.0
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+if(__get_git_revision_description)
+ return()
+endif()
+set(__get_git_revision_description YES)
+
+# We must run the following at "include" time, not at function call time,
+# to find the path to this module rather than the path to a calling list file
+get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+# Function _git_find_closest_git_dir finds the next closest .git directory
+# that is part of any directory in the path defined by _start_dir.
+# The result is returned in the parent scope variable whose name is passed
+# as variable _git_dir_var. If no .git directory can be found, the
+# function returns an empty string via _git_dir_var.
+#
+# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and
+# neither foo nor bar contain a file/directory .git. This wil return
+# C:/bla/.git
+#
+function(_git_find_closest_git_dir _start_dir _git_dir_var)
+ set(cur_dir "${_start_dir}")
+ set(git_dir "${_start_dir}/.git")
+ while(NOT EXISTS "${git_dir}")
+ # .git dir not found, search parent directories
+ set(git_previous_parent "${cur_dir}")
+ get_filename_component(cur_dir "${cur_dir}" DIRECTORY)
+ if(cur_dir STREQUAL git_previous_parent)
+ # We have reached the root directory, we are not in git
+ set(${_git_dir_var}
+ ""
+ PARENT_SCOPE)
+ return()
+ endif()
+ set(git_dir "${cur_dir}/.git")
+ endwhile()
+ set(${_git_dir_var}
+ "${git_dir}"
+ PARENT_SCOPE)
+endfunction()
+
+function(get_git_head_revision _refspecvar _hashvar)
+ _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
+
+ if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
+ set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE)
+ else()
+ set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE)
+ endif()
+ if(NOT "${GIT_DIR}" STREQUAL "")
+ file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}"
+ "${GIT_DIR}")
+ if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
+ # We've gone above the CMake root dir.
+ set(GIT_DIR "")
+ endif()
+ endif()
+ if("${GIT_DIR}" STREQUAL "")
+ set(${_refspecvar}
+ "GITDIR-NOTFOUND"
+ PARENT_SCOPE)
+ set(${_hashvar}
+ "GITDIR-NOTFOUND"
+ PARENT_SCOPE)
+ return()
+ endif()
+
+ # Check if the current source dir is a git submodule or a worktree.
+ # In both cases .git is a file instead of a directory.
+ #
+ if(NOT IS_DIRECTORY ${GIT_DIR})
+ # The following git command will return a non empty string that
+ # points to the super project working tree if the current
+ # source dir is inside a git submodule.
+ # Otherwise the command will return an empty string.
+ #
+ execute_process(
+ COMMAND "${GIT_EXECUTABLE}" rev-parse
+ --show-superproject-working-tree
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ OUTPUT_VARIABLE out
+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(NOT "${out}" STREQUAL "")
+ # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
+ file(READ ${GIT_DIR} submodule)
+ string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE
+ ${submodule})
+ string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
+ get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
+ get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
+ ABSOLUTE)
+ set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
+ else()
+ # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree
+ file(READ ${GIT_DIR} worktree_ref)
+ # The .git directory contains a path to the worktree information directory
+ # inside the parent git repo of the worktree.
+ #
+ string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
+ ${worktree_ref})
+ string(STRIP ${git_worktree_dir} git_worktree_dir)
+ _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
+ set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
+ endif()
+ else()
+ set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
+ endif()
+ set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
+ if(NOT EXISTS "${GIT_DATA}")
+ file(MAKE_DIRECTORY "${GIT_DATA}")
+ endif()
+
+ if(NOT EXISTS "${HEAD_SOURCE_FILE}")
+ return()
+ endif()
+ set(HEAD_FILE "${GIT_DATA}/HEAD")
+ configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY)
+
+ configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
+ "${GIT_DATA}/grabRef.cmake" @ONLY)
+ include("${GIT_DATA}/grabRef.cmake")
+
+ set(${_refspecvar}
+ "${HEAD_REF}"
+ PARENT_SCOPE)
+ set(${_hashvar}
+ "${HEAD_HASH}"
+ PARENT_SCOPE)
+endfunction()
+
+function(git_describe _var)
+ if(NOT GIT_FOUND)
+ find_package(Git QUIET)
+ endif()
+ get_git_head_revision(refspec hash)
+ if(NOT GIT_FOUND)
+ set(${_var}
+ "GIT-NOTFOUND"
+ PARENT_SCOPE)
+ return()
+ endif()
+ if(NOT hash)
+ set(${_var}
+ "HEAD-HASH-NOTFOUND"
+ PARENT_SCOPE)
+ return()
+ endif()
+
+ # TODO sanitize
+ #if((${ARGN}" MATCHES "&&") OR
+ # (ARGN MATCHES "||") OR
+ # (ARGN MATCHES "\\;"))
+ # message("Please report the following error to the project!")
+ # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
+ #endif()
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/build/cmake_modules/GetGitRevisionDescription.cmake.in
^
|
@@ -0,0 +1,43 @@
+#
+# Internal file for GetGitRevisionDescription.cmake
+#
+# Requires CMake 2.6 or newer (uses the 'function' command)
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright 2009-2012, Iowa State University
+# Copyright 2011-2015, Contributors
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+# SPDX-License-Identifier: BSL-1.0
+
+set(HEAD_HASH)
+
+file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
+
+string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
+if(HEAD_CONTENTS MATCHES "ref")
+ # named branch
+ string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
+ if(EXISTS "@GIT_DIR@/${HEAD_REF}")
+ configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
+ else()
+ configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
+ file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
+ if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
+ set(HEAD_HASH "${CMAKE_MATCH_1}")
+ endif()
+ endif()
+else()
+ # detached HEAD
+ configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
+endif()
+
+if(NOT HEAD_HASH)
+ file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
+ string(STRIP "${HEAD_HASH}" HEAD_HASH)
+endif()
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/certificates/family/stormycloud.crt
^
|
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICKDCCAc6gAwIBAgIUcPHZXtYSqGNRCD6z8gp79WUFtI0wCgYIKoZIzj0EAwIw
+gZMxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEPMA0GA1UEBwwGQXVzdGlu
+MRgwFgYDVQQKDA9TdG9ybXlDbG91ZCBJbmMxIzAhBgNVBAMMGnN0b3JteWNsb3Vk
+LmZhbWlseS5pMnAubmV0MSQwIgYJKoZIhvcNAQkBFhVhZG1pbkBzdG9ybXljbG91
+ZC5vcmcwHhcNMjIwMzE5MTU1MjU2WhcNMzIwMzE2MTU1MjU2WjCBkzELMAkGA1UE
+BhMCVVMxDjAMBgNVBAgMBVRleGFzMQ8wDQYDVQQHDAZBdXN0aW4xGDAWBgNVBAoM
+D1N0b3JteUNsb3VkIEluYzEjMCEGA1UEAwwac3Rvcm15Y2xvdWQuZmFtaWx5Lmky
+cC5uZXQxJDAiBgkqhkiG9w0BCQEWFWFkbWluQHN0b3JteWNsb3VkLm9yZzBZMBMG
+ByqGSM49AgEGCCqGSM49AwEHA0IABFUli0hvJEmowNjJVjbKEIWBJhqe973S4VdL
+cJuA5yY3dC4Y998abWEox7/Y1BhnBbpJuiodA341bXKkLMXQy/kwCgYIKoZIzj0E
+AwIDSAAwRQIgD12F/TfY3iV1/WDF7BSKgbD5g2MfELUIy1dtUlJQuJUCIQD69mZw
+V1Z9j2x0ZsuirS3i6AMfVyTDj0RFS3U1jeHzIQ==
+-----END CERTIFICATE-----
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/certificates/reseed/i2p-reseed_at_mk16.de.crt
^
|
@@ -0,0 +1,34 @@
+-----BEGIN CERTIFICATE-----
+MIIFzTCCA7WgAwIBAgIQeUqFi0fHNQopg6BZlBLhVzANBgkqhkiG9w0BAQsFADBy
+MQswCQYDVQQGEwJYWDELMAkGA1UEBxMCWFgxCzAJBgNVBAkTAlhYMR4wHAYDVQQK
+ExVJMlAgQW5vbnltb3VzIE5ldHdvcmsxDDAKBgNVBAsTA0kyUDEbMBkGA1UEAwwS
+aTJwLXJlc2VlZEBtazE2LmRlMB4XDTIyMDIwNTE3MzkzM1oXDTMyMDIwNTE3Mzkz
+M1owcjELMAkGA1UEBhMCWFgxCzAJBgNVBAcTAlhYMQswCQYDVQQJEwJYWDEeMBwG
+A1UEChMVSTJQIEFub255bW91cyBOZXR3b3JrMQwwCgYDVQQLEwNJMlAxGzAZBgNV
+BAMMEmkycC1yZXNlZWRAbWsxNi5kZTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCC
+AgoCggIBAMYxs2D2xpN/8blGawvAlU9DemHIxApOEwaLNfh8aAvqEdB41NTqcx4U
+H8VchSormCfkCvezuMHO+K2HX7ihEZ1v6tbr6aX6hY9UZUyDDYsKmJoB1oKEhddv
+5UYfcWPE2eSykdFsWgTQD6Z+cRQWHEoCzb7qc+Jrw6KcnHMD0VrmBrEQPzTBxMHW
+4HC97PVkSLJTDArnS6ZiX4IbWRPw/mbpJT6EoVZo8J/it0pdn/X4KodEXDcnEMSe
+VRulfZH/nSmOOvKhoHPckmgz/u66BlnuSYXEIB0KfDIcAlSYiPDxGnAemTozJYXA
+UVMeFMs+YE5wiPgzzu+vpC31xtZLq0gyaCfgEi1P9j2ES/8pH3Gw6W2OH4kBx+jO
+TBsfI+ph6qFZ3WWT23MRVyl3ATuI/GHdczTxD9JaOn74lLI+Hnu8wXnyztVWkTMB
+4sAnzjdeHkvNDyQ10vSaN0HnGfg6zuAuUSqFQujFF8Vg8ZCcsh8GouWfzYDvi9mj
+9pfxx8v6UCC719I4J9CgFjWnn2Hqez3fO8fFulY61VPyCCZp4gKWbI2SIQP/n5gz
+ecYJRrJoem+rYfEQ/fwxROsvm3fCO4D6dt7ILRuX286GDIw2qSvP1zZVAioMwSj3
+9CAjKLwD/BhTRiMOlpaVv6IWqjtevbiaIKvbHTnoxvkGsDqe3gJhAgMBAAGjXzBd
+MA4GA1UdDwEB/wQEAwIChDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEw
+DwYDVR0TAQH/BAUwAwEB/zAbBgNVHQ4EFAQSaTJwLXJlc2VlZEBtazE2LmRlMA0G
+CSqGSIb3DQEBCwUAA4ICAQAb+x6XpJdjpVYw2bvWIUbatQJwq0YaEW5W61xGLgIG
+a37oll3YZbSY9Vk+N1cE0f61L3ya4Ioz6zlH/MO2zUG/dEk8vqdgIPUYJvyF7wwF
+w3/G4VMaDKOJx4bAZNmaiRFGYNhCOhCnZx6uZGrLNIJ2Dc+mflrGmGwYphtXVV3e
+Iv+ki3gSRgfXuMfKi4B5bLPnz7XDe4TSmwZZSRac4ly4KqmZUyntqbilRxaGTej3
+VYJ1tac8yppyk5N3VopMQNmBarNZG16wSOTD7CtKgn382jgRW8cR7BMeqhORivp0
+ZnPJFhzh4uthdlPdXXo6lxfvZjfiwlDPytvEu2QBz3urTgopGqRLcTBnLucWg9li
+OSy9z7hNEnIN3iIJJAwI1wBdDa7K0h3PFBbIUa7X2ybn81VeNSfO25Lo8YTZEKsc
+wcThJrNV6qOQv8rM/7aXugi6+VzPlCR+18iKRbebCnlqGR2dT1zFtj3negtOkrjo
+LH4H6VUr3q2Ie56IubS2hUKiUkDm0ckP3Vum35GGntyEAzl6uyog0hJFOJb3aq30
+YQLzyVEOz8NnA+32oMRzJJdDxQ7pqG5fgq7EF4d++YSgEfdVXxvfgXQ6m3jAyC7Z
+p/gX4rlxNsjeGU3Ds51wkmhH4IB1aSQr52PE6RaBhhh3SmADEv6S/3eGvE4F4MN5
+2Q==
+-----END CERTIFICATE-----
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/i18n/English.po
^
|
@@ -1,13 +1,13 @@
# i2pd
-# Copyright (C) 2021 PurpleI2P team
+# Copyright (C) 2021-2022 PurpleI2P team
# This file is distributed under the same license as the i2pd package.
-# R4SAS <r4sas@i2pmail.org>, 2021.
+# R4SAS <r4sas@i2pmail.org>, 2021-2022.
#
msgid ""
msgstr ""
"Project-Id-Version: i2pd\n"
"Report-Msgid-Bugs-To: https://github.com/PurpleI2P/i2pd/issues\n"
-"POT-Creation-Date: 2021-08-06 17:12\n"
+"POT-Creation-Date: 2022-07-26 21:22\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -18,706 +18,712 @@
"X-Poedit-SearchPath-0: daemon/HTTPServer.cpp\n"
"X-Poedit-SearchPath-1: libi2pd_client/HTTPProxy.cpp\n"
-#: daemon/HTTPServer.cpp:177
+#: daemon/HTTPServer.cpp:108
msgid "day"
msgid_plural "days"
msgstr[0] ""
msgstr[1] ""
-#: daemon/HTTPServer.cpp:181
+#: daemon/HTTPServer.cpp:112
msgid "hour"
msgid_plural "hours"
msgstr[0] ""
msgstr[1] ""
-#: daemon/HTTPServer.cpp:185
+#: daemon/HTTPServer.cpp:116
msgid "minute"
msgid_plural "minutes"
msgstr[0] ""
msgstr[1] ""
-#: daemon/HTTPServer.cpp:188
+#: daemon/HTTPServer.cpp:119
msgid "second"
msgid_plural "seconds"
msgstr[0] ""
msgstr[1] ""
#. tr: Kibibit
-#: daemon/HTTPServer.cpp:196 daemon/HTTPServer.cpp:224
+#: daemon/HTTPServer.cpp:127 daemon/HTTPServer.cpp:155
msgid "KiB"
msgstr ""
#. tr: Mebibit
-#: daemon/HTTPServer.cpp:198
+#: daemon/HTTPServer.cpp:129
msgid "MiB"
msgstr ""
#. tr: Gibibit
-#: daemon/HTTPServer.cpp:200
+#: daemon/HTTPServer.cpp:131
msgid "GiB"
msgstr ""
-#: daemon/HTTPServer.cpp:217
+#: daemon/HTTPServer.cpp:148
msgid "building"
msgstr ""
-#: daemon/HTTPServer.cpp:218
+#: daemon/HTTPServer.cpp:149
msgid "failed"
msgstr ""
-#: daemon/HTTPServer.cpp:219
+#: daemon/HTTPServer.cpp:150
msgid "expiring"
msgstr ""
-#: daemon/HTTPServer.cpp:220
+#: daemon/HTTPServer.cpp:151
msgid "established"
msgstr ""
-#: daemon/HTTPServer.cpp:221
+#: daemon/HTTPServer.cpp:152
msgid "unknown"
msgstr ""
-#: daemon/HTTPServer.cpp:223
+#: daemon/HTTPServer.cpp:154
msgid "exploratory"
msgstr ""
-#: daemon/HTTPServer.cpp:259
+#. tr: Webconsole page title
+#: daemon/HTTPServer.cpp:185
+msgid "Purple I2P Webconsole"
+msgstr ""
+
+#: daemon/HTTPServer.cpp:190
msgid "<b>i2pd</b> webconsole"
msgstr ""
-#: daemon/HTTPServer.cpp:262
+#: daemon/HTTPServer.cpp:193
msgid "Main page"
msgstr ""
-#: daemon/HTTPServer.cpp:263 daemon/HTTPServer.cpp:725
+#: daemon/HTTPServer.cpp:194 daemon/HTTPServer.cpp:700
msgid "Router commands"
msgstr ""
-#: daemon/HTTPServer.cpp:264 daemon/HTTPServer.cpp:448
-#: daemon/HTTPServer.cpp:460
+#: daemon/HTTPServer.cpp:195 daemon/HTTPServer.cpp:382
+#: daemon/HTTPServer.cpp:394
msgid "Local Destinations"
msgstr ""
-#: daemon/HTTPServer.cpp:266 daemon/HTTPServer.cpp:418
-#: daemon/HTTPServer.cpp:504 daemon/HTTPServer.cpp:510
-#: daemon/HTTPServer.cpp:641 daemon/HTTPServer.cpp:684
-#: daemon/HTTPServer.cpp:688
+#: daemon/HTTPServer.cpp:197 daemon/HTTPServer.cpp:352
+#: daemon/HTTPServer.cpp:438 daemon/HTTPServer.cpp:444
+#: daemon/HTTPServer.cpp:597 daemon/HTTPServer.cpp:640
+#: daemon/HTTPServer.cpp:644
msgid "LeaseSets"
msgstr ""
-#: daemon/HTTPServer.cpp:268 daemon/HTTPServer.cpp:694
+#: daemon/HTTPServer.cpp:199 daemon/HTTPServer.cpp:650
msgid "Tunnels"
msgstr ""
-#: daemon/HTTPServer.cpp:269 daemon/HTTPServer.cpp:425
-#: daemon/HTTPServer.cpp:787 daemon/HTTPServer.cpp:803
+#: daemon/HTTPServer.cpp:201 daemon/HTTPServer.cpp:359
+#: daemon/HTTPServer.cpp:770 daemon/HTTPServer.cpp:786
msgid "Transit Tunnels"
msgstr ""
-#: daemon/HTTPServer.cpp:270 daemon/HTTPServer.cpp:852
+#: daemon/HTTPServer.cpp:203 daemon/HTTPServer.cpp:839
msgid "Transports"
msgstr ""
-#: daemon/HTTPServer.cpp:271
+#: daemon/HTTPServer.cpp:204
msgid "I2P tunnels"
msgstr ""
-#: daemon/HTTPServer.cpp:273 daemon/HTTPServer.cpp:914
-#: daemon/HTTPServer.cpp:924
+#: daemon/HTTPServer.cpp:206 daemon/HTTPServer.cpp:908
+#: daemon/HTTPServer.cpp:918
msgid "SAM sessions"
msgstr ""
-#: daemon/HTTPServer.cpp:289 daemon/HTTPServer.cpp:1306
-#: daemon/HTTPServer.cpp:1309 daemon/HTTPServer.cpp:1312
-#: daemon/HTTPServer.cpp:1326 daemon/HTTPServer.cpp:1371
-#: daemon/HTTPServer.cpp:1374 daemon/HTTPServer.cpp:1377
+#: daemon/HTTPServer.cpp:222 daemon/HTTPServer.cpp:1302
+#: daemon/HTTPServer.cpp:1305 daemon/HTTPServer.cpp:1308
+#: daemon/HTTPServer.cpp:1322 daemon/HTTPServer.cpp:1367
+#: daemon/HTTPServer.cpp:1370 daemon/HTTPServer.cpp:1373
msgid "ERROR"
msgstr ""
-#: daemon/HTTPServer.cpp:296
+#: daemon/HTTPServer.cpp:229
msgid "OK"
msgstr ""
-#: daemon/HTTPServer.cpp:297
+#: daemon/HTTPServer.cpp:230
msgid "Testing"
msgstr ""
-#: daemon/HTTPServer.cpp:298
+#: daemon/HTTPServer.cpp:231
msgid "Firewalled"
msgstr ""
-#: daemon/HTTPServer.cpp:299 daemon/HTTPServer.cpp:320
-#: daemon/HTTPServer.cpp:406
+#: daemon/HTTPServer.cpp:232 daemon/HTTPServer.cpp:253
+#: daemon/HTTPServer.cpp:325
msgid "Unknown"
msgstr ""
-#: daemon/HTTPServer.cpp:300 daemon/HTTPServer.cpp:435
-#: daemon/HTTPServer.cpp:436 daemon/HTTPServer.cpp:982
-#: daemon/HTTPServer.cpp:991
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/i18n/README.md
^
|
@@ -9,7 +9,7 @@
---
```
-in: msgid\ \"(.*)\"\nmsgid_plural\ \"(.*)\"\nmsgstr\[0\]\ \"(.*)\"\nmsgstr\[1\]\ \"(.*)\"\n(msgstr\[2\]\ \"(.*)\"\n)?(msgstr\[3\]\ \"(.*)\"\n)?(msgstr\[4\]\ \"(.*)\"\n)?(msgstr\[5\]\ \"(.*)\"\n)?
+in: msgid\ \"(.*)\"\nmsgid_plural\ \"(.*)\"\nmsgstr\[0\]\ \"(.*)\"\n(msgstr\[1\]\ \"(.*)\"\n)?(msgstr\[2\]\ \"(.*)\"\n)?(msgstr\[3\]\ \"(.*)\"\n)?(msgstr\[4\]\ \"(.*)\"\n)?(msgstr\[5\]\ \"(.*)\"\n)?
out: #{"$2", {"$3", "$4", "$6", "$8", "$10"}},\n
```
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/i2pd.conf
^
|
@@ -76,7 +76,7 @@
ipv6 = false
## Enable SSU transport (default = true)
-# ssu = true
+ssu = false
## Bandwidth configuration
## L limit bandwidth to 32KBs/sec, O - to 256KBs/sec, P - to 2048KBs/sec,
@@ -96,6 +96,22 @@
## Note: that mode uses much more network connections and CPU!
# floodfill = true
+[ntcp2]
+## Enable NTCP2 transport (default = true)
+# enabled = true
+## Publish address in RouterInfo (default = true)
+# published = true
+## Port for incoming connections (default is global port option value)
+# port = 4567
+
+[ssu2]
+## Enable SSU2 transport (default = false for 2.43.0)
+enabled = true
+## Publish address in RouterInfo (default = false for 2.43.0)
+published = true
+## Port for incoming connections (default is global port option value or port + 1 if SSU is enabled)
+# port = 4567
+
[http]
## Web Console settings
## Uncomment and set to 'false' to disable Web Console
@@ -110,8 +126,8 @@
# user = i2pd
# pass = changeme
## Select webconsole language
-## Currently supported english (default), afrikaans, armenian, german, russian,
-## turkmen, ukrainian and uzbek languages
+## Currently supported english (default), afrikaans, armenian, chinese, french,
+## german, russian, turkmen, ukrainian and uzbek languages
# lang = english
[httpproxy]
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/rpm/i2pd-git.spec
^
|
@@ -1,7 +1,7 @@
%define git_hash %(git rev-parse HEAD | cut -c -7)
Name: i2pd-git
-Version: 2.41.0
+Version: 2.43.0
Release: git%{git_hash}%{?dist}
Summary: I2P router written in C++
Conflicts: i2pd
@@ -57,6 +57,10 @@
%endif
+%if 0%{?rhel} == 9
+pushd redhat-linux-build
+%endif
+
%if 0%{?fedora} >= 35
pushd redhat-linux-build
%else
@@ -71,6 +75,10 @@
make %{?_smp_mflags}
+%if 0%{?rhel} == 9
+popd
+%endif
+
%if 0%{?fedora} >= 33
popd
%endif
@@ -82,6 +90,10 @@
%install
pushd build
+%if 0%{?rhel} == 9
+pushd redhat-linux-build
+%endif
+
%if 0%{?fedora} >= 35
pushd redhat-linux-build
%else
@@ -146,6 +158,15 @@
%changelog
+* Mon Aug 22 2022 orignal <orignal@i2pmail.org> - 2.43.0
+- update to 2.43.0
+
+* Tue May 24 2022 r4sas <r4sas@i2pmail.org> - 2.42.1
+- update to 2.42.1
+
+* Sun May 22 2022 orignal <orignal@i2pmail.org> - 2.42.0
+- update to 2.42.0
+
* Sun Feb 20 2022 r4sas <r4sas@i2pmail.org> - 2.41.0
- update to 2.41.0
- fixed build on Fedora Copr over openssl trunk code
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/contrib/rpm/i2pd.spec
^
|
@@ -1,5 +1,5 @@
Name: i2pd
-Version: 2.41.0
+Version: 2.43.0
Release: 1%{?dist}
Summary: I2P router written in C++
Conflicts: i2pd-git
@@ -54,6 +54,10 @@
%endif
%endif
+%if 0%{?rhel} == 9
+pushd redhat-linux-build
+%endif
+
%if 0%{?fedora} >= 35
pushd redhat-linux-build
%else
@@ -68,6 +72,10 @@
make %{?_smp_mflags}
+%if 0%{?rhel} == 9
+popd
+%endif
+
%if 0%{?fedora} >= 33
popd
%endif
@@ -79,6 +87,10 @@
%install
pushd build
+%if 0%{?rhel} == 9
+pushd redhat-linux-build
+%endif
+
%if 0%{?fedora} >= 35
pushd redhat-linux-build
%else
@@ -143,6 +155,15 @@
%changelog
+* Mon Aug 22 2022 orignal <orignal@i2pmail.org> - 2.43.0
+- update to 2.43.0
+
+* Tue May 24 2022 r4sas <r4sas@i2pmail.org> - 2.42.1
+- update to 2.42.1
+
+* Sun May 22 2022 orignal <orignal@i2pmail.org> - 2.42.0
+- update to 2.42.0
+
* Sun Feb 20 2022 r4sas <r4sas@i2pmail.org> - 2.41.0
- update to 2.41.0
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/Daemon.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -58,12 +58,16 @@
bool Daemon_Singleton::IsService () const
{
bool service = false;
-#ifndef _WIN32
i2p::config::GetOption("service", service);
-#endif
return service;
}
+ void Daemon_Singleton::setDataDir(std::string path)
+ {
+ if (path != "")
+ DaemonDataDir = path;
+ }
+
bool Daemon_Singleton::init(int argc, char* argv[]) {
return init(argc, argv, nullptr);
}
@@ -73,8 +77,14 @@
i2p::config::Init();
i2p::config::ParseCmdline(argc, argv);
- std::string config; i2p::config::GetOption("conf", config);
- std::string datadir; i2p::config::GetOption("datadir", datadir);
+ std::string config; i2p::config::GetOption("conf", config);
+ std::string datadir;
+ if(DaemonDataDir != "") {
+ datadir = DaemonDataDir;
+ } else {
+ i2p::config::GetOption("datadir", datadir);
+ }
+
i2p::fs::DetectDataDir(datadir, IsService());
i2p::fs::Init();
@@ -99,9 +109,9 @@
certsdir = i2p::fs::GetCertsDir();
- std::string logs = ""; i2p::config::GetOption("log", logs);
- std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
- std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
+ std::string logs = ""; i2p::config::GetOption("log", logs);
+ std::string logfile = ""; i2p::config::GetOption("logfile", logfile);
+ std::string loglevel = ""; i2p::config::GetOption("loglevel", loglevel);
bool logclftime; i2p::config::GetOption("logclftime", logclftime);
/* setup logging */
@@ -143,6 +153,9 @@
bool aesni; i2p::config::GetOption("cpuext.aesni", aesni);
bool avx; i2p::config::GetOption("cpuext.avx", avx);
bool forceCpuExt; i2p::config::GetOption("cpuext.force", forceCpuExt);
+ bool ssu; i2p::config::GetOption("ssu", ssu);
+ if (!ssu && i2p::config::IsDefault ("precomputation.elgamal"))
+ precomputation = false; // we don't elgamal table if no ssu, unless it's specified explicitly
i2p::crypto::InitCrypto (precomputation, aesni, avx, forceCpuExt);
int netID; i2p::config::GetOption("netid", netID);
@@ -151,11 +164,7 @@
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
-#ifdef MESHNET
- // manual override for meshnet
- ipv4 = false;
- ipv6 = true;
-#endif
+
// ifname -> address
std::string ifname; i2p::config::GetOption("ifname", ifname);
if (ipv4 && i2p::config::IsDefault ("address4"))
@@ -244,6 +253,18 @@
if (!ipv4 && !ipv6)
i2p::context.SetStatus (eRouterStatusMesh);
}
+ if (!ssu) i2p::context.RemoveSSUAddress (); // TODO: remove later
+ bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
+ if (ssu2)
+ {
+ uint16_t ssu2port; i2p::config::GetOption("ssu2.port", ssu2port);
+ if (!ssu2port) ssu2port = ssu ? (port + 1) : port;
+ bool published; i2p::config::GetOption("ssu2.published", published);
+ if (published)
+ i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish
+ else
+ i2p::context.PublishSSU2Address (ssu2port, false, ipv4, ipv6); // unpublish
+ }
bool transit; i2p::config::GetOption("notransit", transit);
i2p::context.SetAcceptsTunnels (!transit);
@@ -377,6 +398,7 @@
}
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
+ bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
bool ssu; i2p::config::GetOption("ssu", ssu);
bool checkInReserved; i2p::config::GetOption("reservedrange", checkInReserved);
LogPrint(eLogInfo, "Daemon: Starting Transports");
@@ -384,8 +406,8 @@
if(!ntcp2) LogPrint(eLogInfo, "Daemon: NTCP2 disabled");
i2p::transport::transports.SetCheckReserved(checkInReserved);
- i2p::transport::transports.Start(ntcp2, ssu);
- if (i2p::transport::transports.IsBoundSSU() || i2p::transport::transports.IsBoundNTCP2())
+ i2p::transport::transports.Start(ntcp2, ssu, ssu2);
+ if (i2p::transport::transports.IsBoundSSU() || i2p::transport::transports.IsBoundSSU2() || i2p::transport::transports.IsBoundNTCP2())
LogPrint(eLogInfo, "Daemon: Transports started");
else
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/Daemon.h
^
|
@@ -20,27 +20,33 @@
class Daemon_Singleton_Private;
class Daemon_Singleton
{
- public:
+ public:
- virtual bool init(int argc, char* argv[], std::shared_ptr<std::ostream> logstream);
- virtual bool init(int argc, char* argv[]);
- virtual bool start();
- virtual bool stop();
- virtual void run () {};
+ virtual bool init (int argc, char* argv[], std::shared_ptr<std::ostream> logstream);
+ virtual bool init (int argc, char* argv[]);
+ virtual bool start ();
+ virtual bool stop ();
+ virtual void run () {};
- bool isDaemon;
- bool running;
+ virtual void setDataDir (std::string path);
- protected:
+ bool isDaemon;
+ bool running;
- Daemon_Singleton();
- virtual ~Daemon_Singleton();
+ protected:
- bool IsService () const;
+ Daemon_Singleton ();
+ virtual ~Daemon_Singleton ();
- // d-pointer for httpServer, httpProxy, etc.
- class Daemon_Singleton_Private;
- Daemon_Singleton_Private &d;
+ bool IsService () const;
+
+ // d-pointer for httpServer, httpProxy, etc.
+ class Daemon_Singleton_Private;
+ Daemon_Singleton_Private &d;
+
+ private:
+
+ std::string DaemonDataDir;
};
#if defined(QT_GUI_LIB) // check if QT
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/HTTPServer.cpp
^
|
@@ -182,7 +182,7 @@
" <meta charset=\"UTF-8\">\r\n"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n"
" <link rel=\"shortcut icon\" href=\"" << itoopieFavicon << "\">\r\n"
- " <title>Purple I2P " VERSION " Webconsole</title>\r\n";
+ " <title>" << tr(/* tr: Webconsole page title */ "Purple I2P Webconsole") << "</title>\r\n";
GetStyles(s);
s <<
"</head>\r\n"
@@ -196,8 +196,10 @@
if (i2p::context.IsFloodfill ())
s << " <a href=\"" << webroot << "?page=" << HTTP_PAGE_LEASESETS << "\">" << tr("LeaseSets") << "</a><br>\r\n";
s <<
- " <a href=\"" << webroot << "?page=" << HTTP_PAGE_TUNNELS << "\">" << tr("Tunnels") << "</a><br>\r\n"
- " <a href=\"" << webroot << "?page=" << HTTP_PAGE_TRANSIT_TUNNELS << "\">" << tr("Transit Tunnels") << "</a><br>\r\n"
+ " <a href=\"" << webroot << "?page=" << HTTP_PAGE_TUNNELS << "\">" << tr("Tunnels") << "</a><br>\r\n";
+ if (i2p::context.AcceptsTunnels () || i2p::tunnel::tunnels.CountTransitTunnels())
+ s << " <a href=\"" << webroot << "?page=" << HTTP_PAGE_TRANSIT_TUNNELS << "\">" << tr("Transit Tunnels") << "</a><br>\r\n";
+ s <<
" <a href=\"" << webroot << "?page=" << HTTP_PAGE_TRANSPORTS << "\">" << tr ("Transports") << "</a><br>\r\n"
" <a href=\"" << webroot << "?page=" << HTTP_PAGE_I2P_TUNNELS << "\">" << tr("I2P tunnels") << "</a><br>\r\n";
if (i2p::client::context.GetSAMBridge ())
@@ -220,7 +222,7 @@
s << "<b>" << tr("ERROR") << ":</b> " << string << "<br>\r\n";
}
- static void ShowNetworkStatus (std::stringstream& s, RouterStatus status)
+ static void ShowNetworkStatus (std::stringstream& s, RouterStatus status, RouterError error)
{
switch (status)
{
@@ -233,7 +235,7 @@
case eRouterStatusError:
{
s << tr("Error");
- switch (i2p::context.GetError ())
+ switch (error)
{
case eRouterErrorClockSkew:
s << " - " << tr("Clock skew");
@@ -258,12 +260,12 @@
ShowUptime(s, i2p::context.GetUptime ());
s << "<br>\r\n";
s << "<b>" << tr("Network status") << ":</b> ";
- ShowNetworkStatus (s, i2p::context.GetStatus ());
+ ShowNetworkStatus (s, i2p::context.GetStatus (), i2p::context.GetError ());
s << "<br>\r\n";
if (i2p::context.SupportsV6 ())
{
s << "<b>" << tr("Network status v6") << ":</b> ";
- ShowNetworkStatus (s, i2p::context.GetStatusV6 ());
+ ShowNetworkStatus (s, i2p::context.GetStatusV6 (), i2p::context.GetErrorV6 ());
s << "<br>\r\n";
}
#if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY))
@@ -295,10 +297,10 @@
s << " (" << (double) i2p::transport::transports.GetTransitBandwidth () / 1024 << " " << tr(/* tr: Kibibit/s */ "KiB/s") << ")<br>\r\n";
s << "<b>" << tr("Data path") << ":</b> " << i2p::fs::GetUTF8DataDir() << "<br>\r\n";
s << "<div class='slide'>";
- if((outputFormat == OutputFormatEnum::forWebConsole) || !includeHiddenContent) {
+ if ((outputFormat == OutputFormatEnum::forWebConsole) || !includeHiddenContent) {
s << "<label for=\"slide-info\">" << tr("Hidden content. Press on text to see.") << "</label>\r\n<input type=\"checkbox\" id=\"slide-info\" />\r\n<div class=\"slidecontent\">\r\n";
}
- if(includeHiddenContent) {
+ if (includeHiddenContent) {
s << "<b>" << tr("Router Ident") << ":</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";
if (!i2p::context.GetRouterInfo().GetProperty("family").empty())
s << "<b>" << tr("Router Family") << ":</b> " << i2p::context.GetRouterInfo().GetProperty("family") << "<br>\r\n";
@@ -307,41 +309,42 @@
s << "<b>"<< tr("Our external address") << ":</b>" << "<br>\r\n<table class=\"extaddr\"><tbody>\r\n";
for (const auto& address : i2p::context.GetRouterInfo().GetAddresses())
{
- s << "<tr>\r\n";
- if (address->IsNTCP2 () && !address->IsPublishedNTCP2 ())
- {
- s << "<td>NTCP2";
- if (address->host.is_v6 ()) s << "v6";
- s << "</td><td>" << tr("supported") << "</td>\r\n</tr>\r\n";
- continue;
- }
+ s << "<tr>\r\n<td>";
switch (address->transportStyle)
{
case i2p::data::RouterInfo::eTransportNTCP:
- {
- s << "<td>NTCP";
- if (address->IsPublishedNTCP2 ()) s << "2";
- if (address->host.is_v6 ()) s << "v6";
- s << "</td>\r\n";
- break;
- }
+ s << "NTCP2";
+ break;
case i2p::data::RouterInfo::eTransportSSU:
- {
- s << "<td>SSU";
- if (address->host.is_v6 ())
- s << "v6";
- s << "</td>\r\n";
- break;
- }
+ s << "SSU";
+ break;
+ case i2p::data::RouterInfo::eTransportSSU2:
+ s << "SSU2";
+ break;
default:
- s << "<td>" << tr("Unknown") << "</td>\r\n";
+ s << tr("Unknown");
+ }
+ if (address->IsV6 ())
+ {
+ if (address->IsV4 ()) s << "v4";
+ s << "v6";
}
- s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n</tr>\r\n";
+ s << "</td>\r\n";
+ if (address->published)
+ s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n";
+ else
+ {
+ s << "<td>" << tr("supported");
+ if (address->port)
+ s << " :" << address->port;
+ s << "</td>\r\n";
+ }
+ s << "</tr>\r\n";
}
s << "</tbody></table>\r\n";
}
s << "</div>\r\n</div>\r\n";
- if(outputFormat == OutputFormatEnum::forQtUi) {
+ if (outputFormat == OutputFormatEnum::forQtUi) {
s << "<br>";
}
s << "<b>" << tr("Routers") << ":</b> " << i2p::data::netdb.GetNumRouters () << " ";
@@ -355,7 +358,7 @@
s << "<b>" << tr("Client Tunnels") << ":</b> " << std::to_string(clientTunnelCount) << " ";
s << "<b>" << tr("Transit Tunnels") << ":</b> " << std::to_string(transitTunnelCount) << "<br>\r\n<br>\r\n";
- if(outputFormat==OutputFormatEnum::forWebConsole) {
+ if (outputFormat==OutputFormatEnum::forWebConsole) {
bool httpproxy = i2p::client::context.GetHttpProxy () ? true : false;
bool socksproxy = i2p::client::context.GetSocksProxy () ? true : false;
bool bob = i2p::client::context.GetBOBCommandChannel () ? true : false;
@@ -416,7 +419,7 @@
s << "</div>\r\n</div>\r\n";
}
- if(dest->IsPublic())
+ if (dest->IsPublic() && token && !dest->IsEncryptedLeaseSet ())
{
std::string webroot; i2p::config::GetOption("http.webroot", webroot);
auto base32 = dest->GetIdentHash ().ToBase32 ();
@@ -430,7 +433,7 @@
"</form>\r\n<small>" << tr("<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.") << "</small>\r\n</div>\r\n</div>\r\n<br>\r\n";
}
- if(dest->GetNumRemoteLeaseSets())
+ if (dest->GetNumRemoteLeaseSets())
{
s << "<div class='slide'><label for='slide-lease'><b>" << tr("LeaseSets") << ":</b> <i>" << dest->GetNumRemoteLeaseSets ()
<< "</i></label>\r\n<input type=\"checkbox\" id=\"slide-lease\" />\r\n<div class=\"slidecontent\">\r\n<table><thead><th>"<< tr("Address") << "</th><th>" << tr("Type") << "</th><th>" << tr("EncType") << "</th></thead><tbody class=\"tableitem\">";
@@ -446,8 +449,18 @@
s << "<b>" << tr("Inbound tunnels") << ":</b><br>\r\n<div class=\"list\">\r\n";
for (auto & it : pool->GetInboundTunnels ()) {
s << "<div class=\"listitem\">";
- it->Print(s);
- if(it->LatencyIsKnown())
+ // for each tunnel hop if not zero-hop
+ if (it->GetNumHops ())
+ {
+ it->VisitTunnelHops(
+ [&s](std::shared_ptr<const i2p::data::IdentityEx> hopIdent)
+ {
+ s << "⇒ " << i2p::data::GetIdentHashAbbreviation (hopIdent->GetIdentHash ()) << " ";
+ }
+ );
+ }
+ s << "⇒ " << it->GetTunnelID () << ":me";
+ if (it->LatencyIsKnown())
s << " ( " << it->GetMeanLatency() << tr(/* tr: Milliseconds */ "ms") << " )";
ShowTunnelDetails(s, it->GetState (), false, it->GetNumReceivedBytes ());
s << "</div>\r\n";
@@ -456,8 +469,18 @@
s << "<b>" << tr("Outbound tunnels") << ":</b><br>\r\n<div class=\"list\">\r\n";
for (auto & it : pool->GetOutboundTunnels ()) {
s << "<div class=\"listitem\">";
- it->Print(s);
- if(it->LatencyIsKnown())
+ s << it->GetTunnelID () << ":me ⇒";
+ // for each tunnel hop if not zero-hop
+ if (it->GetNumHops ())
+ {
+ it->VisitTunnelHops(
+ [&s](std::shared_ptr<const i2p::data::IdentityEx> hopIdent)
+ {
+ s << " " << i2p::data::GetIdentHashAbbreviation (hopIdent->GetIdentHash ()) << " ⇒";
+ }
+ );
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/HTTPServer.h
^
|
@@ -98,8 +98,8 @@
void ShowSAMSessions (std::stringstream& s);
void ShowI2PTunnels (std::stringstream& s);
void ShowLocalDestination (std::stringstream& s, const std::string& b32, uint32_t token);
- void ShowSAMSession (std::stringstream& s, const std::string& id);
- void ShowI2CPLocalDestination (std::stringstream& s, const std::string& id);
+ void ShowSAMSession (std::stringstream& s, const std::string& id);
+ void ShowI2CPLocalDestination (std::stringstream& s, const std::string& id);
} // http
} // i2p
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/I2PControl.cpp
^
|
@@ -66,29 +66,28 @@
m_SSLContext.use_private_key_file (i2pcp_key, boost::asio::ssl::context::pem);
// handlers
- m_MethodHandlers["Authenticate"] = &I2PControlService::AuthenticateHandler;
- m_MethodHandlers["Echo"] = &I2PControlService::EchoHandler;
- m_MethodHandlers["I2PControl"] = &I2PControlService::I2PControlHandler;
- m_MethodHandlers["RouterInfo"] = &I2PControlService::RouterInfoHandler;
- m_MethodHandlers["RouterManager"] = &I2PControlService::RouterManagerHandler;
- m_MethodHandlers["NetworkSetting"] = &I2PControlService::NetworkSettingHandler;
- m_MethodHandlers["ClientServicesInfo"] = &I2PControlService::ClientServicesInfoHandler;
+ m_MethodHandlers["Authenticate"] = &I2PControlService::AuthenticateHandler;
+ m_MethodHandlers["Echo"] = &I2PControlService::EchoHandler;
+ m_MethodHandlers["I2PControl"] = &I2PControlService::I2PControlHandler;
+ m_MethodHandlers["RouterInfo"] = &I2PControlService::RouterInfoHandler;
+ m_MethodHandlers["RouterManager"] = &I2PControlService::RouterManagerHandler;
+ m_MethodHandlers["NetworkSetting"] = &I2PControlService::NetworkSettingHandler;
+ m_MethodHandlers["ClientServicesInfo"] = &I2PControlService::ClientServicesInfoHandler;
// I2PControl
m_I2PControlHandlers["i2pcontrol.password"] = &I2PControlService::PasswordHandler;
// RouterInfo
- m_RouterInfoHandlers["i2p.router.uptime"] = &I2PControlService::UptimeHandler;
- m_RouterInfoHandlers["i2p.router.version"] = &I2PControlService::VersionHandler;
- m_RouterInfoHandlers["i2p.router.status"] = &I2PControlService::StatusHandler;
- m_RouterInfoHandlers["i2p.router.netdb.knownpeers"] = &I2PControlService::NetDbKnownPeersHandler;
- m_RouterInfoHandlers["i2p.router.netdb.activepeers"] = &I2PControlService::NetDbActivePeersHandler;
- m_RouterInfoHandlers["i2p.router.net.bw.inbound.1s"] = &I2PControlService::InboundBandwidth1S;
- m_RouterInfoHandlers["i2p.router.net.bw.outbound.1s"] = &I2PControlService::OutboundBandwidth1S;
- m_RouterInfoHandlers["i2p.router.net.status"] = &I2PControlService::NetStatusHandler;
+ m_RouterInfoHandlers["i2p.router.uptime"] = &I2PControlService::UptimeHandler;
+ m_RouterInfoHandlers["i2p.router.version"] = &I2PControlService::VersionHandler;
+ m_RouterInfoHandlers["i2p.router.status"] = &I2PControlService::StatusHandler;
+ m_RouterInfoHandlers["i2p.router.netdb.knownpeers"] = &I2PControlService::NetDbKnownPeersHandler;
+ m_RouterInfoHandlers["i2p.router.netdb.activepeers"] = &I2PControlService::NetDbActivePeersHandler;
+ m_RouterInfoHandlers["i2p.router.net.bw.inbound.1s"] = &I2PControlService::InboundBandwidth1S;
+ m_RouterInfoHandlers["i2p.router.net.bw.outbound.1s"] = &I2PControlService::OutboundBandwidth1S;
+ m_RouterInfoHandlers["i2p.router.net.status"] = &I2PControlService::NetStatusHandler;
m_RouterInfoHandlers["i2p.router.net.tunnels.participating"] = &I2PControlService::TunnelsParticipatingHandler;
- m_RouterInfoHandlers["i2p.router.net.tunnels.successrate"] =
-&I2PControlService::TunnelsSuccessRateHandler;
+ m_RouterInfoHandlers["i2p.router.net.tunnels.successrate"] = &I2PControlService::TunnelsSuccessRateHandler;
m_RouterInfoHandlers["i2p.router.net.total.received.bytes"] = &I2PControlService::NetTotalReceivedBytes;
m_RouterInfoHandlers["i2p.router.net.total.sent.bytes"] = &I2PControlService::NetTotalSentBytes;
@@ -104,10 +103,10 @@
// ClientServicesInfo
m_ClientServicesInfoHandlers["I2PTunnel"] = &I2PControlService::I2PTunnelInfoHandler;
m_ClientServicesInfoHandlers["HTTPProxy"] = &I2PControlService::HTTPProxyInfoHandler;
- m_ClientServicesInfoHandlers["SOCKS"] = &I2PControlService::SOCKSInfoHandler;
- m_ClientServicesInfoHandlers["SAM"] = &I2PControlService::SAMInfoHandler;
- m_ClientServicesInfoHandlers["BOB"] = &I2PControlService::BOBInfoHandler;
- m_ClientServicesInfoHandlers["I2CP"] = &I2PControlService::I2CPInfoHandler;
+ m_ClientServicesInfoHandlers["SOCKS"] = &I2PControlService::SOCKSInfoHandler;
+ m_ClientServicesInfoHandlers["SAM"] = &I2PControlService::SAMInfoHandler;
+ m_ClientServicesInfoHandlers["BOB"] = &I2PControlService::BOBInfoHandler;
+ m_ClientServicesInfoHandlers["I2CP"] = &I2PControlService::I2CPInfoHandler;
}
I2PControlService::~I2PControlService ()
@@ -168,7 +167,7 @@
Accept ();
if (ecode) {
- LogPrint (eLogError, "I2PControl: Accept error: ", ecode.message ());
+ LogPrint (eLogError, "I2PControl: Accept error: ", ecode.message ());
return;
}
LogPrint (eLogDebug, "I2PControl: New request from ", socket->lowest_layer ().remote_endpoint ());
@@ -290,12 +289,12 @@
{
ss << "\"" << name << "\":";
if (value.length () > 0)
- {
+ {
if (quotes)
ss << "\"" << value << "\"";
else
ss << value;
- }
+ }
else
ss << "null";
}
@@ -479,7 +478,7 @@
void I2PControlService::NetTotalSentBytes (std::ostringstream& results)
{
- InsertParam (results, "i2p.router.net.total.sent.bytes", (double)i2p::transport::transports.GetTotalSentBytes ());
+ InsertParam (results, "i2p.router.net.total.sent.bytes", (double)i2p::transport::transports.GetTotalSentBytes ());
}
@@ -507,7 +506,7 @@
m_ShutdownTimer.expires_from_now (boost::posix_time::seconds(1)); // 1 second to make sure response has been sent
m_ShutdownTimer.async_wait (
[](const boost::system::error_code& ecode)
- {
+ {
Daemon.running = 0;
});
}
@@ -521,7 +520,7 @@
m_ShutdownTimer.expires_from_now (boost::posix_time::seconds(timeout + 1)); // + 1 second
m_ShutdownTimer.async_wait (
[](const boost::system::error_code& ecode)
- {
+ {
Daemon.running = 0;
});
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/UPnP.cpp
^
|
@@ -93,7 +93,7 @@
#endif
isError = err != UPNPDISCOVER_SUCCESS;
-#else // MINIUPNPC_API_VERSION >= 8
+#else // MINIUPNPC_API_VERSION >= 8
err = 0;
m_Devlist = upnpDiscover (UPNP_RESPONSE_TIMEOUT, NULL, NULL, 0);
isError = m_Devlist == NULL;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/UPnP.h
^
|
@@ -51,7 +51,7 @@
private:
void Discover ();
- int CheckMapping (const char* port, const char* type);
+ int CheckMapping (const char* port, const char* type);
void PortMapping ();
void TryPortMapping (std::shared_ptr<i2p::data::RouterInfo::Address> address);
void CloseMapping ();
@@ -80,7 +80,7 @@
}
}
-#else // USE_UPNP
+#else // USE_UPNP
namespace i2p {
namespace transport {
/* class stub */
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/daemon/UnixDaemon.cpp
^
|
@@ -24,6 +24,7 @@
#include "Tunnel.h"
#include "RouterContext.h"
#include "ClientContext.h"
+#include "Transports.h"
void handle_signal(int sig)
{
@@ -54,6 +55,14 @@
case SIGPIPE:
LogPrint(eLogInfo, "SIGPIPE received");
break;
+ case SIGTSTP:
+ LogPrint(eLogInfo, "Daemon: Got SIGTSTP, disconnecting from network...");
+ i2p::transport::transports.SetOnline(false);
+ break;
+ case SIGCONT:
+ LogPrint(eLogInfo, "Daemon: Got SIGCONT, restoring connection to network...");
+ i2p::transport::transports.SetOnline(true);
+ break;
}
}
@@ -171,6 +180,9 @@
}
gracefulShutdownInterval = 0; // not specified
+ // handle signal TSTP
+ bool handleTSTP; i2p::config::GetOption("unix.handle_sigtstp", handleTSTP);
+
// Signal handler
struct sigaction sa;
sa.sa_handler = handle_signal;
@@ -182,6 +194,11 @@
sigaction(SIGTERM, &sa, 0);
sigaction(SIGINT, &sa, 0);
sigaction(SIGPIPE, &sa, 0);
+ if (handleTSTP)
+ {
+ sigaction(SIGTSTP, &sa, 0);
+ sigaction(SIGCONT, &sa, 0);
+ }
return Daemon_Singleton::start();
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/debian/changelog
^
|
@@ -1,3 +1,22 @@
+i2pd (2.43.0-1) unstable; urgency=medium
+
+ * updated to version 2.43.0/0.9.55
+
+ -- orignal <orignal@i2pmail.org> Mon, 22 Aug 2022 16:00:00 +0000
+
+i2pd (2.42.1-1) unstable; urgency=medium
+
+ * updated to version 2.42.1/0.9.54
+ * remove -O3 optimization flag
+
+ -- r4sas <r4sas@i2pmail.org> Tue, 24 May 2022 12:00:00 +0000
+
+i2pd (2.42.0-1) unstable; urgency=medium
+
+ * updated to version 2.42.0/0.9.54
+
+ -- orignal <orignal@i2pmail.org> Sun, 22 May 2022 16:00:00 +0000
+
i2pd (2.41.0-1) unstable; urgency=medium
* updated to version 2.41.0/0.9.53
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/debian/patches/02-upnp.patch
^
|
@@ -2,14 +2,14 @@
Author: r4sas <r4sas@i2pmail.org>
Reviewed-By: r4sas <r4sas@i2pmail.org>
-Last-Update: 2021-10-22
+Last-Update: 2022-03-23
--- i2pd.orig/Makefile
+++ i2pd/Makefile
-@@ -32,7 +32,7 @@ include filelist.mk
+@@ -31,7 +31,7 @@ include filelist.mk
+
USE_AESNI := $(or $(USE_AESNI),yes)
USE_STATIC := $(or $(USE_STATIC),no)
- USE_MESHNET := $(or $(USE_MESHNET),no)
-USE_UPNP := $(or $(USE_UPNP),no)
+USE_UPNP := $(or $(USE_UPNP),yes)
DEBUG := $(or $(DEBUG),yes)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/debian/rules
^
|
@@ -1,16 +1,13 @@
#!/usr/bin/make -f
#export DH_VERBOSE=1
-
-
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
-
include /usr/share/dpkg/architecture.mk
-export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic -O3
-
+export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND =
-
%:
dh $@ --parallel
+
+override_dh_auto_install:
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/i18n/Chinese.cpp
^
|
@@ -0,0 +1,217 @@
+/*
+* Copyright (c) 2022, The PurpleI2P Project
+*
+* This file is part of Purple i2pd project and licensed under BSD3
+*
+* See full license text in LICENSE file at top of project tree
+*/
+
+#include <map>
+#include <vector>
+#include <string>
+#include <memory>
+#include "I18N.h"
+
+// Simplified Chinese localization file
+// This is an example translation file without strings in it.
+
+namespace i2p
+{
+namespace i18n
+{
+namespace chinese // language namespace
+{
+ // language name in lowercase
+ static std::string language = "chinese";
+
+ // See for language plural forms here:
+ // https://localization-guide.readthedocs.io/en/latest/l10n/pluralforms.html
+ static int plural (int n) {
+ return 0;
+ }
+
+ static std::map<std::string, std::string> strings
+ {
+ {"KiB", "KiB"},
+ {"MiB", "MiB"},
+ {"GiB", "GiB"},
+ {"building", "正在构建"},
+ {"failed", "连接失败"},
+ {"expiring", "即将过期"},
+ {"established", "连接已建立"},
+ {"unknown", "未知"},
+ {"exploratory", "探测"},
+ {"Purple I2P Webconsole", "Purple I2P 网页控制台"},
+ {"<b>i2pd</b> webconsole", "<b>i2pd</b> 网页控制台"},
+ {"Main page", "主页"},
+ {"Router commands", "路由命令"},
+ {"Local Destinations", "本地目标"},
+ {"LeaseSets", "租契集"},
+ {"Tunnels", "隧道"},
+ {"Transit Tunnels", "中转隧道"},
+ {"Transports", "传输"},
+ {"I2P tunnels", "I2P 隧道"},
+ {"SAM sessions", "SAM 会话"},
+ {"ERROR", "错误"},
+ {"OK", "良好"},
+ {"Testing", "测试中"},
+ {"Firewalled", "受到防火墙限制"},
+ {"Unknown", "未知"},
+ {"Proxy", "代理"},
+ {"Mesh", "Mesh组网"},
+ {"Error", "错误"},
+ {"Clock skew", "时钟偏移"},
+ {"Offline", "离线"},
+ {"Symmetric NAT", "对称 NAT"},
+ {"Uptime", "运行时间"},
+ {"Network status", "IPv4 网络状态"},
+ {"Network status v6", "IPv6 网络状态"},
+ {"Stopping in", "距停止还有:"},
+ {"Family", "家族"},
+ {"Tunnel creation success rate", "隧道创建成功率"},
+ {"Received", "已接收"},
+ {"KiB/s", "KiB/s"},
+ {"Sent", "已发送"},
+ {"Transit", "中转"},
+ {"Data path", "数据文件路径"},
+ {"Hidden content. Press on text to see.", "隐藏内容 请点击此处查看。"},
+ {"Router Ident", "路由身份"},
+ {"Router Family", "路由器家族"},
+ {"Router Caps", "路由器类型"},
+ {"Version", "版本"},
+ {"Our external address", "外部地址"},
+ {"supported", "支持"},
+ {"Routers", "路由节点"},
+ {"Floodfills", "洪泛节点"},
+ {"Client Tunnels", "客户端隧道"},
+ {"Services", "服务"},
+ {"Enabled", "启用"},
+ {"Disabled", "禁用"},
+ {"Encrypted B33 address", "加密的 B33 地址"},
+ {"Address registration line", "地址域名注册"},
+ {"Domain", "域名"},
+ {"Generate", "生成"},
+ {"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>注意:</b> 结果字符串可以用于注册次级域名(例如:example.i2p)。若需注册次级域名,请使用 i2pd-tools。"},
+ {"Address", "地址"},
+ {"Type", "类型"},
+ {"EncType", "加密类型"},
+ {"Inbound tunnels", "入站隧道"},
+ {"ms", "毫秒"},
+ {"Outbound tunnels", "出站隧道"},
+ {"Tags", "标签"},
+ {"Incoming", "传入"},
+ {"Outgoing", "传出"},
+ {"Destination", "目标"},
+ {"Amount", "数量"},
+ {"Incoming Tags", "传入标签"},
+ {"Tags sessions", "标签会话"},
+ {"Status", "状态"},
+ {"Local Destination", "本地目标"},
+ {"Streams", "流"},
+ {"Close stream", "断开流"},
+ {"I2CP session not found", "未找到 I2CP 会话"},
+ {"I2CP is not enabled", "I2CP 未启用"},
+ {"Invalid", "无效"},
+ {"Store type", "存储类型"},
+ {"Expires", "过期时间"},
+ {"Non Expired Leases", "未到期的租约"},
+ {"Gateway", "网关"},
+ {"TunnelID", "隧道 ID"},
+ {"EndDate", "结束日期"},
+ {"not floodfill", "非洪泛"},
+ {"Queue size", "队列大小"},
+ {"Run peer test", "运行群体测试"},
+ {"Decline transit tunnels", "拒绝中转隧道"},
+ {"Accept transit tunnels", "允许中转隧道"},
+ {"Cancel graceful shutdown", "取消离线"},
+ {"Start graceful shutdown", "优雅地离线"},
+ {"Force shutdown", "强制停止"},
+ {"Reload external CSS styles", "重载外部 CSS 样式"},
+ {"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b>注意:</b> 此处完成的任何操作都不是永久的,不会更改您的配置文件。"},
+ {"Logging level", "日志级别"},
+ {"Transit tunnels limit", "中转隧道限制"},
+ {"Change", "更换"},
+ {"Change language", "更换语言"},
+ {"no transit tunnels currently built", "目前未构建中转隧道"},
+ {"SAM disabled", "SAM 已禁用"},
+ {"no sessions currently running", "没有正在运行的会话"},
+ {"SAM session not found", "未找到 SAM 会话"},
+ {"SAM Session", "SAM 会话"},
+ {"Server Tunnels", "服务器隧道"},
+ {"Client Forwards", "客户端转发"},
+ {"Server Forwards", "服务器转发"},
+ {"Unknown page", "未知页面"},
+ {"Invalid token", "无效凭证"},
+ {"SUCCESS", "成功"},
+ {"Stream closed", "流已关闭"},
+ {"Stream not found or already was closed", "流未找到或已关闭"},
+ {"Destination not found", "找不到目标"},
+ {"StreamID can't be null", "StreamID 不能为空"},
+ {"Return to destination page", "返回目标页面"},
+ {"You will be redirected in 5 seconds", "您将在5秒内被重定向"},
+ {"Transit tunnels count must not exceed 65535", "中转隧道数量不能超过 65535"},
+ {"Back to commands list", "返回命令列表"},
+ {"Register at reg.i2p", "在 reg.i2p 注册域名"},
+ {"Description", "描述"},
+ {"A bit information about service on domain", "在此域名上运行的服务的一些信息"},
+ {"Submit", "提交"},
+ {"Domain can't end with .b32.i2p", "域名不能以 .b32.i2p 结尾"},
+ {"Domain must end with .i2p", "域名必须以 .i2p 结尾"},
+ {"Such destination is not found", "找不到此目标"},
+ {"Unknown command", "未知指令"},
+ {"Command accepted", "已接受指令"},
+ {"Proxy error", "代理错误"},
+ {"Proxy info", "代理信息"},
+ {"Proxy error: Host not found", "代理错误:找不到主机"},
+ {"Remote host not found in router's addressbook", "在路由的地址簿中找不到远程主机"},
+ {"You may try to find this host on jump services below", "您可以尝试在下方的跳转服务上找到这个主机"},
+ {"Invalid request", "无效请求"},
+ {"Proxy unable to parse your request", "代理无法解析您的请求"},
+ {"addresshelper is not supported", "不支持地址助手"},
+ {"Host", "主机"},
+ {"added to router's addressbook from helper", "将此地址从地址助手添加到地址簿"},
+ {"Click here to proceed:", "点击此处继续:"},
+ {"Continue", "继续"},
+ {"Addresshelper found", "找到地址助手"},
+ {"already in router's addressbook", "已在路由器的地址簿中"},
+ {"Click here to update record:", "点击此处更新地址簿记录"},
+ {"invalid request uri", "无效的 URL 请求"},
+ {"Can't detect destination host from request", "无法从请求中检测到目标主机"},
+ {"Outproxy failure", "出口代理失效"},
+ {"bad outproxy settings", "错误的出口代理设置"},
+ {"not inside I2P network, but outproxy is not enabled", "该地址不在 I2P 网络内,但未启用出口代理"},
+ {"unknown outproxy url", "未知的出口代理地址"},
+ {"cannot resolve upstream proxy", "无法解析上游代理"},
+ {"hostname too long", "主机名过长"},
+ {"cannot connect to upstream socks proxy", "无法连接到上游 socks 代理"},
+ {"Cannot negotiate with socks proxy", "无法与 socks 代理协商"},
+ {"CONNECT error", "连接错误"},
+ {"Failed to Connect", "连接失败"},
+ {"socks proxy error", "socks 代理错误"},
+ {"failed to send request to upstream", "向上游发送请求失败"},
+ {"No Reply From socks proxy", "没有来自 socks 代理的回复"},
+ {"cannot connect", "无法连接"},
+ {"http out proxy not implemented", "http 出口代理未实现"},
+ {"cannot connect to upstream http proxy", "无法连接到上游 http 代理"},
+ {"Host is down", "主机已关闭"},
+ {"Can't create connection to requested host, it may be down. Please try again later.", "无法创建到目标主机的连接。主机可能已下线,请稍后再试。"},
+ {"", ""},
+ };
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/i18n/French.cpp
^
|
@@ -0,0 +1,211 @@
+/*
+* Copyright (c) 2022, The PurpleI2P Project
+*
+* This file is part of Purple i2pd project and licensed under BSD3
+*
+* See full license text in LICENSE file at top of project tree
+*/
+
+#include <map>
+#include <vector>
+#include <string>
+#include <memory>
+#include "I18N.h"
+
+// French localization file
+
+namespace i2p
+{
+namespace i18n
+{
+namespace french // language namespace
+{
+ // language name in lowercase
+ static std::string language = "french";
+
+ // See for language plural forms here:
+ // https://localization-guide.readthedocs.io/en/latest/l10n/pluralforms.html
+ static int plural (int n) {
+ return n != 1 ? 1 : 0;
+ }
+
+ static std::map<std::string, std::string> strings
+ {
+ {"KiB", "Kio"},
+ {"MiB", "Mio"},
+ {"GiB", "Gio"},
+ {"building", "En construction"},
+ {"failed", "échoué"},
+ {"expiring", "expiré"},
+ {"established", "établi"},
+ {"unknown", "inconnu"},
+ {"exploratory", "exploratoire"},
+ {"Purple I2P Webconsole", "Console web Purple I2P"},
+ {"<b>i2pd</b> webconsole", "Console web <b>i2pd</b>"},
+ {"Main page", "Page principale"},
+ {"Router commands", "Commandes du routeur"},
+ {"Local Destinations", "Destinations locales"},
+ {"LeaseSets", "Jeu de baux"},
+ {"Tunnels", "Tunnels"},
+ {"Transit Tunnels", "Tunnels transitoires"},
+ {"Transports", "Transports"},
+ {"I2P tunnels", "Tunnels I2P"},
+ {"SAM sessions", "Sessions SAM"},
+ {"ERROR", "ERREUR"},
+ {"OK", "OK"},
+ {"Testing", "Test en cours"},
+ {"Firewalled", "Derrière un pare-feu"},
+ {"Unknown", "Inconnu"},
+ {"Proxy", "Proxy"},
+ {"Mesh", "Maillé"},
+ {"Error", "Erreur"},
+ {"Clock skew", "Horloge décalée"},
+ {"Offline", "Hors ligne"},
+ {"Symmetric NAT", "NAT symétrique"},
+ {"Uptime", "Temps de fonctionnement"},
+ {"Network status", "État du réseau"},
+ {"Network status v6", "État du réseau v6"},
+ {"Stopping in", "Arrêt dans"},
+ {"Family", "Famille"},
+ {"Tunnel creation success rate", "Taux de succès de création de tunnels"},
+ {"Received", "Reçu"},
+ {"KiB/s", "kio/s"},
+ {"Sent", "Envoyé"},
+ {"Transit", "Transité"},
+ {"Data path", "Emplacement des données"},
+ {"Hidden content. Press on text to see.", "Contenu caché. Cliquez sur le texte pour afficher."},
+ {"Router Ident", "Identifiant du routeur"},
+ {"Router Family", "Famille du routeur"},
+ {"Router Caps", "Limiteurs du routeur"},
+ {"Version", "Version"},
+ {"Our external address", "Notre adresse externe"},
+ {"supported", "supporté"},
+ {"Routers", "Routeurs"},
+ {"Client Tunnels", "Tunnels clients"},
+ {"Services", "Services"},
+ {"Enabled", "Activé"},
+ {"Disabled", "Désactivé"},
+ {"Encrypted B33 address", "Adresse B33 chiffrée"},
+ {"Address registration line", "Ligne d'inscription de l'adresse"},
+ {"Domain", "Domaine"},
+ {"Generate", "Générer"},
+ {"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>Note:</b> La chaîne résultante peut seulement être utilisée pour enregistrer les domaines 2LD (exemple.i2p). Pour enregistrer des sous-domaines, veuillez utiliser i2pd-tools."},
+ {"Address", "Adresse"},
+ {"Type", "Type"},
+ {"Inbound tunnels", "Tunnels entrants"},
+ {"ms", "ms"},
+ {"Outbound tunnels", "Tunnels sortants"},
+ {"Tags", "Balises"},
+ {"Incoming", "Entrant"},
+ {"Outgoing", "Sortant"},
+ {"Destination", "Destination"},
+ {"Amount", "Quantité"},
+ {"Incoming Tags", "Balises entrantes"},
+ {"Tags sessions", "Sessions des balises"},
+ {"Status", "Statut"},
+ {"Local Destination", "Destination locale"},
+ {"Streams", "Flux"},
+ {"Close stream", "Fermer le flux"},
+ {"I2CP session not found", "Session I2CP introuvable"},
+ {"I2CP is not enabled", "I2CP est désactivé"},
+ {"Invalid", "Invalide"},
+ {"Store type", "Type de stockage"},
+ {"Expires", "Expire"},
+ {"Non Expired Leases", "Baux non expirés"},
+ {"Gateway", "Passerelle"},
+ {"TunnelID", "ID du tunnel"},
+ {"EndDate", "Date de fin"},
+ {"Queue size", "Longueur de la file"},
+ {"Run peer test", "Lancer test des pairs"},
+ {"Decline transit tunnels", "Refuser les tunnels transitoires"},
+ {"Accept transit tunnels", "Accepter les tunnels transitoires"},
+ {"Cancel graceful shutdown", "Annuler l'arrêt gracieux"},
+ {"Start graceful shutdown", "Démarrer l'arrêt gracieux"},
+ {"Force shutdown", "Forcer l'arrêt"},
+ {"Reload external CSS styles", "Rafraîchir les styles CSS externes"},
+ {"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b>Note:</b> Toute action effectuée ici n'est pas permanente et ne modifie pas vos fichiers de configuration."},
+ {"Logging level", "Niveau de journalisation"},
+ {"Transit tunnels limit", "Limite sur les tunnels transitoires"},
+ {"Change", "Changer"},
+ {"Change language", "Changer la langue"},
+ {"no transit tunnels currently built", "aucun tunnel transitoire présentement établi"},
+ {"SAM disabled", "SAM désactivé"},
+ {"no sessions currently running", "aucune session présentement en cours"},
+ {"SAM session not found", "session SAM introuvable"},
+ {"SAM Session", "Session SAM"},
+ {"Server Tunnels", "Tunnels serveurs"},
+ {"Unknown page", "Page inconnue"},
+ {"Invalid token", "Jeton invalide"},
+ {"SUCCESS", "SUCCÈS"},
+ {"Stream closed", "Flux fermé"},
+ {"Stream not found or already was closed", "Flux introuvable ou déjà fermé"},
+ {"Destination not found", "Destination introuvable"},
+ {"StreamID can't be null", "StreamID ne peut pas être vide"},
+ {"Return to destination page", "Retourner à la page de destination"},
+ {"You will be redirected in 5 seconds", "Vous allez être redirigé dans cinq secondes"},
+ {"Transit tunnels count must not exceed 65535", "Le nombre de tunnels transitoires ne doit pas dépasser 65535"},
+ {"Back to commands list", "Retour à la liste des commandes"},
+ {"Register at reg.i2p", "Inscription à reg.i2p"},
+ {"Description", "Description"},
+ {"A bit information about service on domain", "Un peu d'information à propos des services disponibles dans le domaine"},
+ {"Submit", "Soumettre"},
+ {"Domain can't end with .b32.i2p", "Le domaine ne peut pas terminer par .b32.i2p"},
+ {"Domain must end with .i2p", "Le domaine doit terminer par .i2p"},
+ {"Such destination is not found", "Cette destination est introuvable"},
+ {"Unknown command", "Commande inconnue"},
+ {"Command accepted", "Commande acceptée"},
+ {"Proxy error", "Erreur de proxy"},
+ {"Proxy info", "Information sur le proxy"},
+ {"Proxy error: Host not found", "Erreur de proxy: Hôte introuvable"},
+ {"Remote host not found in router's addressbook", "Hôte distant introuvable dans le carnet d'adresse du routeur"},
+ {"You may try to find this host on jump services below", "Vous pouvez essayer de trouver cet hôte sur des services de redirection ci-dessous"},
+ {"Invalid request", "Requête invalide"},
+ {"Proxy unable to parse your request", "Proxy incapable de comprendre votre requête"},
+ {"addresshelper is not supported", "Assistant d'adresse non supporté"},
+ {"Host", "Hôte"},
+ {"added to router's addressbook from helper", "Ajouté au carnet d'adresse du routeur par l'assistant"},
+ {"Click here to proceed:", "Cliquez ici pour continuer:"},
+ {"Continue", "Continuer"},
+ {"Addresshelper found", "Assistant d'adresse trouvé"},
+ {"already in router's addressbook", "déjà dans le carnet d'adresses du routeur"},
+ {"Click here to update record:", "Cliquez ici pour mettre à jour le carnet d'adresse:"},
+ {"invalid request uri", "uri de la requête invalide"},
+ {"Can't detect destination host from request", "Impossible de détecter l'hôte de destination à partir de la requête"},
+ {"Outproxy failure", "Échec de proxy de sortie"},
+ {"bad outproxy settings", "Mauvaise configuration du proxy de sortie"},
+ {"not inside I2P network, but outproxy is not enabled", "pas dans le réseau I2P, mais le proxy de sortie n'est pas activé"},
+ {"unknown outproxy url", "URL du proxy de sortie inconnu"},
+ {"cannot resolve upstream proxy", "impossible de résoudre l'adresse du proxy en amont"},
+ {"hostname too long", "nom d'hôte trop long"},
+ {"cannot connect to upstream socks proxy", "impossible de se connecter au proxy socks en amont"},
+ {"Cannot negotiate with socks proxy", "Impossible de négocier avec le proxy socks"},
+ {"CONNECT error", "Erreur de connexion"},
+ {"Failed to Connect", "Échec de connexion"},
+ {"socks proxy error", "Erreur de proxy socks"},
+ {"failed to send request to upstream", "Erreur lors de l'envoie de la requête en amont"},
+ {"No Reply From socks proxy", "Pas de réponse du proxy socks"},
+ {"cannot connect", "impossible de connecter"},
+ {"http out proxy not implemented", "Proxy de sortie HTTP non implémenté"},
+ {"cannot connect to upstream http proxy", "impossible de se connecter au proxy HTTP en amont"},
+ {"Host is down", "Hôte hors service"},
+ {"Can't create connection to requested host, it may be down. Please try again later.", "Impossible d'établir une connexion avec l'hôte, il est peut-être hors service. Veuillez réessayer plus tard."},
+ {"", ""},
+ };
+
+ static std::map<std::string, std::vector<std::string>> plurals
+ {
+ {"days", {"jour", "jours"}},
+ {"hours", {"heure", "heures"}},
+ {"minutes", {"minute", "minutes"}},
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/i18n/German.cpp
^
|
@@ -31,29 +31,30 @@
static std::map<std::string, std::string> strings
{
+ {"Purple I2P Webconsole", "Purple-I2P-Webkonsole"},
{"KiB", "KiB"},
{"MiB", "MiB"},
{"GiB", "GiB"},
{"building", "In Bau"},
{"failed", "fehlgeschlagen"},
- {"expiring", "läuft ab in"},
+ {"expiring", "läuft ab"},
{"established", "hergestellt"},
{"unknown", "Unbekannt"},
- {"exploratory", "erforschende"},
- {"<b>i2pd</b> webconsole", "<b>i2pd</b> Webkonsole"},
+ {"exploratory", "erforschend"},
+ {"<b>i2pd</b> webconsole", "<b>i2pd</b>-Webkonsole"},
{"Main page", "Startseite"},
- {"Router commands", "Router Befehle"},
- {"Local Destinations", "Lokale Destination"},
+ {"Router commands", "Routerbefehle"},
+ {"Local Destinations", "Lokale Ziele"},
{"LeaseSets", "LeaseSets"},
{"Tunnels", "Tunnel"},
{"Transit Tunnels", "Transittunnel"},
{"Transports", "Transporte"},
- {"I2P tunnels", "I2P Tunnel"},
- {"SAM sessions", "SAM Sitzungen"},
+ {"I2P tunnels", "I2P-Tunnel"},
+ {"SAM sessions", "SAM-Sitzungen"},
{"ERROR", "FEHLER"},
{"OK", "OK"},
{"Testing", "Testen"},
- {"Firewalled", "Hinter eine Firewall"},
+ {"Firewalled", "Hinter einer Firewall"},
{"Unknown", "Unbekannt"},
{"Proxy", "Proxy"},
{"Mesh", "Mesh"},
@@ -81,15 +82,15 @@
{"supported", "unterstützt"},
{"Routers", "Router"},
{"Floodfills", "Floodfills"},
- {"Client Tunnels", "Klienttunnel"},
+ {"Client Tunnels", "Clienttunnel"},
{"Services", "Services"},
{"Enabled", "Aktiviert"},
{"Disabled", "Deaktiviert"},
- {"Encrypted B33 address", "Verschlüsselte B33 Adresse"},
- {"Address registration line", "Adresseregistrierungszeile"},
+ {"Encrypted B33 address", "Verschlüsselte B33-Adresse"},
+ {"Address registration line", "Adressregistrierungszeile"},
{"Domain", "Domain"},
{"Generate", "Generieren"},
- {"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>Hinweis:</b> Der resultierende String kann nur für die Registrierung einer 2LD Domain (beispiel.i2p) benutzt werden. Für die Registrierung von Subdomains kann i2pd-tools verwendet werden."},
+ {"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>Hinweis:</b> Der resultierende String kann nur für die Registrierung einer 2LD-Domain (beispiel.i2p) benutzt werden. Für die Registrierung von Subdomains kann i2pd-tools verwendet werden."},
{"Address", "Adresse"},
{"Type", "Typ"},
{"EncType", "Verschlüsselungstyp"},
@@ -99,15 +100,15 @@
{"Tags", "Tags"},
{"Incoming", "Eingehend"},
{"Outgoing", "Ausgehend"},
- {"Destination", "Destination"},
+ {"Destination", "Ziel"},
{"Amount", "Anzahl"},
{"Incoming Tags", "Eingehende Tags"},
- {"Tags sessions", "Tags Sitzungen"},
+ {"Tags sessions", "Tags-Sitzungen"},
{"Status", "Status"},
- {"Local Destination", "Lokale Destination"},
+ {"Local Destination", "Lokales Ziel"},
{"Streams", "Streams"},
{"Close stream", "Stream schließen"},
- {"I2CP session not found", "I2CP Sitzung nicht gefunden"},
+ {"I2CP session not found", "I2CP-Sitzung nicht gefunden"},
{"I2CP is not enabled", "I2CP ist nicht aktiviert"},
{"Invalid", "Ungültig"},
{"Store type", "Speichertyp"},
@@ -117,67 +118,67 @@
{"TunnelID", "TunnelID"},
{"EndDate", "Enddatum"},
{"not floodfill", "kein Floodfill"},
- {"Queue size", "Warteschlangengröße"},
- {"Run peer test", "Peer-Test ausführen"},
+ {"Queue size", "Größe der Warteschlange"},
+ {"Run peer test", "Peer-Test durchführen"},
{"Decline transit tunnels", "Transittunnel ablehnen"},
{"Accept transit tunnels", "Transittunnel akzeptieren"},
- {"Cancel graceful shutdown", "Beende das kontrollierte herunterfahren"},
+ {"Cancel graceful shutdown", "Beende das kontrollierte Herunterfahren"},
{"Start graceful shutdown", "Starte das kontrollierte Herunterfahren"},
{"Force shutdown", "Herunterfahren erzwingen"},
- {"Reload external CSS styles", "Lade externe CSS-Styles neu"},
+ {"Reload external CSS styles", "Lade externe CSS-Stile neu"},
{"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b>Hinweis:</b> Alle hier durchgeführten Aktionen sind nicht dauerhaft und ändern die Konfigurationsdateien nicht."},
{"Logging level", "Protokollierungslevel"},
{"Transit tunnels limit", "Limit für Transittunnel"},
- {"Change", "Verändern"},
+ {"Change", "Ändern"},
{"Change language", "Sprache ändern"},
{"no transit tunnels currently built", "derzeit keine Transittunnel aufgebaut"},
{"SAM disabled", "SAM deaktiviert"},
{"no sessions currently running", "Derzeit keine laufenden Sitzungen"},
- {"SAM session not found", "SAM Sitzung nicht gefunden"},
- {"SAM Session", "SAM Sitzung"},
+ {"SAM session not found", "SAM-Sitzung nicht gefunden"},
+ {"SAM Session", "SAM-Sitzung"},
{"Server Tunnels", "Servertunnel"},
- {"Client Forwards", "Klient-Weiterleitungen"},
+ {"Client Forwards", "Client-Weiterleitungen"},
{"Server Forwards", "Server-Weiterleitungen"},
{"Unknown page", "Unbekannte Seite"},
{"Invalid token", "Ungültiger Token"},
{"SUCCESS", "ERFOLGREICH"},
{"Stream closed", "Stream geschlossen"},
{"Stream not found or already was closed", "Stream nicht gefunden oder bereits geschlossen"},
- {"Destination not found", "Destination nicht gefunden"},
+ {"Destination not found", "Ziel nicht gefunden"},
{"StreamID can't be null", "StreamID kann nicht null sein"},
- {"Return to destination page", "Zurück zur Destination-Seite"},
+ {"Return to destination page", "Zurück zur Ziel-Seite"},
{"You will be redirected in 5 seconds", "Du wirst in 5 Sekunden weitergeleitet"},
{"Transit tunnels count must not exceed 65535", "Es darf maximal 65535 Transittunnel geben"},
- {"Back to commands list", "Zurück zur Kommandoliste"},
+ {"Back to commands list", "Zurück zur Befehlsliste"},
{"Register at reg.i2p", "Auf reg.i2p registrieren"},
{"Description", "Beschreibung"},
- {"A bit information about service on domain", "Ein bisschen Informationen über den Service auf der Domain"},
- {"Submit", "Einreichen"},
- {"Domain can't end with .b32.i2p", "Domain kann nicht mit .b32.i2p enden"},
- {"Domain must end with .i2p", "Domain muss mit .i2p enden"},
- {"Such destination is not found", "Eine solche Destination konnte nicht gefunden werden"},
+ {"A bit information about service on domain", "Ein paar Informationen über den Service auf der Domain"},
+ {"Submit", "Absenden"},
+ {"Domain can't end with .b32.i2p", "Domain kann nicht auf .b32.i2p enden"},
+ {"Domain must end with .i2p", "Domain muss auf .i2p enden"},
+ {"Such destination is not found", "Ein solches Ziel konnte nicht gefunden werden"},
{"Unknown command", "Unbekannter Befehl"},
{"Command accepted", "Befehl akzeptiert"},
{"Proxy error", "Proxy-Fehler"},
{"Proxy info", "Proxy-Info"},
{"Proxy error: Host not found", "Proxy-Fehler: Host nicht gefunden"},
- {"Remote host not found in router's addressbook", "Remote-Host nicht im Router Adressbuch gefunden"},
- {"You may try to find this host on jump services below", "Vielleicht kannst du diesen Host auf einen der Jump-Services unten finden"},
+ {"Remote host not found in router's addressbook", "Remote-Host nicht im Router-Adressbuch gefunden"},
+ {"You may try to find this host on jump services below", "Vielleicht kannst du diesen Host auf einem der nachfolgenden Jump-Services finden"},
{"Invalid request", "Ungültige Anfrage"},
- {"Proxy unable to parse your request", "Proxy konnte die Anfrage nicht interpretieren"},
- {"addresshelper is not supported", "addresshelper wird nicht unterstützt"},
+ {"Proxy unable to parse your request", "Proxy konnte die Anfrage nicht verarbeiten"},
+ {"addresshelper is not supported", "Addresshelfer wird nicht unterstützt"},
{"Host", "Host"},
- {"added to router's addressbook from helper", "vom Helfer zum Router Adressbuch hinzugefügt"},
+ {"added to router's addressbook from helper", "vom Helfer zum Router-Adressbuch hinzugefügt"},
{"Click here to proceed:", "Klicke hier um fortzufahren:"},
{"Continue", "Fortsetzen"},
{"Addresshelper found", "Adresshelfer gefunden"},
{"already in router's addressbook", "bereits im Adressbuch des Routers"},
{"Click here to update record:", "Klicke hier, um den Eintrag zu aktualisieren:"},
{"invalid request uri", "ungültige Anfrage-URI"},
- {"Can't detect destination host from request", "Kann Anhand der Anfrage den Destination-Host nicht erkennen"},
+ {"Can't detect destination host from request", "Kann den Ziel-Host von der Anfrage nicht erkennen"},
{"Outproxy failure", "Outproxy-Fehler"},
{"bad outproxy settings", "ungültige Outproxy-Einstellungen"},
- {"not inside I2P network, but outproxy is not enabled", "nicht innerhalb des I2P-Netzwerks, aber Outproxy ist nicht aktiviert"},
+ {"not inside I2P network, but outproxy is not enabled", "außerhalb des I2P-Netzwerks, aber Outproxy ist nicht aktiviert"},
{"unknown outproxy url", "unbekannte Outproxy-URL"},
{"cannot resolve upstream proxy", "kann den Upstream-Proxy nicht auflösen"},
{"hostname too long", "Hostname zu lang"},
@@ -192,7 +193,7 @@
{"http out proxy not implemented", "HTTP-Outproxy nicht implementiert"},
{"cannot connect to upstream http proxy", "Kann nicht zu Upstream-HTTP-Proxy verbinden"},
{"Host is down", "Host ist offline"},
- {"Can't create connection to requested host, it may be down. Please try again later.", "Konnte keine Verbindung zum angefragten Host aufbaunen, vielleicht ist es offline. Versuche es später noch einmal."},
+ {"Can't create connection to requested host, it may be down. Please try again later.", "Konnte keine Verbindung zum angefragten Host aufbauen, vielleicht ist er offline. Versuche es später noch mal."},
{"", ""},
};
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/i18n/I18N_langs.h
^
|
@@ -73,7 +73,9 @@
// Add localization here with language name as namespace
namespace afrikaans { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace armenian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
+ namespace chinese { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace english { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
+ namespace french { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace german { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace russian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace turkmen { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
@@ -87,7 +89,9 @@
{
{ "afrikaans", {"Afrikaans", "af", i2p::i18n::afrikaans::GetLocale} },
{ "armenian", {"հայերէն", "hy", i2p::i18n::armenian::GetLocale} },
+ { "chinese", {"简体字", "zh-CN", i2p::i18n::chinese::GetLocale} },
{ "english", {"English", "en", i2p::i18n::english::GetLocale} },
+ { "french", {"Français", "fr", i2p::i18n::french::GetLocale} },
{ "german", {"Deutsch", "de", i2p::i18n::german::GetLocale} },
{ "russian", {"русский язык", "ru", i2p::i18n::russian::GetLocale} },
{ "turkmen", {"türkmen dili", "tk", i2p::i18n::turkmen::GetLocale} },
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Base.h
^
|
@@ -24,8 +24,8 @@
size_t ByteStreamToBase32 (const uint8_t * InBuf, size_t len, char * outBuf, size_t outLen);
/**
- Compute the size for a buffer to contain encoded base64 given that the size of the input is input_size bytes
- */
+ * Compute the size for a buffer to contain encoded base64 given that the size of the input is input_size bytes
+ */
size_t Base64EncodingBufferSize(const size_t input_size);
std::string ToBase64Standard (const std::string& in); // using standard table, for Proxy-Authorization
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Blinding.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -99,7 +99,7 @@
static size_t BlindECDSA (i2p::data::SigningKeyType sigType, const uint8_t * key, const uint8_t * seed, Fn blind, Args&&...args)
// blind is BlindEncodedPublicKeyECDSA or BlindEncodedPrivateKeyECDSA
{
- size_t publicKeyLength = 0;
+ size_t publicKeyLength = 0;
EC_GROUP * group = nullptr;
switch (sigType)
{
@@ -146,7 +146,10 @@
m_PublicKey.resize (len);
memcpy (m_PublicKey.data (), identity->GetSigningPublicKeyBuffer (), len);
m_SigType = identity->GetSigningKeyType ();
- m_BlindedSigType = m_SigType;
+ if (m_SigType == i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519)
+ m_BlindedSigType = i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519; // 7 -> 11
+ else
+ m_BlindedSigType = m_SigType;
}
BlindedPublicKey::BlindedPublicKey (const std::string& b33):
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Blinding.h
^
|
@@ -28,8 +28,8 @@
const uint8_t * GetPublicKey () const { return m_PublicKey.data (); };
size_t GetPublicKeyLen () const { return m_PublicKey.size (); };
- SigningKeyType GetSigType () const { return m_SigType; };
- SigningKeyType GetBlindedSigType () const { return m_BlindedSigType; };
+ SigningKeyType GetSigType () const { return m_SigType; };
+ SigningKeyType GetBlindedSigType () const { return m_BlindedSigType; };
bool IsValid () const { return GetSigType (); }; // signature type 0 means invalid
void GetSubcredential (const uint8_t * blinded, size_t len, uint8_t * subcredential) const; // 32 bytes
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Config.cpp
^
|
@@ -78,9 +78,9 @@
("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)")
("limits.openfiles", value<uint16_t>()->default_value(0), "Maximum number of open files (0 - use system default)")
("limits.transittunnels", value<uint16_t>()->default_value(2500), "Maximum active transit sessions (default:2500)")
- ("limits.ntcpsoft", value<uint16_t>()->default_value(0), "Threshold to start probabilistic backoff with ntcp sessions (default: use system limit)")
- ("limits.ntcphard", value<uint16_t>()->default_value(0), "Maximum number of ntcp sessions (default: use system limit)")
- ("limits.ntcpthreads", value<uint16_t>()->default_value(1), "Maximum number of threads used by NTCP DH worker (default: 1)")
+ ("limits.ntcpsoft", value<uint16_t>()->default_value(0), "Ignored")
+ ("limits.ntcphard", value<uint16_t>()->default_value(0), "Ignored")
+ ("limits.ntcpthreads", value<uint16_t>()->default_value(1), "Ignored")
;
options_description httpserver("HTTP Server options");
@@ -109,6 +109,8 @@
("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.outbound.quantity", value<std::string>()->default_value("5"), "HTTP proxy outbound tunnels quantity")
+ ("httpproxy.inbound.lengthVariance", value<std::string>()->default_value("0"), "HTTP proxy inbound tunnels length variance")
+ ("httpproxy.outbound.lengthVariance", value<std::string>()->default_value("0"), "HTTP proxy outbound tunnels length variance")
("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.outproxy", value<std::string>()->default_value(""), "HTTP proxy upstream out proxy url")
@@ -130,6 +132,8 @@
("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.outbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy outbound tunnels quantity")
+ ("socksproxy.inbound.lengthVariance", value<std::string>()->default_value("0"), "SOCKS proxy inbound tunnels length variance")
+ ("socksproxy.outbound.lengthVariance", value<std::string>()->default_value("0"), "SOCKS proxy outbound tunnels length variance")
("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.outproxy.enabled", value<bool>()->default_value(false), "Enable or disable SOCKS outproxy")
@@ -211,18 +215,22 @@
"https://i2pseed.creativecowpat.net:8443/,"
"https://reseed.i2pgit.org/,"
"https://i2p.novg.net/,"
- "https://banana.incognet.io/"
+ "https://banana.incognet.io/,"
+ "https://reseed-pl.i2pd.xyz/,"
+ "https://www2.mk16.de/"
), "Reseed URLs, separated by comma")
("reseed.yggurls", value<std::string>()->default_value(
"http://[324:71e:281a:9ed3::ace]:7070/,"
"http://[301:65b9:c7cd:9a36::1]:18801/,"
"http://[320:8936:ec1a:31f1::216]/,"
- "http://[306:3834:97b9:a00a::1]/"
+ "http://[306:3834:97b9:a00a::1]/,"
+ "http://[316:f9e0:f22e:a74f::216]/"
), "Reseed URLs through the Yggdrasil, separated by comma")
;
options_description addressbook("AddressBook options");
addressbook.add_options()
+ ("addressbook.enabled", value<bool>()->default_value(true), "Enable address book lookups and subscritions (default: enabled)")
("addressbook.defaulturl", value<std::string>()->default_value(
"http://shx5vqsw7usdaunyzr2qmes2fq37oumybpudrd4jjj4e4vk4uusa.b32.i2p/hosts.txt"
), "AddressBook subscription URL for initial setup")
@@ -264,6 +272,13 @@
("ntcp2.proxy", value<std::string>()->default_value(""), "Proxy URL for NTCP2 transport")
;
+ options_description ssu2("SSU2 Options");
+ ssu2.add_options()
+ ("ssu2.enabled", value<bool>()->default_value(false), "Enable SSU2 (default: disabled)")
+ ("ssu2.published", value<bool>()->default_value(false), "Publish SSU2 (default: disabled)")
+ ("ssu2.port", value<uint16_t>()->default_value(0), "Port to listen for incoming SSU2 packets (default: auto)")
+ ;
+
options_description nettime("Time sync options");
nettime.add_options()
("nettime.enabled", value<bool>()->default_value(false), "Disable time sync (default: disabled)")
@@ -296,6 +311,13 @@
("meshnets.yggaddress", value<std::string>()->default_value(""), "Yggdrasil address to publish")
;
+#ifdef __linux__
+ options_description unix_specific("UNIX-specific options");
+ unix_specific.add_options()
+ ("unix.handle_sigtstp", bool_switch()->default_value(false), "Handle SIGTSTP and SIGCONT signals (default: disabled)")
+ ;
+#endif
+
m_OptionsDesc
.add(general)
.add(limits)
@@ -314,10 +336,14 @@
.add(websocket) // deprecated
.add(exploratory)
.add(ntcp2)
+ .add(ssu2)
.add(nettime)
.add(persist)
.add(cpuext)
.add(meshnets)
+#ifdef __linux__
+ .add(unix_specific)
+#endif
;
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Config.h
^
|
@@ -29,16 +29,16 @@
extern boost::program_options::variables_map m_Options;
/**
- * @brief Initialize list of acceptable parameters
+ * @brief Initialize list of acceptable parameters
*
* Should be called before any Parse* functions.
*/
void Init();
/**
- * @brief Parse cmdline parameters, and show help if requested
- * @param argc Cmdline arguments count, should be passed from main().
- * @param argv Cmdline parameters array, should be passed from main()
+ * @brief Parse cmdline parameters, and show help if requested
+ * @param argc Cmdline arguments count, should be passed from main().
+ * @param argv Cmdline parameters array, should be passed from main()
*
* If --help is given in parameters, shows its list with description
* and terminates the program with exitcode 0.
@@ -52,8 +52,8 @@
void ParseCmdline(int argc, char* argv[], bool ignoreUnknown = false);
/**
- * @brief Load and parse given config file
- * @param path Path to config file
+ * @brief Load and parse given config file
+ * @param path Path to config file
*
* If error occurred when opening file path is points to,
* we show the error message and terminate program.
@@ -67,14 +67,14 @@
void ParseConfig(const std::string& path);
/**
- * @brief Used to combine options from cmdline, config and default values
+ * @brief Used to combine options from cmdline, config and default values
*/
void Finalize();
/**
- * @brief Accessor to parameters by name
- * @param name Name of the requested parameter
- * @param value Variable where to store option
+ * @brief Accessor to parameters by name
+ * @param name Name of the requested parameter
+ * @param value Variable where to store option
* @return this function returns false if parameter not found
*
* Example: uint16_t port; GetOption("sam.port", port);
@@ -98,9 +98,9 @@
bool GetOptionAsAny(const std::string& name, boost::any& value);
/**
- * @brief Set value of given parameter
- * @param name Name of settable parameter
- * @param value New parameter value
+ * @brief Set value of given parameter
+ * @param name Name of settable parameter
+ * @param value New parameter value
* @return true if value set up successful, false otherwise
*
* Example: uint16_t port = 2827; SetOption("bob.port", port);
@@ -116,8 +116,8 @@
}
/**
- * @brief Check is value explicitly given or default
- * @param name Name of checked parameter
+ * @brief Check is value explicitly given or default
+ * @param name Name of checked parameter
* @return true if value set to default, false otherwise
*/
bool IsDefault(const char *name);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Crypto.cpp
^
|
@@ -1305,6 +1305,16 @@
SHA256_Final (m_H, &ctx);
}
+ void NoiseSymmetricState::MixHash (const std::vector<std::pair<uint8_t *, size_t> >& bufs)
+ {
+ SHA256_CTX ctx;
+ SHA256_Init (&ctx);
+ SHA256_Update (&ctx, m_H, 32);
+ for (const auto& it: bufs)
+ SHA256_Update (&ctx, it.first, it.second);
+ SHA256_Final (m_H, &ctx);
+ }
+
void NoiseSymmetricState::MixKey (const uint8_t * sharedSecret)
{
HKDF (m_CK, sharedSecret, 32, "", m_CK);
@@ -1320,7 +1330,7 @@
SHA256_Init (&ctx);
SHA256_Update (&ctx, hh, 32);
SHA256_Update (&ctx, pub, 32);
- SHA256_Final (state.m_H, &ctx); // h = MixHash(pub) = SHA256(hh || pub)
+ SHA256_Final (state.m_H, &ctx); // h = MixHash(pub) = SHA256(hh || pub)
}
void InitNoiseNState (NoiseSymmetricState& state, const uint8_t * pub)
@@ -1358,12 +1368,12 @@
}; // SHA256 ("Noise_XKchaobfse+hs1+hs2+hs3_25519_ChaChaPoly_SHA256")
static const uint8_t hh[32] =
{
- 0xdc, 0x85, 0xe6, 0xaf, 0x7b, 0x02, 0x65, 0x0c, 0xf1, 0xf9, 0x0d, 0x71, 0xfb, 0xc6, 0xd4, 0x53,
+ 0xdc, 0x85, 0xe6, 0xaf, 0x7b, 0x02, 0x65, 0x0c, 0xf1, 0xf9, 0x0d, 0x71, 0xfb, 0xc6, 0xd4, 0x53,
0xa7, 0xcf, 0x6d, 0xbf, 0xbd, 0x52, 0x5e, 0xa5, 0xb5, 0x79, 0x1c, 0x47, 0xb3, 0x5e, 0xbc, 0x33
}; // SHA256 (protocolNameHash)
InitNoiseState (state, protocolNameHash, hh, pub);
}
-
+
void InitNoiseIKState (NoiseSymmetricState& state, const uint8_t * pub)
{
static const uint8_t protocolNameHash[32] =
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Crypto.h
^
|
@@ -29,23 +29,25 @@
#include "CPU.h"
// recognize openssl version and features
-#if ((OPENSSL_VERSION_NUMBER < 0x010100000) || defined(LIBRESSL_VERSION_NUMBER)) // 1.0.2 and below or LibreSSL
-# define LEGACY_OPENSSL 1
-# define X509_getm_notBefore X509_get_notBefore
-# define X509_getm_notAfter X509_get_notAfter
+#if (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER >= 0x3050200fL)) // LibreSSL 3.5.2 and above
+# define LEGACY_OPENSSL 0
+#elif ((OPENSSL_VERSION_NUMBER < 0x010100000) || defined(LIBRESSL_VERSION_NUMBER)) // 1.0.2 and below or LibreSSL
+# define LEGACY_OPENSSL 1
+# define X509_getm_notBefore X509_get_notBefore
+# define X509_getm_notAfter X509_get_notAfter
#else
-# define LEGACY_OPENSSL 0
-# if (OPENSSL_VERSION_NUMBER >= 0x010101000) // 1.1.1
-# define OPENSSL_HKDF 1
-# define OPENSSL_EDDSA 1
-# define OPENSSL_X25519 1
-# if (OPENSSL_VERSION_NUMBER < 0x030000000) // 3.0.0, regression in SipHash
-# define OPENSSL_SIPHASH 1
+# define LEGACY_OPENSSL 0
+# if (OPENSSL_VERSION_NUMBER >= 0x010101000) // 1.1.1
+# define OPENSSL_HKDF 1
+# define OPENSSL_EDDSA 1
+# define OPENSSL_X25519 1
+# if (OPENSSL_VERSION_NUMBER != 0x030000000) // 3.0.0, regression in SipHash
+# define OPENSSL_SIPHASH 1
# endif
-# endif
-# if !defined OPENSSL_NO_CHACHA && !defined OPENSSL_NO_POLY1305 // some builds might not include them
-# define OPENSSL_AEAD_CHACHA20_POLY1305 1
-# endif
+# endif
+# if !defined OPENSSL_NO_CHACHA && !defined OPENSSL_NO_POLY1305 // some builds might not include them
+# define OPENSSL_AEAD_CHACHA20_POLY1305 1
+# endif
#endif
namespace i2p
@@ -317,6 +319,7 @@
uint8_t m_H[32] /*h*/, m_CK[64] /*[ck, k]*/;
void MixHash (const uint8_t * buf, size_t len);
+ void MixHash (const std::vector<std::pair<uint8_t *, size_t> >& bufs);
void MixKey (const uint8_t * sharedSecret);
};
@@ -382,7 +385,7 @@
if (dh->p) BN_free (dh->p);
if (dh->q) BN_free (dh->q);
if (dh->g) BN_free (dh->g);
- dh->p = p; dh->q = q; dh->g = g; return 1;
+ dh->p = p; dh->q = q; dh->g = g; return 1;
}
inline int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Datagram.cpp
^
|
@@ -324,7 +324,7 @@
auto path = m_RoutingSession->GetSharedRoutingPath();
if (path && m_RoutingSession->IsRatchets () &&
- m_LastUse > m_RoutingSession->GetLastActivityTimestamp ()*1000 + DATAGRAM_SESSION_PATH_TIMEOUT)
+ m_LastUse > m_RoutingSession->GetLastActivityTimestamp ()*1000 + DATAGRAM_SESSION_PATH_TIMEOUT)
{
m_RoutingSession->SetSharedRoutingPath (nullptr);
path = nullptr;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Destination.cpp
^
|
@@ -13,7 +13,6 @@
#include <vector>
#include <boost/algorithm/string.hpp>
#include "Crypto.h"
-#include "Config.h"
#include "Log.h"
#include "FS.h"
#include "Timestamp.h"
@@ -35,6 +34,8 @@
int inQty = DEFAULT_INBOUND_TUNNELS_QUANTITY;
int outLen = DEFAULT_OUTBOUND_TUNNEL_LENGTH;
int outQty = DEFAULT_OUTBOUND_TUNNELS_QUANTITY;
+ int inVar = DEFAULT_INBOUND_TUNNELS_LENGTH_VARIANCE;
+ int outVar = DEFAULT_OUTBOUND_TUNNELS_LENGTH_VARIANCE;
int numTags = DEFAULT_TAGS_TO_SEND;
std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers;
try
@@ -53,6 +54,12 @@
it = params->find (I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY);
if (it != params->end ())
outQty = std::stoi(it->second);
+ it = params->find (I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE);
+ if (it != params->end ())
+ inVar = std::stoi(it->second);
+ it = params->find (I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE);
+ if (it != params->end ())
+ outVar = std::stoi(it->second);
it = params->find (I2CP_PARAM_TAGS_TO_SEND);
if (it != params->end ())
numTags = std::stoi(it->second);
@@ -86,9 +93,7 @@
if (it != params->end ())
{
// oveeride isPublic
- bool dontpublish = false;
- i2p::config::GetOption (it->second, dontpublish);
- m_IsPublic = !dontpublish;
+ m_IsPublic = (it->second != "true");
}
it = params->find (I2CP_PARAM_LEASESET_TYPE);
if (it != params->end ())
@@ -123,7 +128,7 @@
LogPrint(eLogError, "Destination: Unable to parse parameters for destination: ", ex.what());
}
SetNumTags (numTags);
- m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inLen, outLen, inQty, outQty);
+ m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inLen, outLen, inQty, outQty, inVar, outVar);
if (explicitPeers)
m_Pool->SetExplicitPeers (explicitPeers);
if(params)
@@ -331,6 +336,22 @@
return true;
}
+ void LeaseSetDestination::SubmitECIESx25519Key (const uint8_t * key, uint64_t tag)
+ {
+ struct
+ {
+ uint8_t k[32];
+ uint64_t t;
+ } data;
+ memcpy (data.k, key, 32);
+ data.t = tag;
+ auto s = shared_from_this ();
+ m_Service.post ([s,data](void)
+ {
+ s->AddECIESx25519Key (data.k, data.t);
+ });
+ }
+
void LeaseSetDestination::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg)
{
m_Service.post (std::bind (&LeaseSetDestination::HandleGarlicMessage, shared_from_this (), msg));
@@ -396,7 +417,7 @@
std::lock_guard<std::mutex> lock(m_RemoteLeaseSetsMutex);
auto it = m_RemoteLeaseSets.find (key);
if (it != m_RemoteLeaseSets.end () &&
- it->second->GetStoreType () == buf[DATABASE_STORE_TYPE_OFFSET]) // update only if same type
+ it->second->GetStoreType () == buf[DATABASE_STORE_TYPE_OFFSET]) // update only if same type
{
leaseSet = it->second;
if (leaseSet->IsNewer (buf + offset, len - offset))
@@ -566,7 +587,7 @@
LogPrint (eLogError, "Destination: Can't publish LeaseSet, no more floodfills found");
m_ExcludedFloodfills.clear ();
return;
- }
+ }
auto outbound = m_Pool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false));
auto inbound = m_Pool->GetNextInboundTunnel (nullptr, floodfill->GetCompatibleTransports (true));
if (!outbound || !inbound)
@@ -578,22 +599,22 @@
{
outbound = m_Pool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false));
if (outbound)
- {
+ {
inbound = m_Pool->GetNextInboundTunnel (nullptr, floodfill->GetCompatibleTransports (true));
if (!inbound)
LogPrint (eLogError, "Destination: Can't publish LeaseSet. No inbound tunnels");
- }
+ }
else
LogPrint (eLogError, "Destination: Can't publish LeaseSet. No outbound tunnels");
- }
+ }
else
LogPrint (eLogError, "Destination: Can't publish LeaseSet, no more floodfills found");
if (!floodfill || !outbound || !inbound)
{
m_ExcludedFloodfills.clear ();
return;
- }
- }
+ }
+ }
m_ExcludedFloodfills.insert (floodfill->GetIdentHash ());
LogPrint (eLogDebug, "Destination: Publish LeaseSet of ", GetIdentHash ().ToBase32 ());
RAND_bytes ((uint8_t *)&m_PublishReplyToken, 4);
@@ -930,7 +951,7 @@
for (auto& it: encryptionKeyTypes)
{
auto encryptionKey = new EncryptionKey (it);
- if (isPublic)
+ if (IsPublic ())
PersistTemporaryKeys (encryptionKey, isSingleKey);
else
encryptionKey->GenerateKeys ();
@@ -945,7 +966,7 @@
m_StandardEncryptionKey.reset (encryptionKey);
}
- if (isPublic)
+ if (IsPublic ())
LogPrint (eLogInfo, "Destination: Local address ", GetIdentHash().ToBase32 (), " created");
try
@@ -958,7 +979,7 @@
m_StreamingAckDelay = std::stoi(it->second);
it = params->find (I2CP_PARAM_STREAMING_ANSWER_PINGS);
if (it != params->end ())
- i2p::config::GetOption (it->second, m_IsStreamingAnswerPings);
+ m_IsStreamingAnswerPings = (it->second == "true");
if (GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2)
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Destination.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -53,6 +53,10 @@
const int DEFAULT_INBOUND_TUNNELS_QUANTITY = 5;
const char I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY[] = "outbound.quantity";
const int DEFAULT_OUTBOUND_TUNNELS_QUANTITY = 5;
+ const char I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE[] = "inbound.lengthVariance";
+ const int DEFAULT_INBOUND_TUNNELS_LENGTH_VARIANCE = 0;
+ const char I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE[] = "outbound.lengthVariance";
+ const int DEFAULT_OUTBOUND_TUNNELS_LENGTH_VARIANCE = 0;
const char I2CP_PARAM_EXPLICIT_PEERS[] = "explicitPeers";
const int STREAM_REQUEST_TIMEOUT = 60; //in seconds
const char I2CP_PARAM_TAGS_TO_SEND[] = "crypto.tagsToSend";
@@ -134,6 +138,7 @@
// override GarlicDestination
bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag);
+ void SubmitECIESx25519Key (const uint8_t * key, uint64_t tag);
void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
void ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
void SetLeaseSetUpdated ();
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/ECIESX25519AEADRatchetSession.h
^
|
@@ -212,7 +212,7 @@
uint8_t m_NSREncodedKey[32], m_NSRH[32], m_NSRKey[32]; // new session reply, for incoming only
std::shared_ptr<i2p::crypto::X25519Keys> m_EphemeralKeys;
SessionState m_State = eSessionStateNew;
- uint64_t m_SessionCreatedTimestamp = 0, m_LastActivityTimestamp = 0, // incoming (in seconds)
+ uint64_t m_SessionCreatedTimestamp = 0, m_LastActivityTimestamp = 0, // incoming (in seconds)
m_LastSentTimestamp = 0; // in milliseconds
std::shared_ptr<RatchetTagSet> m_SendTagset, m_NSRSendTagset;
std::unique_ptr<i2p::data::IdentHash> m_Destination;// TODO: might not need it
@@ -229,7 +229,7 @@
{
return m_Destination ? *m_Destination : i2p::data::IdentHash ();
}
- };
+ };
// single session for all incoming messages
class RouterIncomingRatchetSession: public ECIESX25519AEADRatchetSession
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Ed25519.cpp
^
|
@@ -33,7 +33,7 @@
BN_add (l, l, tmp);
BN_sub_word (two_252_2, 2); // 2^252 - 2
- // -121665*inv(121666)
+ // -121665*inv(121666)
d = BN_new ();
BN_set_word (tmp, 121666);
BN_mod_inverse (tmp, tmp, q, ctx);
@@ -61,7 +61,7 @@
BN_mod (By, By, q, ctx); // % q
// precalculate Bi256 table
- Bi256Carry = { Bx, By }; // B
+ Bi256Carry = { Bx, By }; // B
for (int i = 0; i < 32; i++)
{
Bi256[i][0] = Bi256Carry; // first point
@@ -215,7 +215,7 @@
if (!t1) { t1 = BN_CTX_get (ctx); BN_mul (t1, p1.x, p1.y, ctx); }
if (!t2) { t2 = BN_CTX_get (ctx); BN_mul (t2, p2.x, p2.y, ctx); }
BN_mul (t3, t1, t2, ctx);
- BN_mul (t3, t3, d, ctx); // C = d*t1*t2
+ BN_mul (t3, t3, d, ctx); // C = d*t1*t2
if (p1.z)
{
@@ -264,9 +264,9 @@
else
{
BN_mul (t2, p.x, p.y, ctx); // t = x*y
- BN_sqr (t2, t2, ctx); // t2 = t^2
+ BN_sqr (t2, t2, ctx); // t2 = t^2
}
- BN_mul (t2, t2, d, ctx); // t2 = C = d*t^2
+ BN_mul (t2, t2, d, ctx); // t2 = C = d*t^2
if (p.z)
BN_sqr (z2, p.z, ctx); // z2 = D = z^2
else
@@ -349,7 +349,7 @@
BN_mod_inverse (y, p.z, q, ctx);
BN_mod_mul (x, p.x, y, q, ctx); // x = x/z
BN_mod_mul (y, p.y, y, q, ctx); // y = y/z
- return EDDSAPoint{x, y};
+ return EDDSAPoint{x, y};
}
else
return EDDSAPoint{BN_dup (p.x), BN_dup (p.y)};
@@ -506,13 +506,13 @@
std::swap (z2, z3);
}
BN_mod_inverse (z2, z2, q, ctx);
- BIGNUM * res = BN_new (); // not from ctx
+ BIGNUM * res = BN_new (); // not from ctx
BN_mod_mul(res, x2, z2, q, ctx);
BN_CTX_end (ctx);
return res;
}
- void Ed25519::ScalarMul (const uint8_t * p, const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const
+ void Ed25519::ScalarMul (const uint8_t * p, const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const
{
BIGNUM * p1 = DecodeBN<32> (p);
uint8_t k[32];
@@ -524,7 +524,7 @@
BN_free (p1); BN_free (n); BN_free (q1);
}
- void Ed25519::ScalarMulB (const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const
+ void Ed25519::ScalarMulB (const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const
{
BIGNUM *p1 = BN_new (); BN_set_word (p1, 9);
uint8_t k[32];
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Ed25519.h
^
|
@@ -85,8 +85,8 @@
EDDSAPoint DecodePublicKey (const uint8_t * buf, BN_CTX * ctx) const;
void EncodePublicKey (const EDDSAPoint& publicKey, uint8_t * buf, BN_CTX * ctx) const;
#if !OPENSSL_X25519
- void ScalarMul (const uint8_t * p, const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const; // p is point, e is number for x25519
- void ScalarMulB (const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const;
+ void ScalarMul (const uint8_t * p, const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const; // p is point, e is number for x25519
+ void ScalarMulB (const uint8_t * e, uint8_t * buf, BN_CTX * ctx) const;
#endif
void BlindPublicKey (const uint8_t * pub, const uint8_t * seed, uint8_t * blinded); // for encrypted LeaseSet2, pub - 32, seed - 64, blinded - 32
void BlindPrivateKey (const uint8_t * priv, const uint8_t * seed, uint8_t * blindedPriv, uint8_t * blindedPub); // for encrypted LeaseSet2, pub - 32, seed - 64, blinded - 32
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Elligator.cpp
^
|
@@ -189,7 +189,7 @@
// assume a < p, so don't check for a % p = 0, but a = 0 only
if (BN_is_zero(a)) return 0;
BIGNUM * r = BN_CTX_get (ctx);
- BN_mod_exp (r, a, p12, p, ctx); // r = a^((p-1)/2) mod p
+ BN_mod_exp (r, a, p12, p, ctx); // r = a^((p-1)/2) mod p
if (BN_is_word(r, 1))
return 1;
else if (BN_is_zero(r))
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/FS.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -60,10 +60,38 @@
}
void DetectDataDir(const std::string & cmdline_param, bool isService) {
+ // with 'datadir' option
if (cmdline_param != "") {
dataDir = cmdline_param;
return;
}
+
+#if !defined(MAC_OSX) && !defined(ANDROID)
+ // with 'service' option
+ if (isService) {
+#ifdef _WIN32
+ wchar_t commonAppData[MAX_PATH];
+ if(SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, 0, commonAppData) != S_OK)
+ {
+#ifdef WIN32_APP
+ MessageBox(NULL, TEXT("Unable to get common AppData path!"), TEXT("I2Pd: error"), MB_ICONERROR | MB_OK);
+#else
+ fprintf(stderr, "Error: Unable to get common AppData path!");
+#endif
+ exit(1);
+ }
+ else
+ {
+ dataDir = boost::filesystem::wpath(commonAppData).string() + "\\" + appName;
+ }
+#else
+ dataDir = "/var/lib/" + appName;
+#endif
+ return;
+ }
+#endif
+
+ // detect directory as usual
#ifdef _WIN32
wchar_t localAppData[MAX_PATH];
@@ -117,12 +145,10 @@
dataDir = std::string (ext) + "/" + appName;
return;
}
-#endif
- // otherwise use /data/files
+#endif // ANDROID
+ // use /home/user/.i2pd or /tmp/i2pd
char *home = getenv("HOME");
- if (isService) {
- dataDir = "/var/lib/" + appName;
- } else if (home != NULL && strlen(home) > 0) {
+ if (home != NULL && strlen(home) > 0) {
dataDir = std::string(home) + "/." + appName;
} else {
dataDir = "/tmp/" + appName;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/FS.h
^
|
@@ -83,8 +83,8 @@
/**
* @brief Set datadir either from cmdline option or using autodetection
- * @param cmdline_param Value of cmdline parameter --datadir=<something>
- * @param isService Value of cmdline parameter --service
+ * @param cmdline_param Value of cmdline parameter --datadir=<something>
+ * @param isService Value of cmdline parameter --service
*
* Examples of autodetected paths:
*
@@ -93,11 +93,11 @@
* Mac: /Library/Application Support/i2pd/ or ~/Library/Application Support/i2pd/
* Unix: /var/lib/i2pd/ (system=1) >> ~/.i2pd/ or /tmp/i2pd/
*/
- void DetectDataDir(const std::string & cmdline_datadir, bool isService = false);
+ void DetectDataDir(const std::string & cmdline_datadir, bool isService = false);
/**
* @brief Set certsdir either from cmdline option or using autodetection
- * @param cmdline_param Value of cmdline parameter --certsdir=<something>
+ * @param cmdline_param Value of cmdline parameter --certsdir=<something>
*
* Examples of autodetected paths:
*
@@ -106,7 +106,7 @@
* Mac: /Library/Application Support/i2pd/ or ~/Library/Application Support/i2pd/certificates
* Unix: /var/lib/i2pd/certificates (system=1) >> ~/.i2pd/ or /tmp/i2pd/certificates
*/
- void SetCertsDir(const std::string & cmdline_certsdir);
+ void SetCertsDir(const std::string & cmdline_certsdir);
/**
* @brief Create subdirectories inside datadir
@@ -115,7 +115,7 @@
/**
* @brief Get list of files in directory
- * @param path Path to directory
+ * @param path Path to directory
* @param files Vector to store found files
* @return true on success and false if directory not exists
*/
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Family.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -88,7 +88,7 @@
}
EVP_PKEY_free (pkey);
if (verifier && cn)
- m_SigningKeys[cn] = verifier;
+ m_SigningKeys.emplace (cn, std::make_pair(verifier, m_SigningKeys.size () + 1));
}
SSL_free (ssl);
}
@@ -121,7 +121,7 @@
}
bool Families::VerifyFamily (const std::string& family, const IdentHash& ident,
- const char * signature, const char * key)
+ const char * signature, const char * key) const
{
uint8_t buf[100], signatureBuf[64];
size_t len = family.length (), signatureLen = strlen (signature);
@@ -137,11 +137,19 @@
Base64ToByteStream (signature, signatureLen, signatureBuf, 64);
auto it = m_SigningKeys.find (family);
if (it != m_SigningKeys.end ())
- return it->second->Verify (buf, len, signatureBuf);
+ return it->second.first->Verify (buf, len, signatureBuf);
// TODO: process key
return true;
}
+ FamilyID Families::GetFamilyID (const std::string& family) const
+ {
+ auto it = m_SigningKeys.find (family);
+ if (it != m_SigningKeys.end ())
+ return it->second.second;
+ return 0;
+ }
+
std::string CreateFamilySignature (const std::string& family, const IdentHash& ident)
{
auto filename = i2p::fs::DataDirPath("family", (family + ".key"));
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Family.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -19,6 +19,7 @@
{
namespace data
{
+ typedef int FamilyID;
class Families
{
public:
@@ -27,7 +28,8 @@
~Families ();
void LoadCertificates ();
bool VerifyFamily (const std::string& family, const IdentHash& ident,
- const char * signature, const char * key = nullptr);
+ const char * signature, const char * key = nullptr) const;
+ FamilyID GetFamilyID (const std::string& family) const;
private:
@@ -35,7 +37,7 @@
private:
- std::map<std::string, std::shared_ptr<i2p::crypto::Verifier> > m_SigningKeys;
+ std::map<std::string, std::pair<std::shared_ptr<i2p::crypto::Verifier>, FamilyID> > m_SigningKeys; // family -> (verifier, id)
};
std::string CreateFamilySignature (const std::string& family, const IdentHash& ident);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Garlic.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -293,14 +293,14 @@
size_t size = 0;
if (isDestination)
{
- buf[size] = eGarlicDeliveryTypeDestination << 5;// delivery instructions flag destination
+ buf[size] = eGarlicDeliveryTypeDestination << 5;// delivery instructions flag destination
size++;
memcpy (buf + size, m_Destination->GetIdentHash (), 32);
size += 32;
}
else
{
- buf[size] = 0;// delivery instructions flag local
+ buf[size] = 0;// delivery instructions flag local
size++;
}
@@ -484,6 +484,11 @@
return true;
}
+ void GarlicDestination::SubmitECIESx25519Key (const uint8_t * key, uint64_t tag)
+ {
+ AddECIESx25519Key (key, tag);
+ }
+
void GarlicDestination::HandleGarlicMessage (std::shared_ptr<I2NPMessage> msg)
{
uint8_t * buf = msg->GetPayload ();
@@ -739,7 +744,7 @@
LogPrint (eLogError, "Garlic: Message is too short");
break;
}
- buf += GetI2NPMessageLength (buf, len - offset); // I2NP
+ buf += GetI2NPMessageLength (buf, len - offset); // I2NP
buf += 4; // CloveID
buf += 8; // Date
buf += 3; // Certificate
@@ -1019,7 +1024,7 @@
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
for (auto it: files)
if (ts >= i2p::fs::GetLastUpdateTime (it) + INCOMING_TAGS_EXPIRATION_TIMEOUT)
- i2p::fs::Remove (it);
+ i2p::fs::Remove (it);
}
void GarlicDestination::HandleECIESx25519GarlicClove (const uint8_t * buf, size_t len)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Garlic.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -245,6 +245,7 @@
void AddSessionKey (const uint8_t * key, const uint8_t * tag); // one tag
void AddECIESx25519Key (const uint8_t * key, uint64_t tag); // one tag
virtual bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag); // from different thread
+ virtual void SubmitECIESx25519Key (const uint8_t * key, uint64_t tag); // from different thread
void DeliveryStatusSent (GarlicRoutingSessionPtr session, uint32_t msgID);
uint64_t AddECIESx25519SessionNextTag (ReceiveRatchetTagSetPtr tagset);
void AddECIESx25519Session (const uint8_t * staticKey, ECIESX25519AEADRatchetSessionPtr session);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Gost.cpp
^
|
@@ -96,7 +96,7 @@
EC_POINT * C = EC_POINT_new (m_Group);
EC_POINT_mul (m_Group, C, z1, pub, z2, ctx); // z1*P + z2*pub
BIGNUM * x = BN_CTX_get (ctx);
- GetXY (C, x, nullptr); // Cx
+ GetXY (C, x, nullptr); // Cx
BN_mod (x, x, q, ctx); // Cx % q
bool ret = !BN_cmp (x, r); // Cx = r ?
EC_POINT_free (C);
@@ -111,8 +111,8 @@
BN_CTX * ctx = BN_CTX_new ();
BN_CTX_start (ctx);
EC_POINT * C = EC_POINT_new (m_Group); // C = k*P = (rx, ry)
- EC_POINT * Q = nullptr;
- if (EC_POINT_set_compressed_coordinates_GFp (m_Group, C, r, isNegativeY ? 1 : 0, ctx))
+ EC_POINT * Q = nullptr;
+ if (EC_POINT_set_compressed_coordinates_GFp (m_Group, C, r, isNegativeY ? 1 : 0, ctx))
{
EC_POINT * S = EC_POINT_new (m_Group); // S = s*P
EC_POINT_mul (m_Group, S, s, nullptr, nullptr, ctx);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/HTTP.cpp
^
|
@@ -279,7 +279,7 @@
method = tokens[0];
uri = tokens[1];
version = tokens[2];
- expect = HEADER_LINE;
+ expect = HEADER_LINE;
}
else
{
@@ -363,7 +363,7 @@
return false; /* no header */
if (it->second.find("gzip") != std::string::npos)
return true; /* gotcha! */
- if (includingI2PGzip && it->second.find("x-i2p-gzip") != std::string::npos)
+ if (includingI2PGzip && it->second.find("x-i2p-gzip") != std::string::npos)
return true;
return false;
}
@@ -409,7 +409,7 @@
/* all ok */
version = tokens[0];
status = tokens[2];
- expect = HEADER_LINE;
+ expect = HEADER_LINE;
} else {
std::string line = str.substr(pos, eol - pos);
auto p = parse_header_line(line);
@@ -460,7 +460,7 @@
case 304: ptr = "Not Modified"; break;
case 307: ptr = "Temporary Redirect"; break;
/* client error */
- case 400: ptr = "Bad Request"; break;
+ case 400: ptr = "Bad Request"; break;
case 401: ptr = "Unauthorized"; break;
case 403: ptr = "Forbidden"; break;
case 404: ptr = "Not Found"; break;
@@ -471,7 +471,7 @@
case 502: ptr = "Bad Gateway"; break;
case 503: ptr = "Not Implemented"; break;
case 504: ptr = "Gateway Timeout"; break;
- default: ptr = "Unknown Status"; break;
+ default: ptr = "Unknown Status"; break;
}
return ptr;
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/HTTP.h
^
|
@@ -161,7 +161,7 @@
/**
* @brief Merge HTTP response content with Transfer-Encoding: chunked
- * @param in Input stream
+ * @param in Input stream
* @param out Output stream
* @return true on success, false otherwise
*/
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/I2NPProtocol.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -171,7 +171,7 @@
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
const std::set<i2p::data::IdentHash>& excludedFloodfills,
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel, const uint8_t * replyKey,
- const uint8_t * replyTag, bool replyECIES)
+ const uint8_t * replyTag, bool replyECIES)
{
int cnt = excludedFloodfills.size ();
auto m = cnt > 7 ? NewI2NPMessage () : NewI2NPShortMessage ();
@@ -244,7 +244,7 @@
}
std::shared_ptr<I2NPMessage> CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::RouterInfo> router,
- uint32_t replyToken, std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel)
+ uint32_t replyToken, std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel)
{
if (!router) // we send own RouterInfo
router = context.GetSharedRouterInfo ();
@@ -629,7 +629,7 @@
// we send it to reply tunnel
transports.SendMessage (clearText + SHORT_REQUEST_RECORD_NEXT_IDENT_OFFSET,
CreateTunnelGatewayMsg (bufbe32toh (clearText + SHORT_REQUEST_RECORD_NEXT_TUNNEL_OFFSET),
- i2p::garlic::WrapECIESX25519Message (replyMsg, noiseState.m_CK + 32, tag)));
+ i2p::garlic::WrapECIESX25519Message (replyMsg, noiseState.m_CK + 32, tag)));
}
else
{
@@ -802,13 +802,8 @@
break;
case eI2NPGarlic:
{
- if (msg->from)
- {
- if (msg->from->GetTunnelPool ())
- msg->from->GetTunnelPool ()->ProcessGarlicMessage (msg);
- else
- LogPrint (eLogInfo, "I2NP: Local destination for garlic doesn't exist anymore");
- }
+ if (msg->from && msg->from->GetTunnelPool ())
+ msg->from->GetTunnelPool ()->ProcessGarlicMessage (msg);
else
i2p::context.ProcessGarlicMessage (msg);
break;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/I2NPProtocol.h
^
|
@@ -150,7 +150,7 @@
std::shared_ptr<i2p::tunnel::InboundTunnel> from;
I2NPMessage (): buf (nullptr),len (I2NP_HEADER_SIZE + 2),
- offset(2), maxLen (0), from (nullptr) {}; // reserve 2 bytes for NTCP header
+ offset(2), maxLen (0), from (nullptr) {}; // reserve 2 bytes for NTCP header
// header accessors
uint8_t * GetHeader () { return GetBuffer (); };
@@ -274,8 +274,8 @@
uint32_t replyTunnelID, bool exploratory = false, std::set<i2p::data::IdentHash> * excludedPeers = nullptr);
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
const std::set<i2p::data::IdentHash>& excludedFloodfills,
- std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel,
- const uint8_t * replyKey, const uint8_t * replyTag, bool replyECIES = false);
+ std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel,
+ const uint8_t * replyKey, const uint8_t * replyTag, bool replyECIES = false);
std::shared_ptr<I2NPMessage> CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
std::shared_ptr<I2NPMessage> CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::RouterInfo> router = nullptr, uint32_t replyToken = 0, std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel = nullptr);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Identity.cpp
^
|
@@ -64,7 +64,7 @@
{
case SIGNING_KEY_TYPE_ECDSA_SHA256_P256:
{
- size_t padding = 128 - i2p::crypto::ECDSAP256_KEY_LENGTH; // 64 = 128 - 64
+ size_t padding = 128 - i2p::crypto::ECDSAP256_KEY_LENGTH; // 64 = 128 - 64
RAND_bytes (m_StandardIdentity.signingKey, padding);
memcpy (m_StandardIdentity.signingKey + padding, signingKey, i2p::crypto::ECDSAP256_KEY_LENGTH);
break;
@@ -788,7 +788,7 @@
keys.m_OfflineSignature.resize (pubKeyLen + m_Public->GetSignatureLen () + 6);
htobe32buf (keys.m_OfflineSignature.data (), expires); // expires
htobe16buf (keys.m_OfflineSignature.data () + 4, type); // type
- GenerateSigningKeyPair (type, keys.m_SigningPrivateKey, keys.m_OfflineSignature.data () + 6); // public key
+ GenerateSigningKeyPair (type, keys.m_SigningPrivateKey, keys.m_OfflineSignature.data () + 6); // public key
Sign (keys.m_OfflineSignature.data (), pubKeyLen + 6, keys.m_OfflineSignature.data () + 6 + pubKeyLen); // signature
// recreate signer
keys.m_Signer = nullptr;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Identity.h
^
|
@@ -120,7 +120,7 @@
CryptoKeyType GetCryptoKeyType () const;
void DropVerifier () const; // to save memory
- bool operator == (const IdentityEx & other) const { return GetIdentHash() == other.GetIdentHash(); }
+ bool operator == (const IdentityEx & other) const { return GetIdentHash() == other.GetIdentHash(); }
void RecalculateIdentHash(uint8_t * buff=nullptr);
static i2p::crypto::Verifier * CreateVerifier (SigningKeyType keyType);
@@ -222,7 +222,7 @@
RoutingDestination () {};
virtual ~RoutingDestination () {};
- virtual std::shared_ptr<const IdentityEx> GetIdentity () const = 0;
+ virtual std::shared_ptr<const IdentityEx> GetIdentity () const = 0;
virtual void Encrypt (const uint8_t * data, uint8_t * encrypted) const = 0; // encrypt data for
virtual bool IsDestination () const = 0; // for garlic
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/LeaseSet.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -59,9 +59,9 @@
if (readIdentity || !m_Identity)
m_Identity = std::make_shared<IdentityEx>(m_Buffer, m_BufferLen);
size_t size = m_Identity->GetFullLen ();
- if (size > m_BufferLen)
+ if (size + 256 > m_BufferLen)
{
- LogPrint (eLogError, "LeaseSet: Identity length ", size, " exceeds buffer size ", m_BufferLen);
+ LogPrint (eLogError, "LeaseSet: Identity length ", int(size), " exceeds buffer size ", int(m_BufferLen));
m_IsValid = false;
return;
}
@@ -74,7 +74,7 @@
size += m_Identity->GetSigningPublicKeyLen (); // unused signing key
if (size + 1 > m_BufferLen)
{
- LogPrint (eLogError, "LeaseSet: ", size, " exceeds buffer size ", m_BufferLen);
+ LogPrint (eLogError, "LeaseSet: ", int(size), " exceeds buffer size ", int(m_BufferLen));
m_IsValid = false;
return;
}
@@ -89,7 +89,7 @@
}
if (size + num*LEASE_SIZE > m_BufferLen)
{
- LogPrint (eLogError, "LeaseSet: ", size, " exceeds buffer size ", m_BufferLen);
+ LogPrint (eLogError, "LeaseSet: ", int(size), " exceeds buffer size ", int(m_BufferLen));
m_IsValid = false;
return;
}
@@ -125,7 +125,7 @@
auto signedSize = leases - m_Buffer;
if (signedSize + m_Identity->GetSignatureLen () > m_BufferLen)
{
- LogPrint (eLogError, "LeaseSet: Signature exceeds buffer size ", m_BufferLen);
+ LogPrint (eLogError, "LeaseSet: Signature exceeds buffer size ", int(m_BufferLen));
m_IsValid = false;
}
else if (!m_Identity->Verify (m_Buffer, signedSize, leases))
@@ -172,7 +172,7 @@
m_ExpirationTime = lease.endDate;
if (m_StoreLeases)
{
- auto ret = m_Leases.insert (std::make_shared<Lease>(lease));
+ auto ret = m_Leases.insert (i2p::data::netdb.NewLease (lease));
if (!ret.second) (*ret.first)->endDate = lease.endDate; // update existing
(*ret.first)->isUpdated = true;
}
@@ -274,7 +274,7 @@
{
if (len <= m_BufferLen) m_BufferLen = len;
else
- LogPrint (eLogError, "LeaseSet2: Actual buffer size ", len , " exceeds full buffer size ", m_BufferLen);
+ LogPrint (eLogError, "LeaseSet2: Actual buffer size ", int(len) , " exceeds full buffer size ", int(m_BufferLen));
}
LeaseSet2::LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases, CryptoKeyType preferredCrypto):
@@ -320,7 +320,7 @@
else
identity = GetIdentity ();
size_t offset = identity->GetFullLen ();
- if (offset + 8 >= len) return;
+ if (offset + 8 > len) return;
m_PublishedTimestamp = bufbe32toh (buf + offset); offset += 4; // published timestamp (seconds)
uint16_t expires = bufbe16toh (buf + offset); offset += 2; // expires (seconds)
SetExpirationTime ((m_PublishedTimestamp + expires)*1000LL); // in milliseconds
@@ -364,6 +364,10 @@
SetIsValid (verified);
}
offset += m_TransientVerifier ? m_TransientVerifier->GetSignatureLen () : identity->GetSignatureLen ();
+ if (offset > len) {
+ LogPrint (eLogWarning, "LeaseSet2: short buffer: wanted ", int(offset), "bytes, have ", int(len));
+ return;
+ }
SetBufferLen (offset);
}
@@ -388,17 +392,17 @@
// properties
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
offset += propertiesLen; // skip for now. TODO: implement properties
- if (offset + 1 >= len) return 0;
// key sections
CryptoKeyType preferredKeyType = m_EncryptionType;
bool preferredKeyFound = false;
+ if (offset + 1 > len) return 0;
int numKeySections = buf[offset]; offset++;
for (int i = 0; i < numKeySections; i++)
{
+ if (offset + 4 > len) return 0;
uint16_t keyType = bufbe16toh (buf + offset); offset += 2; // encryption key type
- if (offset + 2 >= len) return 0;
uint16_t encryptionKeyLen = bufbe16toh (buf + offset); offset += 2;
- if (offset + encryptionKeyLen >= len) return 0;
+ if (offset + encryptionKeyLen > len) return 0;
if (IsStoreLeases () && !preferredKeyFound) // create encryptor with leases only
{
// we pick first valid key if preferred not found
@@ -413,7 +417,7 @@
offset += encryptionKeyLen;
}
// leases
- if (offset + 1 >= len) return 0;
+ if (offset + 1 > len) return 0;
int numLeases = buf[offset]; offset++;
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
if (IsStoreLeases ())
@@ -432,7 +436,8 @@
}
else
offset += numLeases*LEASE2_SIZE; // 40 bytes per lease
- return offset;
+
+ return (offset > len ? 0 : offset);
}
size_t LeaseSet2::ReadMetaLS2TypeSpecificPart (const uint8_t * buf, size_t len)
@@ -442,18 +447,18 @@
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
offset += propertiesLen; // skip for now. TODO: implement properties
// entries
- if (offset + 1 >= len) return 0;
+ if (offset + 1 > len) return 0;
int numEntries = buf[offset]; offset++;
for (int i = 0; i < numEntries; i++)
{
- if (offset + 40 >= len) return 0;
+ if (offset + LEASE2_SIZE > len) return 0;
offset += 32; // hash
offset += 3; // flags
offset += 1; // cost
offset += 4; // expires
}
// revocations
- if (offset + 1 >= len) return 0;
+ if (offset + 1 > len) return 0;
int numRevocations = buf[offset]; offset++;
for (int i = 0; i < numRevocations; i++)
{
@@ -582,7 +587,7 @@
// helper for ExtractClientAuthData
static inline bool GetAuthCookie (const uint8_t * authClients, int numClients, const uint8_t * okm, uint8_t * authCookie)
{
- // try to find clientCookie_i for clientID_i = okm[44:51]
+ // try to find clientCookie_i for clientID_i = okm[44:51]
for (int i = 0; i < numClients; i++)
{
if (!memcmp (okm + 44, authClients + i*40, 8)) // clientID_i
@@ -606,7 +611,7 @@
{
const uint8_t * ephemeralPublicKey = buf + offset; offset += 32; // ephemeralPublicKey
uint16_t numClients = bufbe16toh (buf + offset); offset += 2; // clients
- const uint8_t * authClients = buf + offset; offset += numClients*40; // authClients
+ const uint8_t * authClients = buf + offset; offset += numClients*40; // authClients
if (offset > len)
{
LogPrint (eLogError, "LeaseSet2: Too many clients ", numClients, " in DH auth data");
@@ -632,7 +637,7 @@
{
const uint8_t * authSalt = buf + offset; offset += 32; // authSalt
uint16_t numClients = bufbe16toh (buf + offset); offset += 2; // clients
- const uint8_t * authClients = buf + offset; offset += numClients*40; // authClients
+ const uint8_t * authClients = buf + offset; offset += numClients*40; // authClients
if (offset > len)
{
LogPrint (eLogError, "LeaseSet2: Too many clients ", numClients, " in PSK auth data");
@@ -737,7 +742,7 @@
htobe64buf (m_Buffer + offset, ts);
offset += 8; // end date
}
- // we don't sign it yet. must be signed later on
+ // we don't sign it yet. must be signed later on
}
LocalLeaseSet::LocalLeaseSet (std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len):
@@ -995,7 +1000,7 @@
ek.GenerateKeys (); // esk and epk
memcpy (authData, ek.GetPublicKey (), 32); authData += 32; // epk
htobe16buf (authData, authKeys->size ()); authData += 2; // num clients
- uint8_t authInput[100]; // sharedSecret || cpk_i || subcredential || publishedTimestamp
+ uint8_t authInput[100]; // sharedSecret || cpk_i || subcredential || publishedTimestamp
memcpy (authInput + 64, subcredential, 36);
for (auto& it: *authKeys)
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/LeaseSet.h
^
|
@@ -128,8 +128,8 @@
};
/**
- validate lease set buffer signature and extract expiration timestamp
- @returns true if the leaseset is well formed and signature is valid
+ * validate lease set buffer signature and extract expiration timestamp
+ * @returns true if the leaseset is well formed and signature is valid
*/
bool LeaseSetBufferValidate(const uint8_t * ptr, size_t sz, uint64_t & expires);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Log.cpp
^
|
@@ -46,7 +46,7 @@
#ifndef _WIN32
/**
- * @brief Maps our log levels to syslog one
+ * @brief Maps our log levels to syslog one
* @return syslog priority LOG_*, as defined in syslog.h
*/
static inline int GetSyslogPrio (enum LogLevel l) {
@@ -113,11 +113,11 @@
std::string str_tolower(std::string s) {
std::transform(s.begin(), s.end(), s.begin(),
- // static_cast<int(*)(int)>(std::tolower) // wrong
- // [](int c){ return std::tolower(c); } // wrong
- // [](char c){ return std::tolower(c); } // wrong
- [](unsigned char c){ return std::tolower(c); } // correct
- );
+ // static_cast<int(*)(int)>(std::tolower) // wrong
+ // [](int c){ return std::tolower(c); } // wrong
+ // [](char c){ return std::tolower(c); } // wrong
+ [](unsigned char c){ return std::tolower(c); } // correct
+ );
return s;
}
@@ -170,7 +170,7 @@
break;
case eLogStdout:
default:
- std::cout << TimeAsString(msg->timestamp)
+ std::cout << TimeAsString(msg->timestamp)
<< "@" << short_tid
<< "/" << LogMsgColors[msg->level] << g_LogLevelStr[msg->level] << LogMsgColors[eNumLogLevels]
<< " - " << msg->text << std::endl;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Log.h
^
|
@@ -52,7 +52,7 @@
{
private:
- enum LogType m_Destination;
+ enum LogType m_Destination;
enum LogLevel m_MinLevel;
std::shared_ptr<std::ostream> m_LogStream;
std::string m_Logfile;
@@ -75,7 +75,7 @@
/**
* @brief Makes formatted string from unix timestamp
- * @param ts Second since epoch
+ * @param ts Second since epoch
*
* This function internally caches the result for last provided value
*/
@@ -86,52 +86,52 @@
Log ();
~Log ();
- LogType GetLogType () { return m_Destination; };
+ LogType GetLogType () { return m_Destination; };
LogLevel GetLogLevel () { return m_MinLevel; };
void Start ();
void Stop ();
/**
- * @brief Sets minimal allowed level for log messages
- * @param level String with wanted minimal msg level
+ * @brief Sets minimal allowed level for log messages
+ * @param level String with wanted minimal msg level
*/
- void SetLogLevel (const std::string& level);
+ void SetLogLevel (const std::string& level);
/**
* @brief Sets log destination to logfile
- * @param path Path to logfile
+ * @param path Path to logfile
*/
void SendTo (const std::string &path);
/**
* @brief Sets log destination to given output stream
- * @param os Output stream
+ * @param os Output stream
*/
void SendTo (std::shared_ptr<std::ostream> os);
/**
- * @brief Sets format for timestamps in log
- * @param format String with timestamp format
+ * @brief Sets format for timestamps in log
+ * @param format String with timestamp format
*/
void SetTimeFormat (std::string format) { m_TimeFormat = format; };
#ifndef _WIN32
/**
* @brief Sets log destination to syslog
- * @param name Wanted program name
+ * @param name Wanted program name
* @param facility Wanted log category
*/
void SendTo (const char *name, int facility);
#endif
/**
- * @brief Format log message and write to output stream/syslog
- * @param msg Pointer to processed message
+ * @brief Format log message and write to output stream/syslog
+ * @param msg Pointer to processed message
*/
void Append(std::shared_ptr<i2p::log::LogMsg> &);
- /** @brief Reopen log file */
+ /** @brief Reopen log file */
void Reopen();
};
@@ -144,8 +144,8 @@
*/
struct LogMsg {
std::time_t timestamp;
- std::string text; /**< message text as single string */
- LogLevel level; /**< message level */
+ std::string text; /**< message text as single string */
+ LogLevel level; /**< message level */
std::thread::id tid; /**< id of thread that generated message */
LogMsg (LogLevel lvl, std::time_t ts, std::string&& txt): timestamp(ts), text(std::move(txt)), level(lvl) {}
@@ -153,7 +153,7 @@
Log & Logger();
- typedef std::function<void (const std::string&)> ThrowFunction;
+ typedef std::function<void (const std::string&)> ThrowFunction;
ThrowFunction GetThrowFunction ();
void SetThrowFunction (ThrowFunction f);
} // log
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/NTCP2.cpp
^
|
@@ -23,7 +23,7 @@
#include "HTTP.h"
#include "util.h"
-#ifdef __linux__
+#if defined(__linux__) && !defined(_NETINET_IN_H)
#include <linux/in6.h>
#endif
@@ -59,14 +59,14 @@
void NTCP2Establisher::KDF1Bob ()
{
- KeyDerivationFunction1 (GetRemotePub (), i2p::context.GetStaticKeys (), i2p::context.GetNTCP2StaticPublicKey (), GetRemotePub ());
+ KeyDerivationFunction1 (GetRemotePub (), i2p::context.GetNTCP2StaticKeys (), i2p::context.GetNTCP2StaticPublicKey (), GetRemotePub ());
}
void NTCP2Establisher::KeyDerivationFunction2 (const uint8_t * sessionRequest, size_t sessionRequestLen, const uint8_t * epub)
{
MixHash (sessionRequest + 32, 32); // encrypted payload
- int paddingLength = sessionRequestLen - 64;
+ int paddingLength = sessionRequestLen - 64;
if (paddingLength > 0)
MixHash (sessionRequest + 64, paddingLength);
MixHash (epub, 32);
@@ -91,7 +91,7 @@
void NTCP2Establisher::KDF3Alice ()
{
uint8_t inputKeyMaterial[32];
- i2p::context.GetStaticKeys ().Agree (GetRemotePub (), inputKeyMaterial);
+ i2p::context.GetNTCP2StaticKeys ().Agree (GetRemotePub (), inputKeyMaterial);
MixKey (inputKeyMaterial);
}
@@ -130,7 +130,7 @@
// m3p2Len
auto bufLen = i2p::context.GetRouterInfo ().GetBufferLen ();
m3p2Len = bufLen + 4 + 16; // (RI header + RI + MAC for now) TODO: implement options
- htobe16buf (options + 4, m3p2Len);
+ htobe16buf (options + 4, m3p2Len);
// fill m3p2 payload (RouterInfo block)
m_SessionConfirmedBuffer = new uint8_t[m3p2Len + 48]; // m3p1 is 48 bytes
uint8_t * m3p2 = m_SessionConfirmedBuffer + 48;
@@ -231,11 +231,11 @@
auto ts = i2p::util::GetSecondsSinceEpoch ();
uint32_t tsA = bufbe32toh (options + 8);
if (tsA < ts - NTCP2_CLOCK_SKEW || tsA > ts + NTCP2_CLOCK_SKEW)
- {
+ {
LogPrint (eLogWarning, "NTCP2: SessionRequest time difference ", (int)(ts - tsA), " exceeds clock skew");
clockSkew = true;
// we send SessionCreate to let Alice know our time and then close session
- }
+ }
}
else
{
@@ -320,7 +320,7 @@
}
NTCP2Session::NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter,
- std::shared_ptr<const i2p::data::RouterInfo::Address> addr):
+ std::shared_ptr<const i2p::data::RouterInfo::Address> addr):
TransportSession (in_RemoteRouter, NTCP2_ESTABLISH_TIMEOUT),
m_Server (server), m_Socket (m_Server.GetService ()),
m_IsEstablished (false), m_IsTerminated (false),
@@ -418,7 +418,7 @@
void NTCP2Session::DeleteNextReceiveBuffer (uint64_t ts)
{
if (m_NextReceivedBuffer && !m_IsReceiving &&
- ts > m_LastActivityTimestamp + NTCP2_RECEIVE_BUFFER_DELETION_TIMEOUT)
+ ts > m_LastActivityTimestamp + NTCP2_RECEIVE_BUFFER_DELETION_TIMEOUT)
{
delete[] m_NextReceivedBuffer;
m_NextReceivedBuffer = nullptr;
@@ -484,9 +484,9 @@
if (clockSkew)
{
// we don't care about padding, send SessionCreated and close session
- SendSessionCreated ();
+ SendSessionCreated ();
m_Server.GetService ().post (std::bind (&NTCP2Session::Terminate, shared_from_this ()));
- }
+ }
else if (paddingLen > 0)
{
if (paddingLen <= NTCP2_SESSION_REQUEST_MAX_SIZE - 64) // session request is 287 bytes max
@@ -496,7 +496,7 @@
}
else
{
- LogPrint (eLogWarning, "NTCP2: SessionRequest padding length ", (int)paddingLen, " is too long");
+ LogPrint (eLogWarning, "NTCP2: SessionRequest padding length ", (int)paddingLen, " is too long");
Terminate ();
}
}
@@ -549,7 +549,7 @@
}
else
{
- LogPrint (eLogWarning, "NTCP2: SessionCreated padding length ", (int)paddingLen, " is too long");
+ LogPrint (eLogWarning, "NTCP2: SessionCreated padding length ", (int)paddingLen, " is too long");
Terminate ();
}
}
@@ -757,7 +757,7 @@
if (IsTerminated ()) return;
#ifdef __linux__
const int one = 1;
- setsockopt(m_Socket.native_handle(), IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
+ setsockopt(m_Socket.native_handle(), IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
#endif
boost::asio::async_read (m_Socket, boost::asio::buffer(&m_NextReceivedLen, 2), boost::asio::transfer_all (),
std::bind(&NTCP2Session::HandleReceivedLength, shared_from_this (), std::placeholders::_1, std::placeholders::_2));
@@ -1126,11 +1126,11 @@
{
if (!m_SendKey ||
#if OPENSSL_SIPHASH
- !m_SendMDCtx
+ !m_SendMDCtx
#else
- !m_SendSipKey
+ !m_SendSipKey
#endif
- ) return;
+ ) return;
m_NextSendBuffer = new uint8_t[49]; // 49 = 12 bytes message + 16 bytes MAC + 2 bytes size + up to 19 padding block
// termination block
m_NextSendBuffer[2] = eNTCP2BlkTermination;
@@ -1164,20 +1164,20 @@
else if (m_SendQueue.size () > NTCP2_MAX_OUTGOING_QUEUE_SIZE)
{
LogPrint (eLogWarning, "NTCP2: Outgoing messages queue size to ",
- GetIdentHashBase64(), " exceeds ", NTCP2_MAX_OUTGOING_QUEUE_SIZE);
+ GetIdentHashBase64(), " exceeds ", NTCP2_MAX_OUTGOING_QUEUE_SIZE);
Terminate ();
}
}
- void NTCP2Session::SendLocalRouterInfo ()
+ void NTCP2Session::SendLocalRouterInfo (bool update)
{
- if (!IsOutgoing ()) // we send it in SessionConfirmed
+ if (update || !IsOutgoing ()) // we send it in SessionConfirmed for ougoing session
m_Server.GetService ().post (std::bind (&NTCP2Session::SendRouterInfo, shared_from_this ()));
}
NTCP2Server::NTCP2Server ():
RunnableServiceWithWork ("NTCP2"), m_TerminationTimer (GetService ()),
- m_ProxyType(eNoProxy), m_Resolver(GetService ())
+ m_ProxyType(eNoProxy), m_Resolver(GetService ())
{
}
@@ -1243,7 +1243,7 @@
m_NTCP2V6Acceptor->open (boost::asio::ip::tcp::v6());
m_NTCP2V6Acceptor->set_option (boost::asio::ip::v6_only (true));
m_NTCP2V6Acceptor->set_option (boost::asio::socket_base::reuse_address (true));
-#ifdef __linux__
+#if defined(__linux__) && !defined(_NETINET_IN_H)
if (!m_Address6 && !m_YggdrasilAddress) // only if not binded to address
{
// Set preference to use public IPv6 address -- tested on linux, not works on windows, and not tested on others
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/NTCP2.h
^
|
@@ -148,7 +148,7 @@
void ClientLogin (); // Alice
void ServerLogin (); // Bob
- void SendLocalRouterInfo (); // after handshake
+ void SendLocalRouterInfo (bool update); // after handshake or by update
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
private:
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/NetDb.cpp
^
|
@@ -107,7 +107,10 @@
{
i2p::util::SetThreadName("NetDB");
- uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0;
+ uint64_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0;
+ uint64_t lastProfilesCleanup = i2p::util::GetSecondsSinceEpoch ();
+ int16_t profilesCleanupVariance = 0;
+
while (m_IsRunning)
{
try
@@ -155,6 +158,7 @@
m_Requests.ManageRequests ();
lastManageRequest = ts;
}
+
if (ts - lastSave >= 60) // save routers, manage leasesets and validate subscriptions every minute
{
if (lastSave)
@@ -164,12 +168,20 @@
}
lastSave = ts;
}
+
if (ts - lastDestinationCleanup >= i2p::garlic::INCOMING_TAGS_EXPIRATION_TIMEOUT)
{
i2p::context.CleanupDestination ();
lastDestinationCleanup = ts;
}
+ if (ts - lastProfilesCleanup >= (uint64_t)(i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance))
+ {
+ DeleteObsoleteProfiles ();
+ lastProfilesCleanup = ts;
+ profilesCleanupVariance = (rand () % (2 * i2p::data::PEER_PROFILE_AUTOCLEAN_VARIANCE) - i2p::data::PEER_PROFILE_AUTOCLEAN_VARIANCE);
+ }
+
// publish
if (!m_HiddenMode && i2p::transport::transports.IsOnline ())
{
@@ -195,6 +207,7 @@
lastPublish = ts;
}
}
+
if (ts - lastExploratory >= 30) // exploratory every 30 seconds
{
auto numRouters = m_RouterInfos.size ();
@@ -227,11 +240,10 @@
m_HiddenMode = hide;
}
- bool NetDb::AddRouterInfo (const uint8_t * buf, int len)
+ std::shared_ptr<const RouterInfo> NetDb::AddRouterInfo (const uint8_t * buf, int len)
{
bool updated;
- AddRouterInfo (buf, len, updated);
- return updated;
+ return AddRouterInfo (buf, len, updated);
}
std::shared_ptr<const RouterInfo> NetDb::AddRouterInfo (const uint8_t * buf, int len, bool& updated)
@@ -259,7 +271,10 @@
if (r->IsNewer (buf, len))
{
bool wasFloodfill = r->IsFloodfill ();
- r->Update (buf, len);
+ {
+ std::unique_lock<std::mutex> l(m_RouterInfosMutex);
+ r->Update (buf, len);
+ }
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
{
@@ -423,12 +438,15 @@
// try reseeding from floodfill first if specified
std::string riPath;
- if(i2p::config::GetOption("reseed.floodfill", riPath)) {
+ if(i2p::config::GetOption("reseed.floodfill", riPath))
+ {
auto ri = std::make_shared<RouterInfo>(riPath);
- if (ri->IsFloodfill()) {
+ if (ri->IsFloodfill())
+ {
const uint8_t * riData = ri->GetBuffer();
int riLen = ri->GetBufferLen();
- if(!i2p::data::netdb.AddRouterInfo(riData, riLen)) {
+ if (!i2p::data::netdb.AddRouterInfo(riData, riLen))
+ {
// bad router info
LogPrint(eLogError, "NetDb: Bad router info");
return;
@@ -476,7 +494,7 @@
{
auto r = std::make_shared<RouterInfo>(path);
if (r->GetRouterIdentity () && !r->IsUnreachable () && r->HasValidAddresses () &&
- ts < r->GetTimestamp () + 24*60*60*NETDB_MAX_OFFLINE_EXPIRATION_TIMEOUT*1000LL)
+ ts < r->GetTimestamp () + 24*60*60*NETDB_MAX_OFFLINE_EXPIRATION_TIMEOUT*1000LL)
{
r->DeleteBuffer ();
if (m_RouterInfos.emplace (r->GetIdentHash (), r).second)
@@ -607,7 +625,7 @@
}
// make router reachable back if too few routers or floodfills
if (it.second->IsUnreachable () && (total - deletedCount < NETDB_MIN_ROUTERS ||
- (it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
+ (it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
it.second->SetUnreachable (false);
// find & mark expired routers
if (!it.second->IsReachable () && it.second->IsSSU (false))
@@ -630,7 +648,7 @@
} // m_RouterInfos iteration
m_RouterInfoBuffersPool.CleanUpMt ();
-
+
if (updatedCount > 0)
LogPrint (eLogInfo, "NetDb: Saved ", updatedCount, " new/updated routers");
if (deletedCount > 0)
@@ -659,7 +677,7 @@
else
++it;
}
- }
+ }
}
void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete, bool direct)
@@ -675,7 +693,7 @@
if (floodfill)
{
if (direct && !floodfill->IsReachableFrom (i2p::context.GetRouterInfo ()) &&
- !i2p::transport::transports.IsConnected (floodfill->GetIdentHash ()))
+ !i2p::transport::transports.IsConnected (floodfill->GetIdentHash ()))
direct = false; // floodfill can't be reached directly
if (direct)
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
@@ -927,9 +945,9 @@
}
uint16_t numExcluded = bufbe16toh (excluded);
excluded += 2;
- if (numExcluded > 512)
+ if (numExcluded > 512 || (excluded - buf) + numExcluded*32 > (int)msg->GetPayloadLength ())
{
- LogPrint (eLogWarning, "NetDb: Number of excluded peers", numExcluded, " exceeds 512");
+ LogPrint (eLogWarning, "NetDb: Number of excluded peers", numExcluded, " is too much");
return;
}
@@ -938,10 +956,11 @@
{
LogPrint (eLogInfo, "NetDb: Exploratory close to ", key, " ", numExcluded, " excluded");
std::set<IdentHash> excludedRouters;
+ const uint8_t * excluded_ident = excluded;
for (int i = 0; i < numExcluded; i++)
{
- excludedRouters.insert (excluded);
- excluded += 32;
+ excludedRouters.insert (excluded_ident);
+ excluded_ident += 32;
}
std::vector<IdentHash> routers;
for (int i = 0; i < 3; i++)
@@ -958,14 +977,13 @@
else
{
if (lookupType == DATABASE_LOOKUP_TYPE_ROUTERINFO_LOOKUP ||
- lookupType == DATABASE_LOOKUP_TYPE_NORMAL_LOOKUP)
+ lookupType == DATABASE_LOOKUP_TYPE_NORMAL_LOOKUP)
{
auto router = FindRouter (ident);
if (router)
{
LogPrint (eLogDebug, "NetDb: Requested RouterInfo ", key, " found");
- if (!router->GetBuffer ())
- router->LoadBuffer (m_Storage.Path (router->GetIdentHashBase64 ()));
+ PopulateRouterInfoBuffer (router);
if (router->GetBuffer ())
replyMsg = CreateDatabaseStoreMsg (router);
}
@@ -1000,7 +1018,7 @@
if (closestFloodfills.empty ())
LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded");
replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills);
- }
+ }
}
excluded += numExcluded * 32;
if (replyMsg)
@@ -1123,7 +1141,7 @@
m_PublishExcluded.insert (floodfill->GetIdentHash ());
m_PublishReplyToken = replyToken;
if (floodfill->IsReachableFrom (i2p::context.GetRouterInfo ()) || // are we able to connect?
- i2p::transport::transports.IsConnected (floodfill->GetIdentHash ())) // already connected ?
+ i2p::transport::transports.IsConnected (floodfill->GetIdentHash ())) // already connected ?
// send directly
transports.SendMessage (floodfill->GetIdentHash (), CreateDatabaseStoreMsg (i2p::context.GetSharedRouterInfo (), replyToken));
else
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/NetDb.hpp
^
|
@@ -69,7 +69,7 @@
void Start ();
void Stop ();
- bool AddRouterInfo (const uint8_t * buf, int len);
+ std::shared_ptr<const RouterInfo> AddRouterInfo (const uint8_t * buf, int len);
bool AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
bool AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len);
bool AddLeaseSet2 (const IdentHash& ident, const uint8_t * buf, int len, uint8_t storeType);
@@ -90,13 +90,15 @@
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
+ std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
std::shared_ptr<const RouterInfo> GetRandomSSUV6Router () const; // TODO: change to v6 peer test later
std::shared_ptr<const RouterInfo> GetRandomIntroducer (bool v4, const std::set<IdentHash>& excluded) const;
+ std::shared_ptr<const RouterInfo> GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const;
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
std::vector<IdentHash> GetClosestFloodfills (const IdentHash& destination, size_t num,
std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
std::shared_ptr<const RouterInfo> GetClosestNonFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
- std::shared_ptr<const RouterInfo> GetRandomRouterInFamily(const std::string & fam) const;
+ std::shared_ptr<const RouterInfo> GetRandomRouterInFamily (FamilyID fam) const;
void SetUnreachable (const IdentHash& ident, bool unreachable);
void PostI2NPMsg (std::shared_ptr<const I2NPMessage> msg);
@@ -123,7 +125,9 @@
void ClearRouterInfos () { m_RouterInfos.clear (); };
std::shared_ptr<RouterInfo::Buffer> NewRouterInfoBuffer () { return m_RouterInfoBuffersPool.AcquireSharedMt (); };
-
+ void PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r);
+ std::shared_ptr<Lease> NewLease (const Lease& lease) { return m_LeasesPool.AcquireSharedMt (lease); };
+
uint32_t GetPublishReplyToken () const { return m_PublishReplyToken; };
private:
@@ -179,6 +183,7 @@
uint32_t m_PublishReplyToken = 0;
i2p::util::MemoryPoolMt<RouterInfo::Buffer> m_RouterInfoBuffersPool;
+ i2p::util::MemoryPoolMt<Lease> m_LeasesPool;
};
extern NetDb netdb;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/NetDbRequests.h
^
|
@@ -60,7 +60,7 @@
void Start ();
void Stop ();
- std::shared_ptr<RequestedDestination> CreateRequest (const IdentHash& destination, bool isExploratory, RequestedDestination::RequestComplete requestComplete = nullptr);
+ std::shared_ptr<RequestedDestination> CreateRequest (const IdentHash& destination, bool isExploratory, RequestedDestination::RequestComplete requestComplete = nullptr);
void RequestComplete (const IdentHash& ident, std::shared_ptr<RouterInfo> r);
std::shared_ptr<RequestedDestination> FindRequest (const IdentHash& ident) const;
void ManageRequests ();
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Poly1305.cpp
^
|
@@ -1,12 +1,13 @@
-#include "Poly1305.h"
/**
- This code is licensed under the MCGSI Public License
- Copyright 2018 Jeff Becker
-
- Kovri go write your own code
-
+ * This code is licensed under the MCGSI Public License
+ * Copyright 2018 Jeff Becker
+ *
+ *Kovri go write your own code
+ *
*/
+#include "Poly1305.h"
+
#if !OPENSSL_AEAD_CHACHA20_POLY1305
namespace i2p
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Poly1305.h
^
|
@@ -5,6 +5,7 @@
* Kovri go write your own code
*
*/
+
#ifndef LIBI2PD_POLY1305_H
#define LIBI2PD_POLY1305_H
#include <cstdint>
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Profiling.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -29,6 +29,8 @@
const char PEER_PROFILE_USAGE_REJECTED[] = "rejected";
const int PEER_PROFILE_EXPIRATION_TIMEOUT = 72; // in hours (3 days)
+ const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 24 * 3600; // in seconds (1 day)
+ const int PEER_PROFILE_AUTOCLEAN_VARIANCE = 3 * 3600; // in seconds (3 hours)
class RouterProfile
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Queue.h
^
|
@@ -28,7 +28,7 @@
void Put (Element e)
{
- std::unique_lock<std::mutex> l(m_QueueMutex);
+ std::unique_lock<std::mutex> l(m_QueueMutex);
m_Queue.push (std::move(e));
m_NonEmpty.notify_one ();
}
@@ -38,7 +38,7 @@
{
if (!vec.empty ())
{
- std::unique_lock<std::mutex> l(m_QueueMutex);
+ std::unique_lock<std::mutex> l(m_QueueMutex);
for (const auto& it: vec)
m_Queue.push (std::move(it));
m_NonEmpty.notify_one ();
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Reseed.cpp
^
|
@@ -187,31 +187,31 @@
}
s.seekg (1, std::ios::cur); // su3 file format version
SigningKeyType signatureType;
- s.read ((char *)&signatureType, 2); // signature type
+ s.read ((char *)&signatureType, 2); // signature type
signatureType = be16toh (signatureType);
uint16_t signatureLength;
- s.read ((char *)&signatureLength, 2); // signature length
+ s.read ((char *)&signatureLength, 2); // signature length
signatureLength = be16toh (signatureLength);
s.seekg (1, std::ios::cur); // unused
uint8_t versionLength;
- s.read ((char *)&versionLength, 1); // version length
+ s.read ((char *)&versionLength, 1); // version length
s.seekg (1, std::ios::cur); // unused
uint8_t signerIDLength;
- s.read ((char *)&signerIDLength, 1); // signer ID length
+ s.read ((char *)&signerIDLength, 1); // signer ID length
uint64_t contentLength;
- s.read ((char *)&contentLength, 8); // content length
+ s.read ((char *)&contentLength, 8); // content length
contentLength = be64toh (contentLength);
s.seekg (1, std::ios::cur); // unused
uint8_t fileType;
- s.read ((char *)&fileType, 1); // file type
- if (fileType != 0x00) // zip file
+ s.read ((char *)&fileType, 1); // file type
+ if (fileType != 0x00) // zip file
{
LogPrint (eLogError, "Reseed: Can't handle file type ", (int)fileType);
return 0;
}
s.seekg (1, std::ios::cur); // unused
uint8_t contentType;
- s.read ((char *)&contentType, 1); // content type
+ s.read ((char *)&contentType, 1); // content type
if (contentType != 0x03) // reseed data
{
LogPrint (eLogError, "Reseed: Unexpected content type ", (int)contentType);
@@ -688,7 +688,7 @@
{
boost::asio::ip::tcp::endpoint ep = *it;
if ((ep.address ().is_v4 () && i2p::context.SupportsV4 ()) ||
- (ep.address ().is_v6 () && i2p::context.SupportsV6 ()))
+ (ep.address ().is_v6 () && i2p::context.SupportsV6 ()))
{
s.lowest_layer().connect (ep, ecode);
if (!ecode)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/RouterContext.cpp
^
|
@@ -29,7 +29,7 @@
RouterContext::RouterContext ():
m_LastUpdateTime (0), m_AcceptsTunnels (true), m_IsFloodfill (false),
m_ShareRatio (100), m_Status (eRouterStatusUnknown), m_StatusV6 (eRouterStatusUnknown),
- m_Error (eRouterErrorNone), m_NetID (I2PD_NET_ID)
+ m_Error (eRouterErrorNone), m_ErrorV6 (eRouterErrorNone), m_NetID (I2PD_NET_ID)
{
}
@@ -60,20 +60,19 @@
i2p::data::LocalRouterInfo routerInfo;
routerInfo.SetRouterIdentity (GetIdentity ());
uint16_t port; i2p::config::GetOption("port", port);
- if (!port)
- {
- port = rand () % (30777 - 9111) + 9111; // I2P network ports range
- if (port == 9150) port = 9151; // Tor browser
- }
- bool ipv4; i2p::config::GetOption("ipv4", ipv4);
- bool ipv6; i2p::config::GetOption("ipv6", ipv6);
- bool ssu; i2p::config::GetOption("ssu", ssu);
- bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
- bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
- bool nat; i2p::config::GetOption("nat", nat);
+ if (!port) port = SelectRandomPort ();
+ bool ipv4; i2p::config::GetOption("ipv4", ipv4);
+ bool ipv6; i2p::config::GetOption("ipv6", ipv6);
+ bool ssu; i2p::config::GetOption("ssu", ssu);
+ bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
+ bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
+ bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
+ bool nat; i2p::config::GetOption("nat", nat);
if ((ntcp2 || ygg) && !m_NTCP2Keys)
NewNTCP2Keys ();
+ if (ssu2 && !m_SSU2Keys)
+ NewSSU2Keys ();
bool ntcp2Published = false;
if (ntcp2)
{
@@ -84,6 +83,9 @@
if (!ntcp2proxy.empty ()) ntcp2Published = false;
}
}
+ bool ssu2Published = false;
+ if (ssu2)
+ i2p::config::GetOption("ssu2.published", ssu2Published);
uint8_t caps = 0, addressCaps = 0;
if (ipv4)
{
@@ -112,6 +114,20 @@
routerInfo.AddSSUAddress (host.c_str(), port, nullptr);
caps |= i2p::data::RouterInfo::eReachable; // R
}
+ if (ssu2)
+ {
+ if (ssu2Published)
+ {
+ uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
+ if (!ssu2Port) ssu2Port = ssu ? (port + 1) : port;
+ routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v4::from_string (host), ssu2Port);
+ }
+ else
+ {
+ addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4;
+ routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro);
+ }
+ }
}
if (ipv6)
{
@@ -147,6 +163,21 @@
routerInfo.AddSSUAddress (host.c_str(), port, nullptr);
caps |= i2p::data::RouterInfo::eReachable; // R
}
+ if (ssu2)
+ {
+ if (ssu2Published)
+ {
+ uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
+ if (!ssu2Port) ssu2Port = ssu ? (port + 1) : port;
+ routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v6::from_string (host), ssu2Port);
+ }
+ else
+ {
+ if (!ipv4) // no other ssu2 addresses yet
+ routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro);
+ addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6;
+ }
+ }
}
if (ygg)
{
@@ -165,6 +196,13 @@
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
}
+ uint16_t RouterContext::SelectRandomPort () const
+ {
+ uint16_t port = rand () % (30777 - 9111) + 9111; // I2P network ports range
+ if (port == 9150) port = 9151; // Tor browser
+ return port;
+ }
+
void RouterContext::UpdateRouterInfo ()
{
m_RouterInfo.CreateBuffer (m_Keys);
@@ -174,17 +212,37 @@
void RouterContext::NewNTCP2Keys ()
{
- m_StaticKeys.reset (new i2p::crypto::X25519Keys ());
- m_StaticKeys->GenerateKeys ();
+ m_NTCP2StaticKeys.reset (new i2p::crypto::X25519Keys ());
+ m_NTCP2StaticKeys->GenerateKeys ();
m_NTCP2Keys.reset (new NTCP2PrivateKeys ());
- m_StaticKeys->GetPrivateKey (m_NTCP2Keys->staticPrivateKey);
- memcpy (m_NTCP2Keys->staticPublicKey, m_StaticKeys->GetPublicKey (), 32);
+ m_NTCP2StaticKeys->GetPrivateKey (m_NTCP2Keys->staticPrivateKey);
+ memcpy (m_NTCP2Keys->staticPublicKey, m_NTCP2StaticKeys->GetPublicKey (), 32);
RAND_bytes (m_NTCP2Keys->iv, 16);
// save
std::ofstream fk (i2p::fs::DataDirPath (NTCP2_KEYS), std::ofstream::binary | std::ofstream::out);
fk.write ((char *)m_NTCP2Keys.get (), sizeof (NTCP2PrivateKeys));
}
+ void RouterContext::NewSSU2Keys ()
+ {
+ m_SSU2StaticKeys.reset (new i2p::crypto::X25519Keys ());
+ m_SSU2StaticKeys->GenerateKeys ();
+ m_SSU2Keys.reset (new SSU2PrivateKeys ());
+ m_SSU2StaticKeys->GetPrivateKey (m_SSU2Keys->staticPrivateKey);
+ memcpy (m_SSU2Keys->staticPublicKey, m_SSU2StaticKeys->GetPublicKey (), 32);
+ RAND_bytes (m_SSU2Keys->intro, 32);
+ // save
+ std::ofstream fk (i2p::fs::DataDirPath (SSU2_KEYS), std::ofstream::binary | std::ofstream::out);
+ fk.write ((char *)m_SSU2Keys.get (), sizeof (SSU2PrivateKeys));
+ }
+
+ bool RouterContext::IsSSU2Only () const
+ {
+ auto transports = m_RouterInfo.GetCompatibleTransports (false);
+ return (transports & (i2p::data::RouterInfo::eSSU2V4 | i2p::data::RouterInfo::eSSU2V6)) &&
+ !(transports & (i2p::data::RouterInfo::eSSUV4 | i2p::data::RouterInfo::eSSUV6));
+ }
+
void RouterContext::SetStatus (RouterStatus status)
{
if (status != m_Status)
@@ -205,11 +263,18 @@
}
}
+ void RouterContext::SetStatusSSU2 (RouterStatus status)
+ {
+ if (IsSSU2Only ())
+ SetStatus (status);
+ }
+
void RouterContext::SetStatusV6 (RouterStatus status)
{
if (status != m_StatusV6)
{
m_StatusV6 = status;
+ m_ErrorV6 = eRouterErrorNone;
switch (m_StatusV6)
{
case eRouterStatusOK:
@@ -224,12 +289,18 @@
}
}
+ void RouterContext::SetStatusV6SSU2 (RouterStatus status)
+ {
+ if (IsSSU2Only ())
+ SetStatusV6 (status);
+ }
+
void RouterContext::UpdatePort (int port)
{
bool updated = false;
for (auto& address : m_RouterInfo.GetAddresses ())
{
- if (!address->IsNTCP2 () && address->port != port)
+ if (address->port != port && (address->transportStyle == i2p::data::RouterInfo::eTransportSSU || IsSSU2Only ()))
{
address->port = port;
updated = true;
@@ -257,12 +328,7 @@
}
if (isAddr)
{
- if (!port && !address->port)
- {
- // select random port only if address's port is not set
- port = rand () % (30777 - 9111) + 9111; // I2P network ports range
- if (port == 9150) port = 9151; // Tor browser
- }
+ if (!port && !address->port) port = SelectRandomPort ();
if (port) address->port = port;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/RouterContext.h
^
|
@@ -29,6 +29,7 @@
const char ROUTER_INFO[] = "router.info";
const char ROUTER_KEYS[] = "router.keys";
const char NTCP2_KEYS[] = "ntcp2.keys";
+ const char SSU2_KEYS[] = "ssu2.keys";
const int ROUTER_INFO_UPDATE_INTERVAL = 1800; // 30 minutes
enum RouterStatus
@@ -61,6 +62,13 @@
uint8_t iv[16];
};
+ struct SSU2PrivateKeys
+ {
+ uint8_t staticPublicKey[32];
+ uint8_t staticPrivateKey[32];
+ uint8_t intro[32];
+ };
+
public:
RouterContext ();
@@ -78,10 +86,16 @@
return std::shared_ptr<i2p::garlic::GarlicDestination> (this,
[](i2p::garlic::GarlicDestination *) {});
}
+
const uint8_t * GetNTCP2StaticPublicKey () const { return m_NTCP2Keys ? m_NTCP2Keys->staticPublicKey : nullptr; };
const uint8_t * GetNTCP2StaticPrivateKey () const { return m_NTCP2Keys ? m_NTCP2Keys->staticPrivateKey : nullptr; };
const uint8_t * GetNTCP2IV () const { return m_NTCP2Keys ? m_NTCP2Keys->iv : nullptr; };
- i2p::crypto::X25519Keys& GetStaticKeys ();
+ i2p::crypto::X25519Keys& GetNTCP2StaticKeys ();
+
+ const uint8_t * GetSSU2StaticPublicKey () const { return m_SSU2Keys ? m_SSU2Keys->staticPublicKey : nullptr; };
+ const uint8_t * GetSSU2StaticPrivateKey () const { return m_SSU2Keys ? m_SSU2Keys->staticPrivateKey : nullptr; };
+ const uint8_t * GetSSU2IntroKey () const { return m_SSU2Keys ? m_SSU2Keys->intro : nullptr; };
+ i2p::crypto::X25519Keys& GetSSU2StaticKeys ();
uint32_t GetUptime () const; // in seconds
uint64_t GetLastUpdateTime () const { return m_LastUpdateTime; };
@@ -89,10 +103,14 @@
uint64_t GetTransitBandwidthLimit () const { return (m_BandwidthLimit*m_ShareRatio)/100LL; };
RouterStatus GetStatus () const { return m_Status; };
void SetStatus (RouterStatus status);
+ void SetStatusSSU2 (RouterStatus status);
RouterError GetError () const { return m_Error; };
void SetError (RouterError error) { m_Status = eRouterStatusError; m_Error = error; };
RouterStatus GetStatusV6 () const { return m_StatusV6; };
void SetStatusV6 (RouterStatus status);
+ void SetStatusV6SSU2 (RouterStatus status);
+ RouterError GetErrorV6 () const { return m_ErrorV6; };
+ void SetErrorV6 (RouterError error) { m_StatusV6 = eRouterStatusError; m_ErrorV6 = error; };
int GetNetID () const { return m_NetID; };
void SetNetID (int netID) { m_NetID = netID; };
bool DecryptTunnelBuildRecord (const uint8_t * encrypted, uint8_t * data);
@@ -102,11 +120,18 @@
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
void PublishNTCP2Address (int port, bool publish, bool v4, bool v6, bool ygg);
void UpdateNTCP2Address (bool enable);
+ void PublishSSU2Address (int port, bool publish, bool v4, bool v6);
+ void UpdateSSU2Address (bool enable);
void RemoveNTCPAddress (bool v4only = true); // delete NTCP address for older routers. TODO: remove later
+ void RemoveSSUAddress (); // delete SSU address for older routers
bool AddIntroducer (const i2p::data::RouterInfo::Introducer& introducer);
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
+ bool AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4);
+ void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4);
+ void ClearSSU2Introducers (bool v4);
bool IsUnreachable () const;
void SetUnreachable (bool v4, bool v6);
+ void SetUnreachableSSU2 (bool v4, bool v6);
void SetReachable (bool v4, bool v6);
bool IsFloodfill () const { return m_IsFloodfill; };
void SetFloodfill (bool floodfill);
@@ -123,6 +148,7 @@
void SetSupportsV6 (bool supportsV6);
void SetSupportsV4 (bool supportsV4);
void SetSupportsMesh (bool supportsmesh, const boost::asio::ip::address_v6& host);
+ void SetMTU (int mtu, bool v4);
i2p::crypto::NoiseSymmetricState& GetCurrentNoiseState () { return m_CurrentNoiseState; };
void UpdateNTCP2V6Address (const boost::asio::ip::address& host); // called from Daemon. TODO: remove
@@ -156,8 +182,11 @@
void NewRouterInfo ();
void UpdateRouterInfo ();
void NewNTCP2Keys ();
+ void NewSSU2Keys ();
+ bool IsSSU2Only () const; // SSU2 and no SSU
bool Load ();
void SaveKeys ();
+ uint16_t SelectRandomPort () const;
bool DecryptECIESTunnelBuildRecord (const uint8_t * encrypted, uint8_t * data, size_t clearTextSize);
@@ -173,11 +202,12 @@
uint64_t m_BandwidthLimit; // allowed bandwidth
int m_ShareRatio;
RouterStatus m_Status, m_StatusV6;
- RouterError m_Error;
+ RouterError m_Error, m_ErrorV6;
int m_NetID;
std::mutex m_GarlicMutex;
std::unique_ptr<NTCP2PrivateKeys> m_NTCP2Keys;
- std::unique_ptr<i2p::crypto::X25519Keys> m_StaticKeys;
+ std::unique_ptr<SSU2PrivateKeys> m_SSU2Keys;
+ std::unique_ptr<i2p::crypto::X25519Keys> m_NTCP2StaticKeys, m_SSU2StaticKeys;
// for ECIESx25519
i2p::crypto::NoiseSymmetricState m_InitialNoiseState, m_CurrentNoiseState;
};
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/RouterInfo.cpp
^
|
@@ -33,26 +33,27 @@
{
if (len > size ()) len = size ();
memcpy (data (), buf, len);
- }
-
+ }
+
RouterInfo::RouterInfo (): m_Buffer (nullptr)
{
m_Addresses = boost::make_shared<Addresses>(); // create empty list
}
RouterInfo::RouterInfo (const std::string& fullPath):
- m_IsUpdated (false), m_IsUnreachable (false),
- m_SupportedTransports (0),m_ReachableTransports (0),
+ m_FamilyID (0), m_IsUpdated (false), m_IsUnreachable (false),
+ m_SupportedTransports (0),m_ReachableTransports (0),
m_Caps (0), m_Version (0)
{
m_Addresses = boost::make_shared<Addresses>(); // create empty list
- m_Buffer = netdb.NewRouterInfoBuffer ();
+ m_Buffer = NewBuffer (); // always RouterInfo's
ReadFromFile (fullPath);
}
RouterInfo::RouterInfo (std::shared_ptr<Buffer>&& buf, size_t len):
- m_IsUpdated (true), m_IsUnreachable (false), m_SupportedTransports (0),
- m_ReachableTransports (0), m_Caps (0), m_Version (0)
+ m_FamilyID (0), m_IsUpdated (true), m_IsUnreachable (false),
+ m_SupportedTransports (0), m_ReachableTransports (0),
+ m_Caps (0), m_Version (0)
{
if (len <= MAX_RI_BUFFER_SIZE)
{
@@ -67,12 +68,12 @@
m_Buffer = nullptr;
m_IsUnreachable = true;
}
- }
-
+ }
+
RouterInfo::RouterInfo (const uint8_t * buf, size_t len):
RouterInfo (std::make_shared<Buffer> (buf, len), len)
{
- }
+ }
RouterInfo::~RouterInfo ()
{
@@ -134,7 +135,7 @@
}
s.seekg(0, std::ios::beg);
if (!m_Buffer)
- m_Buffer = netdb.NewRouterInfoBuffer ();
+ m_Buffer = NewBuffer ();
s.read((char *)m_Buffer->data (), m_BufferLen);
}
else
@@ -159,7 +160,7 @@
{
m_IsUnreachable = true;
return;
- }
+ }
m_RouterIdentity = std::make_shared<IdentityEx>(m_Buffer->data (), m_BufferLen);
size_t identityLen = m_RouterIdentity->GetFullLen ();
if (identityLen >= m_BufferLen)
@@ -216,14 +217,15 @@
uint8_t cost; // ignore
s.read ((char *)&cost, sizeof (cost));
s.read ((char *)&address->date, sizeof (address->date));
- bool isHost = false, isIntroKey = false, isStaticKey = false;
+ bool isHost = false, isIntroKey = false, isStaticKey = false, isV2 = false;
+ Tag<32> iV2; // for 'i' field in SSU, TODO: remove later
char transportStyle[6];
ReadString (transportStyle, 6, s);
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
address->transportStyle = eTransportNTCP;
- else if (!strcmp (transportStyle, "SSU"))
+ else if (!strncmp (transportStyle, "SSU", 3)) // SSU or SSU2
{
- address->transportStyle = eTransportSSU;
+ address->transportStyle = (transportStyle[3] == '2') ? eTransportSSU2 : eTransportSSU;
address->ssu.reset (new SSUExt ());
address->ssu->mtu = 0;
}
@@ -234,6 +236,12 @@
uint16_t size, r = 0;
s.read ((char *)&size, sizeof (size)); if (!s) return;
size = be16toh (size);
+ if (address->transportStyle == eTransportUnknown)
+ {
+ // skip unknown address
+ s.seekg (size, std::ios_base::cur);
+ if (s) continue; else return;
+ }
while (r < size)
{
char key[255], value[255];
@@ -266,15 +274,29 @@
}
else if (!strcmp (key, "caps"))
address->caps = ExtractAddressCaps (value);
- else if (!strcmp (key, "s")) // ntcp2 static key
+ else if (!strcmp (key, "s")) // ntcp2 or ssu2 static key
{
Base64ToByteStream (value, strlen (value), address->s, 32);
isStaticKey = true;
}
- else if (!strcmp (key, "i")) // ntcp2 iv
+ else if (!strcmp (key, "i")) // ntcp2 iv or ssu2 intro
+ {
+ if (address->IsNTCP2 ())
+ {
+ Base64ToByteStream (value, strlen (value), address->i, 16);
+ address->published = true; // presence of "i" means "published" NTCP2
+ }
+ else if (address->IsSSU2 ())
+ Base64ToByteStream (value, strlen (value), address->i, 32);
+ else
+ Base64ToByteStream (value, strlen (value), iV2, 32);
+ }
+ else if (!strcmp (key, "v"))
{
- Base64ToByteStream (value, strlen (value), address->i, 16);
- address->published = true; // presence if "i" means "published"
+ if (!strcmp (value, "2"))
+ isV2 = true;
+ else
+ LogPrint (eLogWarning, "RouterInfo: Unexpected value ", value, " for v");
}
else if (key[0] == 'i')
{
@@ -308,7 +330,7 @@
introducer.iPort = boost::lexical_cast<int>(value);
else if (!strcmp (key, "itag"))
introducer.iTag = boost::lexical_cast<uint32_t>(value);
- else if (!strcmp (key, "ikey"))
+ else if (!strcmp (key, "ikey") || !strcmp (key, "ih"))
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
else if (!strcmp (key, "iexp"))
introducer.iExp = boost::lexical_cast<uint32_t>(value);
@@ -322,7 +344,7 @@
if (isHost)
{
if (address->host.is_v6 ())
- supportedTransports |= (i2p::util::net::IsYggdrasilAddress (address->host) ? eNTCP2V6Mesh : eNTCP2V6);
+ supportedTransports |= (i2p::util::net::IsYggdrasilAddress (address->host) ? eNTCP2V6Mesh : eNTCP2V6);
else
supportedTransports |= eNTCP2V4;
m_ReachableTransports |= supportedTransports;
@@ -344,7 +366,7 @@
if (isIntroKey)
{
if (isHost)
- supportedTransports |= address->host.is_v4 () ? eSSUV4 : eSSUV6;
+ supportedTransports |= address->host.is_v4 () ? eSSUV4 : eSSUV6;
else if (address->caps & AddressCaps::eV6)
{
supportedTransports |= eSSUV6;
@@ -361,10 +383,13 @@
{
if (!it.iExp) it.iExp = m_Timestamp/1000 + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT;
if (ts <= it.iExp && it.iPort > 0 &&
- ((it.iHost.is_v4 () && address->IsV4 ()) || (it.iHost.is_v6 () && address->IsV6 ())))
+ ((it.iHost.is_v4 () && address->IsV4 ()) || (it.iHost.is_v6 () && address->IsV6 ())))
numValid++;
else
+ {
it.iPort = 0;
+ if (isV2) numValid++;
+ }
}
if (numValid)
m_ReachableTransports |= supportedTransports;
@@ -378,7 +403,59 @@
}
}
}
- if (supportedTransports)
+ if (address->transportStyle == eTransportSSU2 || (isV2 && address->transportStyle == eTransportSSU))
+ {
+ if (address->IsV4 ()) supportedTransports |= eSSU2V4;
+ if (address->IsV6 ()) supportedTransports |= eSSU2V6;
+ if (address->port)
+ {
+ if (address->host.is_v4 ()) m_ReachableTransports |= eSSU2V4;
+ if (address->host.is_v6 ()) m_ReachableTransports |= eSSU2V6;
+ }
+ if (address->transportStyle == eTransportSSU2)
+ {
+ if (address->port) address->published = true;
+ if (address->ssu && !address->ssu->introducers.empty ())
+ {
+ // exclude invalid introducers
+ uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
+ int numValid = 0;
+ for (auto& it: address->ssu->introducers)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/RouterInfo.h
^
|
@@ -19,6 +19,7 @@
#include <boost/shared_ptr.hpp>
#include "Identity.h"
#include "Profiling.h"
+#include "Family.h"
namespace i2p
{
@@ -51,10 +52,12 @@
const uint8_t COST_NTCP2_PUBLISHED = 3;
const uint8_t COST_NTCP2_NON_PUBLISHED = 14;
+ const uint8_t COST_SSU2_DIRECT = 8;
const uint8_t COST_SSU_DIRECT = 9;
const uint8_t COST_SSU_THROUGH_INTRODUCERS = 11;
+ const uint8_t COST_SSU2_NON_PUBLISHED = 15;
- const size_t MAX_RI_BUFFER_SIZE = 2048; // if RouterInfo exceeds 2048 we consider it as malformed, might be changed later
+ const size_t MAX_RI_BUFFER_SIZE = 3072; // if RouterInfo exceeds 3K we consider it as malformed, might extend later
class RouterInfo: public RoutingDestination
{
public:
@@ -66,6 +69,8 @@
eSSUV4 = 0x04,
eSSUV6 = 0x08,
eNTCP2V6Mesh = 0x10,
+ eSSU2V4 = 0x20,
+ eSSU2V6 = 0x40,
eAllTransports = 0xFF
};
typedef uint8_t CompatibleTransports;
@@ -92,7 +97,8 @@
{
eTransportUnknown = 0,
eTransportNTCP,
- eTransportSSU
+ eTransportSSU,
+ eTransportSSU2
};
typedef Tag<32> IntroKey; // should be castable to MacKey and AESKey
@@ -101,7 +107,7 @@
Introducer (): iPort (0), iExp (0) {};
boost::asio::ip::address iHost;
int iPort;
- IntroKey iKey;
+ IntroKey iKey; // or ih for SSU2
uint32_t iTag;
uint32_t iExp;
};
@@ -131,7 +137,7 @@
bool operator==(const Address& other) const
{
- return transportStyle == other.transportStyle && IsNTCP2 () == other.IsNTCP2 () &&
+ return transportStyle == other.transportStyle &&
host == other.host && port == other.port;
}
@@ -140,10 +146,11 @@
return !(*this == other);
}
- bool IsNTCP2 () const { return transportStyle == eTransportNTCP; };
+ bool IsNTCP2 () const { return transportStyle == eTransportNTCP; };
+ bool IsSSU2 () const { return transportStyle == eTransportSSU2; };
bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; };
- bool IsReachableSSU () const { return (bool)ssu && (published || !ssu->introducers.empty ()); };
- bool UsesIntroducer () const { return (bool)ssu && !ssu->introducers.empty (); };
+ bool IsReachableSSU () const { return (bool)ssu && (published || UsesIntroducer ()); };
+ bool UsesIntroducer () const { return (bool)ssu && !ssu->introducers.empty (); };
bool IsIntroducer () const { return caps & eSSUIntroducer; };
bool IsPeerTesting () const { return caps & eSSUTesting; };
@@ -159,7 +166,7 @@
Buffer () = default;
Buffer (const uint8_t * buf, size_t len);
};
-
+
typedef std::vector<std::shared_ptr<Address> > Addresses;
RouterInfo (const std::string& fullPath);
@@ -174,19 +181,26 @@
std::string GetIdentHashBase64 () const { return GetIdentHash ().ToBase64 (); };
uint64_t GetTimestamp () const { return m_Timestamp; };
int GetVersion () const { return m_Version; };
- virtual void SetProperty (const std::string& key, const std::string& value) {};
+ virtual void SetProperty (const std::string& key, const std::string& value) {};
virtual void ClearProperties () {};
Addresses& GetAddresses () { return *m_Addresses; }; // should be called for local RI only, otherwise must return shared_ptr
std::shared_ptr<const Address> GetNTCP2AddressWithStaticKey (const uint8_t * key) const;
+ std::shared_ptr<const Address> GetSSU2AddressWithStaticKey (const uint8_t * key, bool isV6) const;
std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const;
std::shared_ptr<const Address> GetPublishedNTCP2V6Address () const;
std::shared_ptr<const Address> GetSSUAddress (bool v4only = true) const;
std::shared_ptr<const Address> GetSSUV6Address () const;
std::shared_ptr<const Address> GetYggdrasilAddress () const;
+ std::shared_ptr<const Address> GetSSU2V4Address () const;
+ std::shared_ptr<const Address> GetSSU2V6Address () const;
+ std::shared_ptr<const Address> GetSSU2Address (bool v4) const;
void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0);
void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,
const boost::asio::ip::address& host = boost::asio::ip::address(), int port = 0, uint8_t caps = 0);
+ void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, uint8_t caps = 0); // non published
+ void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey,
+ const boost::asio::ip::address& host, int port); // published
bool AddIntroducer (const Introducer& introducer);
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
@@ -195,12 +209,14 @@
bool IsReachable () const { return m_Caps & Caps::eReachable; };
bool IsECIES () const { return m_RouterIdentity->GetCryptoKeyType () == i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD; };
bool IsSSU (bool v4only = true) const;
- bool IsSSUV6 () const;
+ bool IsSSUV6 () const { return m_SupportedTransports & eSSUV6; };
bool IsNTCP2 (bool v4only = true) const;
- bool IsNTCP2V6 () const;
- bool IsV6 () const;
- bool IsV4 () const;
- bool IsMesh () const;
+ bool IsNTCP2V6 () const { return m_SupportedTransports & eNTCP2V6; };
+ bool IsSSU2V4 () const { return m_SupportedTransports & eSSU2V4; };
+ bool IsSSU2V6 () const { return m_SupportedTransports & eSSU2V6; };
+ bool IsV6 () const { return m_SupportedTransports & (eSSUV6 | eNTCP2V6 | eSSU2V6); };
+ bool IsV4 () const { return m_SupportedTransports & (eSSUV4 | eNTCP2V4 | eSSU2V4); };
+ bool IsMesh () const { return m_SupportedTransports & eNTCP2V6Mesh; };
void EnableV6 ();
void DisableV6 ();
void EnableV4 ();
@@ -217,7 +233,9 @@
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
bool IsEligibleFloodfill () const;
bool IsPeerTesting (bool v4) const;
+ bool IsSSU2PeerTesting (bool v4) const;
bool IsIntroducer (bool v4) const;
+ bool IsSSU2Introducer (bool v4) const;
uint8_t GetCaps () const { return m_Caps; };
void SetCaps (uint8_t caps) { m_Caps = caps; };
@@ -241,7 +259,7 @@
bool IsNewer (const uint8_t * buf, size_t len) const;
/** return true if we are in a router family and the signature is valid */
- bool IsFamily(const std::string & fam) const;
+ bool IsFamily (FamilyID famid) const;
// implements RoutingDestination
std::shared_ptr<const IdentityEx> GetIdentity () const { return m_RouterIdentity; };
@@ -257,7 +275,9 @@
void SetBufferLen (size_t len) { m_BufferLen = len; };
void RefreshTimestamp ();
const Addresses& GetAddresses () const { return *m_Addresses; };
-
+ CompatibleTransports GetReachableTransports () const { return m_ReachableTransports; };
+ void SetReachableTransports (CompatibleTransports transports) { m_ReachableTransports = transports; };
+
private:
bool LoadFile (const std::string& fullPath);
@@ -269,10 +289,11 @@
uint8_t ExtractAddressCaps (const char * value) const;
template<typename Filter>
std::shared_ptr<const Address> GetAddress (Filter filter) const;
+ virtual std::shared_ptr<Buffer> NewBuffer () const;
private:
- std::string m_Family;
+ FamilyID m_FamilyID;
std::shared_ptr<const IdentityEx> m_RouterIdentity;
std::shared_ptr<Buffer> m_Buffer;
size_t m_BufferLen;
@@ -293,21 +314,25 @@
void CreateBuffer (const PrivateKeys& privateKeys);
void UpdateCaps (uint8_t caps);
- void SetProperty (const std::string& key, const std::string& value) override;
- void DeleteProperty (const std::string& key);
- std::string GetProperty (const std::string& key) const;
+ void SetProperty (const std::string& key, const std::string& value) override;
+ void DeleteProperty (const std::string& key);
+ std::string GetProperty (const std::string& key) const;
void ClearProperties () override { m_Properties.clear (); };
+
+ bool AddSSU2Introducer (const Introducer& introducer, bool v4);
+ bool RemoveSSU2Introducer (const IdentHash& h, bool v4);
private:
void WriteToStream (std::ostream& s) const;
void UpdateCapsProperty ();
void WriteString (const std::string& str, std::ostream& s) const;
-
+ std::shared_ptr<Buffer> NewBuffer () const override;
+
private:
- std::map<std::string, std::string> m_Properties;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSU.cpp
^
|
@@ -15,7 +15,7 @@
#include "util.h"
#include "SSU.h"
-#ifdef __linux__
+#if defined(__linux__) && !defined(_NETINET_IN_H)
#include <linux/in6.h>
#endif
@@ -68,7 +68,7 @@
m_SocketV6.set_option (boost::asio::ip::v6_only (true));
m_SocketV6.set_option (boost::asio::socket_base::receive_buffer_size (SSU_SOCKET_RECEIVE_BUFFER_SIZE));
m_SocketV6.set_option (boost::asio::socket_base::send_buffer_size (SSU_SOCKET_SEND_BUFFER_SIZE));
-#ifdef __linux__
+#if defined(__linux__) && !defined(_NETINET_IN_H)
if (m_EndpointV6.address() == boost::asio::ip::address().from_string("::")) // only if not binded to address
{
// Set preference to use public IPv6 address -- tested on linux, not works on windows, and not tested on others
@@ -273,14 +273,14 @@
void SSUServer::HandleReceivedFrom (const boost::system::error_code& ecode, std::size_t bytes_transferred, SSUPacket * packet)
{
if (!ecode
- || ecode == boost::asio::error::connection_refused
- || ecode == boost::asio::error::connection_reset
- || ecode == boost::asio::error::network_unreachable
- || ecode == boost::asio::error::host_unreachable
+ || ecode == boost::asio::error::connection_refused
+ || ecode == boost::asio::error::connection_reset
+ || ecode == boost::asio::error::network_unreachable
+ || ecode == boost::asio::error::host_unreachable
#ifdef _WIN32 // windows can throw WinAPI error, which is not handled by ASIO
- || ecode.value() == boost::winapi::ERROR_CONNECTION_REFUSED_
- || ecode.value() == boost::winapi::ERROR_NETWORK_UNREACHABLE_
- || ecode.value() == boost::winapi::ERROR_HOST_UNREACHABLE_
+ || ecode.value() == boost::winapi::ERROR_CONNECTION_REFUSED_
+ || ecode.value() == boost::winapi::ERROR_NETWORK_UNREACHABLE_
+ || ecode.value() == boost::winapi::ERROR_HOST_UNREACHABLE_
#endif
)
// just try continue reading when received ICMP response otherwise socket can crash,
@@ -332,14 +332,14 @@
void SSUServer::HandleReceivedFromV6 (const boost::system::error_code& ecode, std::size_t bytes_transferred, SSUPacket * packet)
{
if (!ecode
- || ecode == boost::asio::error::connection_refused
- || ecode == boost::asio::error::connection_reset
- || ecode == boost::asio::error::network_unreachable
- || ecode == boost::asio::error::host_unreachable
+ || ecode == boost::asio::error::connection_refused
+ || ecode == boost::asio::error::connection_reset
+ || ecode == boost::asio::error::network_unreachable
+ || ecode == boost::asio::error::host_unreachable
#ifdef _WIN32 // windows can throw WinAPI error, which is not handled by ASIO
- || ecode.value() == boost::winapi::ERROR_CONNECTION_REFUSED_
- || ecode.value() == boost::winapi::ERROR_NETWORK_UNREACHABLE_
- || ecode.value() == boost::winapi::ERROR_HOST_UNREACHABLE_
+ || ecode.value() == boost::winapi::ERROR_CONNECTION_REFUSED_
+ || ecode.value() == boost::winapi::ERROR_NETWORK_UNREACHABLE_
+ || ecode.value() == boost::winapi::ERROR_HOST_UNREACHABLE_
#endif
)
// just try continue reading when received ICMP response otherwise socket can crash,
@@ -582,7 +582,7 @@
"] through introducer ", introducer->iHost, ":", introducer->iPort);
session->WaitForIntroduction ();
if ((address->host.is_v4 () && i2p::context.GetStatus () == eRouterStatusFirewalled) ||
- (address->host.is_v6 () && i2p::context.GetStatusV6 () == eRouterStatusFirewalled))
+ (address->host.is_v6 () && i2p::context.GetStatusV6 () == eRouterStatusFirewalled))
{
uint8_t buf[1];
Send (buf, 0, remoteEndpoint); // send HolePunch
@@ -676,7 +676,7 @@
for (const auto& s : sessions)
{
if (s.second->GetRelayTag () && s.second->GetState () == eSessionStateEstablished &&
- ts < s.second->GetCreationTime () + SSU_TO_INTRODUCER_SESSION_EXPIRATION)
+ ts < s.second->GetCreationTime () + SSU_TO_INTRODUCER_SESSION_EXPIRATION)
ret.push_back (s.second);
else if (s.second->GetRemoteIdentity ())
excluded.insert (s.second->GetRemoteIdentity ()->GetIdentHash ());
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSU2.cpp
^
|
@@ -6,75 +6,1026 @@
* See full license text in LICENSE file at top of project tree
*/
-#include <string.h>
-#include <openssl/rand.h>
+#include <random>
+#include "Log.h"
+#include "RouterContext.h"
#include "Transports.h"
+#include "NetDb.hpp"
+#include "Config.h"
#include "SSU2.h"
namespace i2p
{
namespace transport
-{
- SSU2Session::SSU2Session (std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter,
- std::shared_ptr<const i2p::data::RouterInfo::Address> addr, bool peerTest):
- TransportSession (in_RemoteRouter, SSU2_TERMINATION_TIMEOUT),
- m_Address (addr)
- {
- m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState);
- if (in_RemoteRouter && addr)
- {
- // outgoing
- InitNoiseXKState1 (*m_NoiseState, addr->s);
- }
- }
-
- SSU2Session::~SSU2Session ()
- {
- }
-
- void SSU2Session::SendSessionRequest ()
- {
- m_EphemeralKeys = i2p::transport::transports.GetNextX25519KeysPair ();
- m_NoiseState->MixHash (m_EphemeralKeys->GetPublicKey (), 32);
- uint8_t sharedSecret[32];
- m_EphemeralKeys->Agree (m_Address->s, sharedSecret);
- m_NoiseState->MixKey (sharedSecret);
-
- Header header;
- uint8_t headerX[48], payload[1200]; // TODO: correct payload size
- size_t payloadSize = 8;
- // fill packet
- RAND_bytes (header.h.connID, 8);
- memset (header.h.packetNum, 0, 4);
- header.h.type = eSSU2SessionRequest;
- header.h.flags[0] = 2; // ver
- header.h.flags[1] = 2; // netID TODO:
- header.h.flags[2] = 0; // flag
- RAND_bytes (headerX, 8); // source id
- memset (headerX + 8, 0, 8); // token
- memcpy (headerX + 16, m_EphemeralKeys->GetPublicKey (), 32); // X
- // encrypt
- const uint8_t nonce[12] = {0};
- i2p::crypto::AEADChaCha20Poly1305 (payload, payloadSize, m_NoiseState->m_H, 32, m_NoiseState->m_CK + 32, nonce, payload, payloadSize + 16, true);
- payloadSize += 16;
- CreateHeaderMask (m_Address->i, payload + (payloadSize - 24), m_Address->i, payload + (payloadSize - 12));
- EncryptHeader (header);
- i2p::crypto::ChaCha20 (headerX, 48, m_Address->i, nonce, headerX);
+{
+ SSU2Server::SSU2Server ():
+ RunnableServiceWithWork ("SSU2"), m_ReceiveService ("SSU2r"),
+ m_SocketV4 (m_ReceiveService.GetService ()), m_SocketV6 (m_ReceiveService.GetService ()),
+ m_AddressV4 (boost::asio::ip::address_v4()), m_AddressV6 (boost::asio::ip::address_v6()),
+ m_TerminationTimer (GetService ()), m_ResendTimer (GetService ()),
+ m_IntroducersUpdateTimer (GetService ()), m_IntroducersUpdateTimerV6 (GetService ()),
+ m_IsPublished (true), m_IsSyncClockFromPeers (true)
+ {
+ }
+
+ void SSU2Server::Start ()
+ {
+ if (!IsRunning ())
+ {
+ StartIOService ();
+ i2p::config::GetOption ("ssu2.published", m_IsPublished);
+ i2p::config::GetOption("nettime.frompeers", m_IsSyncClockFromPeers);
+ bool found = false;
+ auto& addresses = i2p::context.GetRouterInfo ().GetAddresses ();
+ for (const auto& address: addresses)
+ {
+ if (!address) continue;
+ if (address->transportStyle == i2p::data::RouterInfo::eTransportSSU2)
+ {
+ auto port = address->port;
+ if (!port)
+ {
+ uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
+ if (ssu2Port) port = ssu2Port;
+ else
+ {
+ bool ssu; i2p::config::GetOption("ssu", ssu);
+ uint16_t p; i2p::config::GetOption ("port", p);
+ if (p) port = ssu ? (p + 1) : p;
+ }
+ }
+ if (port)
+ {
+ if (address->IsV4 ())
+ {
+ found = true;
+ OpenSocket (boost::asio::ip::udp::endpoint (m_AddressV4, port));
+ m_ReceiveService.GetService ().post(
+ [this]()
+ {
+ Receive (m_SocketV4);
+ });
+ ScheduleIntroducersUpdateTimer (); // wait for 30 seconds and decide if we need introducers
+ }
+ if (address->IsV6 ())
+ {
+ found = true;
+ OpenSocket (boost::asio::ip::udp::endpoint (m_AddressV6, port));
+ m_ReceiveService.GetService ().post(
+ [this]()
+ {
+ Receive (m_SocketV6);
+ });
+ ScheduleIntroducersUpdateTimerV6 (); // wait for 30 seconds and decide if we need introducers
+ }
+ }
+ else
+ LogPrint (eLogError, "SSU2: Can't start server because port not specified");
+ }
+ }
+ if (found)
+ m_ReceiveService.Start ();
+ ScheduleTermination ();
+ }
+ }
+
+ void SSU2Server::Stop ()
+ {
+ if (IsRunning ())
+ {
+ m_TerminationTimer.cancel ();
+ m_ResendTimer.cancel ();
+ m_IntroducersUpdateTimer.cancel ();
+ m_IntroducersUpdateTimerV6.cancel ();
+ }
+
+ auto sessions = m_Sessions;
+ for (auto& it: sessions)
+ {
+ it.second->RequestTermination (eSSU2TerminationReasonRouterShutdown);
+ it.second->Done ();
+ }
+ if (context.SupportsV4 () || context.SupportsV6 ())
+ m_ReceiveService.Stop ();
+ m_SocketV4.close ();
+ m_SocketV6.close ();
+
+ StopIOService ();
+
+ m_Sessions.clear ();
+ m_SessionsByRouterHash.clear ();
+ m_PendingOutgoingSessions.clear ();
+ m_Relays.clear ();
+ m_Introducers.clear ();
+ m_IntroducersV6.clear ();
+ }
+
+ void SSU2Server::SetLocalAddress (const boost::asio::ip::address& localAddress)
+ {
+ if (localAddress.is_unspecified ()) return;
+ if (localAddress.is_v4 ())
+ {
+ m_AddressV4 = localAddress;
+ int mtu = i2p::util::net::GetMTU (localAddress);
+ if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
+ if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
+ i2p::context.SetMTU (mtu, true);
+ }
+ else if (localAddress.is_v6 ())
+ {
+ m_AddressV6 = localAddress;
+ int maxMTU = i2p::util::net::GetMaxMTU (localAddress.to_v6 ());
+ int mtu = i2p::util::net::GetMTU (localAddress);
+ if (mtu > maxMTU) mtu = maxMTU;
+ if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
+ i2p::context.SetMTU (mtu, false);
+ }
+ }
+
+ bool SSU2Server::IsSupported (const boost::asio::ip::address& addr) const
+ {
+ if (addr.is_v4 ())
+ {
+ if (m_SocketV4.is_open ())
+ return true;
+ }
+ else if (addr.is_v6 ())
+ {
+ if (m_SocketV6.is_open ())
+ return true;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSU2.h
^
|
@@ -9,60 +9,135 @@
#ifndef SSU2_H__
#define SSU2_H__
-#include <memory>
-#include "Crypto.h"
-#include "RouterInfo.h"
-#include "TransportSession.h"
+#include <unordered_map>
+#include "util.h"
+#include "SSU2Session.h"
namespace i2p
{
namespace transport
{
- const int SSU2_TERMINATION_TIMEOUT = 330; // 5.5 minutes
-
- enum SSU2MessageType
- {
- eSSU2SessionRequest = 0
- };
-
- class SSU2Session: public TransportSession, public std::enable_shared_from_this<SSU2Session>
+ const int SSU2_TERMINATION_CHECK_TIMEOUT = 30; // in seconds
+ const int SSU2_RESEND_CHECK_TIMEOUT = 500; // in milliseconds
+ const size_t SSU2_SOCKET_RECEIVE_BUFFER_SIZE = 0x1FFFF; // 128K
+ const size_t SSU2_SOCKET_SEND_BUFFER_SIZE = 0x1FFFF; // 128K
+ const size_t SSU2_MAX_NUM_INTRODUCERS = 3;
+ const int SSU2_TO_INTRODUCER_SESSION_DURATION = 3600; // 1 hour
+ const int SSU2_TO_INTRODUCER_SESSION_EXPIRATION = 4800; // 80 minutes
+ const int SSU2_KEEP_ALIVE_INTERVAL = 30; // 30 seconds
+
+ class SSU2Server: private i2p::util::RunnableServiceWithWork
{
- union Header
+ struct Packet
{
- uint64_t ll[2];
- uint8_t buf[16];
- struct
- {
- uint8_t connID[8];
- uint8_t packetNum[4];
- uint8_t type;
- uint8_t flags[3];
- } h;
+ uint8_t buf[SSU2_MAX_PACKET_SIZE];
+ size_t len;
+ boost::asio::ip::udp::endpoint from;
};
-
+
+ class ReceiveService: public i2p::util::RunnableService
+ {
+ public:
+
+ ReceiveService (const std::string& name): RunnableService (name) {};
+ boost::asio::io_service& GetService () { return GetIOService (); };
+ void Start () { StartIOService (); };
+ void Stop () { StopIOService (); };
+ };
+
public:
- SSU2Session (std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter = nullptr,
- std::shared_ptr<const i2p::data::RouterInfo::Address> addr = nullptr, bool peerTest = false);
- ~SSU2Session ();
+ SSU2Server ();
+ ~SSU2Server () {};
- private:
+ void Start ();
+ void Stop ();
+ boost::asio::io_service& GetService () { return GetIOService (); };
+ void SetLocalAddress (const boost::asio::ip::address& localAddress);
+ bool IsSupported (const boost::asio::ip::address& addr) const;
+ uint16_t GetPort (bool v4) const;
+ bool IsSyncClockFromPeers () const { return m_IsSyncClockFromPeers; };
+
+ void AddSession (std::shared_ptr<SSU2Session> session);
+ void RemoveSession (uint64_t connID);
+ void AddSessionByRouterHash (std::shared_ptr<SSU2Session> session);
+ bool AddPendingOutgoingSession (std::shared_ptr<SSU2Session> session);
+ void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);
+ std::shared_ptr<SSU2Session> FindSession (const i2p::data::IdentHash& ident) const;
+ std::shared_ptr<SSU2Session> FindPendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep) const;
+ std::shared_ptr<SSU2Session> GetRandomSession (i2p::data::RouterInfo::CompatibleTransports remoteTransports,
+ const i2p::data::IdentHash& excluded) const;
+
+ void AddRelay (uint32_t tag, std::shared_ptr<SSU2Session> relay);
+ void RemoveRelay (uint32_t tag);
+ std::shared_ptr<SSU2Session> FindRelaySession (uint32_t tag);
+
+ void Send (const uint8_t * header, size_t headerLen, const uint8_t * payload, size_t payloadLen,
+ const boost::asio::ip::udp::endpoint& to);
+ void Send (const uint8_t * header, size_t headerLen, const uint8_t * headerX, size_t headerXLen,
+ const uint8_t * payload, size_t payloadLen, const boost::asio::ip::udp::endpoint& to);
+
+ bool CreateSession (std::shared_ptr<const i2p::data::RouterInfo> router,
+ std::shared_ptr<const i2p::data::RouterInfo::Address> address, bool peerTest = false);
+ bool StartPeerTest (std::shared_ptr<const i2p::data::RouterInfo> router, bool v4);
+
+ void UpdateOutgoingToken (const boost::asio::ip::udp::endpoint& ep, uint64_t token, uint32_t exp);
+ uint64_t FindOutgoingToken (const boost::asio::ip::udp::endpoint& ep) const;
+ uint64_t GetIncomingToken (const boost::asio::ip::udp::endpoint& ep);
+ std::pair<uint64_t, uint32_t> NewIncomingToken (const boost::asio::ip::udp::endpoint& ep);
+
+ void RescheduleIntroducersUpdateTimer ();
+ void RescheduleIntroducersUpdateTimerV6 ();
- void SendSessionRequest ();
- void EncryptHeader (Header& h);
- void CreateHeaderMask (const uint8_t * kh1, const uint8_t * nonce1, const uint8_t * kh2, const uint8_t * nonce2);
+ i2p::util::MemoryPool<SSU2SentPacket>& GetSentPacketsPool () { return m_SentPacketsPool; };
private:
- std::shared_ptr<i2p::crypto::X25519Keys> m_EphemeralKeys;
- std::unique_ptr<i2p::crypto::NoiseSymmetricState> m_NoiseState;
- std::shared_ptr<const i2p::data::RouterInfo::Address> m_Address;
-
- union
- {
- uint64_t ll[2];
- uint8_t buf[16];
- } m_HeaderMask;
+ boost::asio::ip::udp::socket& OpenSocket (const boost::asio::ip::udp::endpoint& localEndpoint);
+ void Receive (boost::asio::ip::udp::socket& socket);
+ void HandleReceivedFrom (const boost::system::error_code& ecode, size_t bytes_transferred,
+ Packet * packet, boost::asio::ip::udp::socket& socket);
+ void HandleReceivedPacket (Packet * packet);
+ void HandleReceivedPackets (std::vector<Packet *> packets);
+ void ProcessNextPacket (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
+
+ void ScheduleTermination ();
+ void HandleTerminationTimer (const boost::system::error_code& ecode);
+
+ void ScheduleResend ();
+ void HandleResendTimer (const boost::system::error_code& ecode);
+
+ void ConnectThroughIntroducer (std::shared_ptr<SSU2Session> session);
+ std::list<std::shared_ptr<SSU2Session> > FindIntroducers (int maxNumIntroducers,
+ bool v4, const std::set<i2p::data::IdentHash>& excluded) const;
+ void UpdateIntroducers (bool v4);
+ void ScheduleIntroducersUpdateTimer ();
+ void HandleIntroducersUpdateTimer (const boost::system::error_code& ecode, bool v4);
+ void ScheduleIntroducersUpdateTimerV6 ();
+
+ private:
+
+ ReceiveService m_ReceiveService;
+ boost::asio::ip::udp::socket m_SocketV4, m_SocketV6;
+ boost::asio::ip::address m_AddressV4, m_AddressV6;
+ std::unordered_map<uint64_t, std::shared_ptr<SSU2Session> > m_Sessions;
+ std::unordered_map<i2p::data::IdentHash, std::shared_ptr<SSU2Session> > m_SessionsByRouterHash;
+ std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSU2Session> > m_PendingOutgoingSessions;
+ std::map<boost::asio::ip::udp::endpoint, std::pair<uint64_t, uint32_t> > m_IncomingTokens, m_OutgoingTokens; // remote endpoint -> (token, expires in seconds)
+ std::map<uint32_t, std::shared_ptr<SSU2Session> > m_Relays; // we are introducer, relay tag -> session
+ std::list<i2p::data::IdentHash> m_Introducers, m_IntroducersV6; // introducers we are connected to
+ i2p::util::MemoryPoolMt<Packet> m_PacketsPool;
+ i2p::util::MemoryPool<SSU2SentPacket> m_SentPacketsPool;
+ boost::asio::deadline_timer m_TerminationTimer, m_ResendTimer,
+ m_IntroducersUpdateTimer, m_IntroducersUpdateTimerV6;
+ std::shared_ptr<SSU2Session> m_LastSession;
+ bool m_IsPublished; // if we maintain introducers
+ bool m_IsSyncClockFromPeers;
+
+ public:
+
+ // for HTTP/I2PControl
+ const decltype(m_Sessions)& GetSSU2Sessions () const { return m_Sessions; };
};
}
}
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSU2Session.cpp
^
|
@@ -0,0 +1,2669 @@
+/*
+* Copyright (c) 2022, The PurpleI2P Project
+*
+* This file is part of Purple i2pd project and licensed under BSD3
+*
+* See full license text in LICENSE file at top of project tree
+*/
+
+#include <string.h>
+#include <openssl/rand.h>
+#include "Log.h"
+#include "Transports.h"
+#include "Gzip.h"
+#include "NetDb.hpp"
+#include "SSU2.h"
+
+namespace i2p
+{
+namespace transport
+{
+ void SSU2IncompleteMessage::AttachNextFragment (const uint8_t * fragment, size_t fragmentSize)
+ {
+ if (msg->len + fragmentSize > msg->maxLen)
+ {
+ LogPrint (eLogInfo, "SSU2: I2NP message size ", msg->maxLen, " is not enough");
+ auto newMsg = NewI2NPMessage ();
+ *newMsg = *msg;
+ msg = newMsg;
+ }
+ if (msg->Concat (fragment, fragmentSize) < fragmentSize)
+ LogPrint (eLogError, "SSU2: I2NP buffer overflow ", msg->maxLen);
+ nextFragmentNum++;
+ }
+
+
+ SSU2Session::SSU2Session (SSU2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter,
+ std::shared_ptr<const i2p::data::RouterInfo::Address> addr):
+ TransportSession (in_RemoteRouter, SSU2_CONNECT_TIMEOUT),
+ m_Server (server), m_Address (addr), m_RemoteTransports (0),
+ m_DestConnID (0), m_SourceConnID (0), m_State (eSSU2SessionStateUnknown),
+ m_SendPacketNum (0), m_ReceivePacketNum (0), m_IsDataReceived (false),
+ m_WindowSize (SSU2_MIN_WINDOW_SIZE), m_RTT (SSU2_RESEND_INTERVAL),
+ m_RTO (SSU2_RESEND_INTERVAL*SSU2_kAPPA), m_RelayTag (0),
+ m_ConnectTimer (server.GetService ()), m_TerminationReason (eSSU2TerminationReasonNormalClose),
+ m_MaxPayloadSize (SSU2_MIN_PACKET_SIZE - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - 32) // min size
+ {
+ m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState);
+ if (in_RemoteRouter && m_Address)
+ {
+ // outgoing
+ InitNoiseXKState1 (*m_NoiseState, m_Address->s);
+ m_RemoteEndpoint = boost::asio::ip::udp::endpoint (m_Address->host, m_Address->port);
+ m_RemoteTransports = in_RemoteRouter->GetCompatibleTransports (false);
+ RAND_bytes ((uint8_t *)&m_DestConnID, 8);
+ RAND_bytes ((uint8_t *)&m_SourceConnID, 8);
+ }
+ else
+ {
+ // incoming
+ InitNoiseXKState1 (*m_NoiseState, i2p::context.GetSSU2StaticPublicKey ());
+ }
+ }
+
+ SSU2Session::~SSU2Session ()
+ {
+ }
+
+ void SSU2Session::Connect ()
+ {
+ if (m_State == eSSU2SessionStateUnknown || m_State == eSSU2SessionStateTokenReceived)
+ {
+ ScheduleConnectTimer ();
+ auto token = m_Server.FindOutgoingToken (m_RemoteEndpoint);
+ if (token)
+ SendSessionRequest (token);
+ else
+ {
+ m_State = eSSU2SessionStateUnknown;
+ SendTokenRequest ();
+ }
+ }
+ }
+
+ void SSU2Session::ScheduleConnectTimer ()
+ {
+ m_ConnectTimer.cancel ();
+ m_ConnectTimer.expires_from_now (boost::posix_time::seconds(SSU2_CONNECT_TIMEOUT));
+ m_ConnectTimer.async_wait (std::bind (&SSU2Session::HandleConnectTimer,
+ shared_from_this (), std::placeholders::_1));
+ }
+
+ void SSU2Session::HandleConnectTimer (const boost::system::error_code& ecode)
+ {
+ if (!ecode)
+ {
+ // timeout expired
+ LogPrint (eLogWarning, "SSU2: Session with ", m_RemoteEndpoint, " was not established after ", SSU2_CONNECT_TIMEOUT, " seconds");
+ Terminate ();
+ }
+ }
+
+ bool SSU2Session::Introduce (std::shared_ptr<SSU2Session> session, uint32_t relayTag)
+ {
+ // we are Alice
+ if (!session || !relayTag) return false;
+ // find local adddress to introduce
+ auto localAddress = session->FindLocalAddress ();
+ if (!localAddress) return false;
+ // create nonce
+ uint32_t nonce;
+ RAND_bytes ((uint8_t *)&nonce, 4);
+ auto ts = i2p::util::GetSecondsSinceEpoch ();
+ // payload
+ uint8_t payload[SSU2_MAX_PACKET_SIZE];
+ size_t payloadSize = 0;
+ payload[0] = eSSU2BlkRelayRequest;
+ payload[3] = 0; // flag
+ htobe32buf (payload + 4, nonce);
+ htobe32buf (payload + 8, relayTag);
+ htobe32buf (payload + 12, ts);
+ payload[16] = 2; // ver
+ size_t asz = CreateEndpoint (payload + 18, m_MaxPayloadSize - 18, boost::asio::ip::udp::endpoint (localAddress->host, localAddress->port));
+ if (!asz) return false;
+ payload[17] = asz;
+ payloadSize += asz + 18;
+ SignedData s;
+ s.Insert ((const uint8_t *)"RelayRequestData", 16); // prologue
+ s.Insert (GetRemoteIdentity ()->GetIdentHash (), 32); // bhash
+ s.Insert (session->GetRemoteIdentity ()->GetIdentHash (), 32); // chash
+ s.Insert (payload + 4, 14 + asz); // nonce, relay tag, timestamp, ver, asz and Alice's endpoint
+ s.Sign (i2p::context.GetPrivateKeys (), payload + payloadSize);
+ payloadSize += i2p::context.GetIdentity ()->GetSignatureLen ();
+ htobe16buf (payload + 1, payloadSize - 3); // size
+ payloadSize += CreatePaddingBlock (payload + payloadSize, m_MaxPayloadSize - payloadSize);
+ // send
+ m_RelaySessions.emplace (nonce, std::make_pair (session, ts));
+ session->m_SourceConnID = htobe64 (((uint64_t)nonce << 32) | nonce);
+ session->m_DestConnID = ~session->m_SourceConnID;
+ m_Server.AddSession (session);
+ SendData (payload, payloadSize);
+
+ return true;
+ }
+
+ void SSU2Session::WaitForIntroduction ()
+ {
+ m_State = eSSU2SessionStateIntroduced;
+ ScheduleConnectTimer ();
+ }
+
+ void SSU2Session::ConnectAfterIntroduction ()
+ {
+ if (m_State == eSSU2SessionStateIntroduced)
+ {
+ // create new connID
+ uint64_t oldConnID = GetConnID ();
+ RAND_bytes ((uint8_t *)&m_DestConnID, 8);
+ RAND_bytes ((uint8_t *)&m_SourceConnID, 8);
+ // connect
+ m_State = eSSU2SessionStateTokenReceived;
+ m_Server.AddPendingOutgoingSession (shared_from_this ());
+ m_Server.RemoveSession (oldConnID);
+ Connect ();
+ }
+ }
+
+ void SSU2Session::SendPeerTest ()
+ {
+ // we are Alice
+ uint32_t nonce;
+ RAND_bytes ((uint8_t *)&nonce, 4);
+ auto ts = i2p::util::GetSecondsSinceEpoch ();
+ // session for message 5
+ auto session = std::make_shared<SSU2Session> (m_Server);
+ session->SetState (eSSU2SessionStatePeerTest);
+ m_PeerTests.emplace (nonce, std::make_pair (session, ts));
+ session->m_SourceConnID = htobe64 (((uint64_t)nonce << 32) | nonce);
+ session->m_DestConnID = ~session->m_SourceConnID;
+ m_Server.AddSession (session);
+ // peer test block
+ uint8_t payload[SSU2_MAX_PACKET_SIZE];
+ size_t payloadSize = CreatePeerTestBlock (payload, m_MaxPayloadSize, nonce);
+ if (payloadSize > 0)
+ {
+ payloadSize += CreatePaddingBlock (payload + payloadSize, m_MaxPayloadSize - payloadSize);
+ SendData (payload, payloadSize);
+ }
+ }
+
+ void SSU2Session::SendKeepAlive ()
+ {
+ if (IsEstablished ())
+ {
+ uint8_t payload[20];
+ size_t payloadSize = CreatePaddingBlock (payload, 20, 5);
+ SendData (payload, payloadSize);
+ }
+ }
+
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSU2Session.h
^
|
@@ -0,0 +1,358 @@
+/*
+* Copyright (c) 2022, The PurpleI2P Project
+*
+* This file is part of Purple i2pd project and licensed under BSD3
+*
+* See full license text in LICENSE file at top of project tree
+*/
+
+#ifndef SSU2_SESSION_H__
+#define SSU2_SESSION_H__
+
+#include <memory>
+#include <functional>
+#include <map>
+#include <set>
+#include <list>
+#include <boost/asio.hpp>
+#include "Crypto.h"
+#include "RouterInfo.h"
+#include "RouterContext.h"
+#include "TransportSession.h"
+
+namespace i2p
+{
+namespace transport
+{
+ const int SSU2_CONNECT_TIMEOUT = 5; // 5 seconds
+ const int SSU2_TERMINATION_TIMEOUT = 330; // 5.5 minutes
+ const int SSU2_CLOCK_SKEW = 60; // in seconds
+ const int SSU2_CLOCK_THRESHOLD = 15; // in seconds, if more we should adjust
+ const int SSU2_TOKEN_EXPIRATION_TIMEOUT = 9; // for Retry message, in seconds
+ const int SSU2_NEXT_TOKEN_EXPIRATION_TIMEOUT = 52*60; // for next token block, in seconds
+ const int SSU2_TOKEN_EXPIRATION_THRESHOLD = 2; // in seconds
+ const int SSU2_RELAY_NONCE_EXPIRATION_TIMEOUT = 10; // in seconds
+ const int SSU2_PEER_TEST_EXPIRATION_TIMEOUT = 60; // 60 seconds
+ const size_t SSU2_MAX_PACKET_SIZE = 1500;
+ const size_t SSU2_MIN_PACKET_SIZE = 1280;
+ const int SSU2_HANDSHAKE_RESEND_INTERVAL = 1000; // in millseconds
+ const int SSU2_RESEND_INTERVAL = 300; // in milliseconds
+ const int SSU2_MAX_NUM_RESENDS = 5;
+ const int SSU2_INCOMPLETE_MESSAGES_CLEANUP_TIMEOUT = 30; // in seconds
+ const size_t SSU2_MIN_WINDOW_SIZE = 16; // in packets
+ const size_t SSU2_MAX_WINDOW_SIZE = 256; // in packets
+ const size_t SSU2_MIN_RTO = 100; // in milliseconds
+ const size_t SSU2_MAX_RTO = 2500; // in milliseconds
+ const float SSU2_kAPPA = 1.8;
+ const size_t SSU2_MAX_OUTGOING_QUEUE_SIZE = 500; // in messages
+ const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
+ const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
+
+ enum SSU2MessageType
+ {
+ eSSU2SessionRequest = 0,
+ eSSU2SessionCreated = 1,
+ eSSU2SessionConfirmed = 2,
+ eSSU2Data = 6,
+ eSSU2PeerTest = 7,
+ eSSU2Retry = 9,
+ eSSU2TokenRequest = 10,
+ eSSU2HolePunch = 11
+ };
+
+ enum SSU2BlockType
+ {
+ eSSU2BlkDateTime = 0,
+ eSSU2BlkOptions, // 1
+ eSSU2BlkRouterInfo, // 2
+ eSSU2BlkI2NPMessage, // 3
+ eSSU2BlkFirstFragment, // 4
+ eSSU2BlkFollowOnFragment, // 5
+ eSSU2BlkTermination, // 6
+ eSSU2BlkRelayRequest, // 7
+ eSSU2BlkRelayResponse, // 8
+ eSSU2BlkRelayIntro, // 9
+ eSSU2BlkPeerTest, // 10
+ eSSU2BlkNextNonce, // 11
+ eSSU2BlkAck, // 12
+ eSSU2BlkAddress, // 13
+ eSSU2BlkIntroKey, // 14
+ eSSU2BlkRelayTagRequest, // 15
+ eSSU2BlkRelayTag, // 16
+ eSSU2BlkNewToken, // 17
+ eSSU2BlkPathChallenge, // 18
+ eSSU2BlkPathResponse, // 19
+ eSSU2BlkFirstPacketNumber, // 20
+ eSSU2BlkPadding = 254
+ };
+
+ enum SSU2SessionState
+ {
+ eSSU2SessionStateUnknown,
+ eSSU2SessionStateTokenReceived,
+ eSSU2SessionStateSessionRequestSent,
+ eSSU2SessionStateSessionRequestReceived,
+ eSSU2SessionStateSessionCreatedSent,
+ eSSU2SessionStateSessionCreatedReceived,
+ eSSU2SessionStateSessionConfirmedSent,
+ eSSU2SessionStateEstablished,
+ eSSU2SessionStateClosing,
+ eSSU2SessionStateTerminated,
+ eSSU2SessionStateFailed,
+ eSSU2SessionStateIntroduced,
+ eSSU2SessionStatePeerTest,
+ eSSU2SessionStatePeerTestReceived // 5 before 4
+ };
+
+ enum SSU2PeerTestCode
+ {
+ eSSU2PeerTestCodeAccept = 0,
+ eSSU2PeerTestCodeBobReasonUnspecified = 1,
+ eSSU2PeerTestCodeBobNoCharlieAvailable = 2,
+ eSSU2PeerTestCodeBobLimitExceeded = 3,
+ eSSU2PeerTestCodeBobSignatureFailure = 4,
+ eSSU2PeerTestCodeCharlieReasonUnspecified = 64,
+ eSSU2PeerTestCodeCharlieUnsupportedAddress = 65,
+ eSSU2PeerTestCodeCharlieLimitExceeded = 66,
+ eSSU2PeerTestCodeCharlieSignatureFailure = 67,
+ eSSU2PeerTestCodeCharlieAliceIsAlreadyConnected = 68,
+ eSSU2PeerTestCodeCharlieAliceIsBanned = 69,
+ eSSU2PeerTestCodeCharlieAliceIsUnknown = 70,
+ eSSU2PeerTestCodeUnspecified = 128
+ };
+
+ enum SSU2RelayResponseCode
+ {
+ eSSU2RelayResponseCodeAccept = 0,
+ eSSU2RelayResponseCodeBobRelayTagNotFound = 5,
+ eSSU2RelayResponseCodeCharlieUnsupportedAddress = 65,
+ eSSU2RelayResponseCodeCharlieSignatureFailure = 67,
+ eSSU2RelayResponseCodeCharlieAliceIsUnknown = 70
+ };
+
+ enum SSU2TerminationReason
+ {
+ eSSU2TerminationReasonNormalClose = 0,
+ eSSU2TerminationReasonTerminationReceived = 1,
+ eSSU2TerminationReasonIdleTimeout = 2,
+ eSSU2TerminationReasonRouterShutdown = 3,
+ eSSU2TerminationReasonDataPhaseAEADFailure= 4,
+ eSSU2TerminationReasonIncompatibleOptions = 5,
+ eSSU2TerminationReasonTncompatibleSignatureType = 6,
+ eSSU2TerminationReasonClockSkew = 7,
+ eSSU2TerminationPaddingViolation = 8,
+ eSSU2TerminationReasonAEADFramingError = 9,
+ eSSU2TerminationReasonPayloadFormatError = 10,
+ eSSU2TerminationReasonSessionRequestError = 11,
+ eSSU2TerminationReasonSessionCreatedError = 12,
+ eSSU2TerminationReasonSessionConfirmedError = 13,
+ eSSU2TerminationReasonTimeout = 14,
+ eSSU2TerminationReasonRouterInfoSignatureVerificationFail = 15,
+ eSSU2TerminationReasonInvalidS = 16,
+ eSSU2TerminationReasonBanned = 17,
+ eSSU2TerminationReasonBadToken = 18,
+ eSSU2TerminationReasonConnectionLimits = 19,
+ eSSU2TerminationReasonIncompatibleVersion = 20,
+ eSSU2TerminationReasonWrongNetID = 21,
+ eSSU2TerminationReasonReplacedByNewSession = 22
+ };
+
+ struct SSU2IncompleteMessage
+ {
+ struct Fragment
+ {
+ uint8_t buf[SSU2_MAX_PACKET_SIZE];
+ size_t len;
+ bool isLast;
+ };
+
+ std::shared_ptr<I2NPMessage> msg;
+ int nextFragmentNum;
+ uint32_t lastFragmentInsertTime; // in seconds
+ std::map<int, std::shared_ptr<Fragment> > outOfSequenceFragments;
+
+ void AttachNextFragment (const uint8_t * fragment, size_t fragmentSize);
+ };
+
+ struct SSU2SentPacket
+ {
+ uint8_t payload[SSU2_MAX_PACKET_SIZE];
+ size_t payloadSize = 0;
+ uint64_t sendTime; // in milliseconds
+ int numResends = 0;
+ };
+
+ // RouterInfo flags
+ const uint8_t SSU2_ROUTER_INFO_FLAG_REQUEST_FLOOD = 0x01;
+ const uint8_t SSU2_ROUTER_INFO_FLAG_GZIP = 0x02;
+
+ class SSU2Server;
+ class SSU2Session: public TransportSession, public std::enable_shared_from_this<SSU2Session>
+ {
+ union Header
+ {
+ uint64_t ll[2];
+ uint8_t buf[16];
+ struct
+ {
+ uint64_t connID;
+ uint32_t packetNum;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSUData.cpp
^
|
@@ -171,7 +171,7 @@
return;
}
- // find message with msgID
+ // find message with msgID
auto it = m_IncompleteMessages.find (msgID);
if (it == m_IncompleteMessages.end ())
{
@@ -318,7 +318,7 @@
sentMessage->numResends = 0;
}
auto& fragments = sentMessage->fragments;
- size_t payloadSize = m_PacketSize - sizeof (SSUHeader) - 9; // 9 = flag + #frg(1) + messageID(4) + frag info (3)
+ size_t payloadSize = m_PacketSize - sizeof (SSUHeader) - 9; // 9 = flag + #frg(1) + messageID(4) + frag info (3)
size_t len = msg->GetLength ();
uint8_t * msgBuf = msg->GetSSUHeader ();
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSUData.h
^
|
@@ -19,21 +19,14 @@
#include "I2NPProtocol.h"
#include "Identity.h"
#include "RouterInfo.h"
+#include "TransportSession.h"
namespace i2p
{
namespace transport
{
-
const size_t SSU_MTU_V4 = 1484;
- #ifdef MESHNET
- const size_t SSU_MTU_V6 = 1286;
- #else
const size_t SSU_MTU_V6 = 1488;
- #endif
- const size_t IPV4_HEADER_SIZE = 20;
- const size_t IPV6_HEADER_SIZE = 40;
- const size_t UDP_HEADER_SIZE = 8;
const size_t SSU_V4_MAX_PACKET_SIZE = SSU_MTU_V4 - IPV4_HEADER_SIZE - UDP_HEADER_SIZE; // 1456
const size_t SSU_V6_MAX_PACKET_SIZE = SSU_MTU_V6 - IPV6_HEADER_SIZE - UDP_HEADER_SIZE; // 1440
const int RESEND_INTERVAL = 3; // in seconds
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSUSession.cpp
^
|
@@ -41,7 +41,6 @@
i2p::context.GetRouterInfo ().GetSSUAddress (true);
if (address) m_IntroKey = address->i;
}
- m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
}
SSUSession::~SSUSession ()
@@ -296,8 +295,8 @@
{
LogPrint (eLogWarning, "SSU: Clock adjusted by ", -offset, " seconds");
i2p::util::AdjustTimeOffset (-offset);
- }
- }
+ }
+ }
else if (std::abs (offset) > SSU_CLOCK_SKEW)
{
LogPrint (eLogError, "SSU: Clock skew detected ", offset, ". Check your clock");
@@ -388,11 +387,11 @@
// fill extended options, 3 bytes extended options don't change message size
bool isV4 = m_RemoteEndpoint.address ().is_v4 ();
if ((isV4 && i2p::context.GetStatus () == eRouterStatusOK) ||
- (!isV4 && i2p::context.GetStatusV6 () == eRouterStatusOK)) // we don't need relays
+ (!isV4 && i2p::context.GetStatusV6 () == eRouterStatusOK)) // we don't need relays
{
// tell out peer to now assign relay tag
flag = SSU_HEADER_EXTENDED_OPTIONS_INCLUDED;
- *payload = 2; payload++; // 1 byte length
+ *payload = 2; payload++; // 1 byte length
uint16_t flags = 0; // clear EXTENDED_OPTIONS_FLAG_REQUEST_RELAY_TAG
htobe16buf (payload, flags);
payload += 2;
@@ -1020,7 +1019,7 @@
for (auto it = m_RelayRequests.begin (); it != m_RelayRequests.end ();)
{
if (ts > it->second.second + SSU_CONNECT_TIMEOUT)
- it = m_RelayRequests.erase (it);
+ it = m_RelayRequests.erase (it);
else
++it;
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/SSUSession.h
^
|
@@ -103,8 +103,6 @@
void SendKeepAlive ();
uint32_t GetRelayTag () const { return m_RelayTag; };
const i2p::data::RouterInfo::IntroKey& GetIntroKey () const { return m_IntroKey; };
- uint32_t GetCreationTime () const { return m_CreationTime; };
- void SetCreationTime (uint32_t ts) { m_CreationTime = ts; }; // for introducers
void FlushData ();
void CleanUp (uint64_t ts);
@@ -167,7 +165,6 @@
i2p::crypto::AESKey m_SessionKey;
i2p::crypto::MACKey m_MacKey;
i2p::data::RouterInfo::IntroKey m_IntroKey;
- uint32_t m_CreationTime; // seconds since epoch
SSUData m_Data;
bool m_IsDataReceived;
std::unique_ptr<SignedData> m_SignedData; // we need it for SessionConfirmed only
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Signature.cpp
^
|
@@ -130,7 +130,7 @@
else
{
size_t l = 64;
- uint8_t sig[64]; // temporary buffer for signature. openssl issue #7232
+ uint8_t sig[64]; // temporary buffer for signature. openssl issue #7232
EVP_DigestSign (m_MDCtx, sig, &l, buf, len);
memcpy (signature, sig, 64);
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Streaming.cpp
^
|
@@ -1249,7 +1249,7 @@
return s;
}
- void StreamingDestination::SendPing (std::shared_ptr<const i2p::data::LeaseSet> remote)
+ void StreamingDestination::SendPing (std::shared_ptr<const i2p::data::LeaseSet> remote)
{
auto s = std::make_shared<Stream> (m_Owner->GetService (), *this, remote, 0);
s->SendPing ();
@@ -1277,7 +1277,7 @@
{
m_PacketsPool.CleanUp ();
m_I2NPMsgsPool.CleanUp ();
- }
+ }
}
bool StreamingDestination::DeleteStream (uint32_t recvStreamID)
@@ -1285,7 +1285,13 @@
auto it = m_Streams.find (recvStreamID);
if (it == m_Streams.end ())
return false;
- DeleteStream (it->second);
+ auto s = it->second;
+ m_Owner->GetService ().post ([this, s] ()
+ {
+ s->Close (); // try to send FIN
+ s->Terminate (false);
+ DeleteStream (s);
+ });
return true;
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Timestamp.cpp
^
|
@@ -254,6 +254,6 @@
void AdjustTimeOffset (int64_t offset)
{
g_TimeOffset += offset;
- }
+ }
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Timestamp.h
^
|
@@ -27,7 +27,7 @@
void GetCurrentDate (char * date); // returns date as YYYYMMDD string, 9 bytes
void GetDateString (uint64_t timestamp, char * date); // timestap is seconds since epoch, returns date as YYYYMMDD string, 9 bytes
void AdjustTimeOffset (int64_t offset); // in seconds from current
-
+
class NTPTimeSync
{
public:
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/TransportSession.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -24,6 +24,10 @@
{
namespace transport
{
+ const size_t IPV4_HEADER_SIZE = 20;
+ const size_t IPV6_HEADER_SIZE = 40;
+ const size_t UDP_HEADER_SIZE = 8;
+
class SignedData
{
public:
@@ -33,6 +37,12 @@
{
m_Stream << other.m_Stream.rdbuf ();
}
+
+ void Reset ()
+ {
+ m_Stream.str("");
+ }
+
void Insert (const uint8_t * buf, size_t len)
{
m_Stream.write ((char *)buf, len);
@@ -58,7 +68,7 @@
std::stringstream m_Stream;
};
-
+
class TransportSession
{
public:
@@ -69,6 +79,7 @@
{
if (router)
m_RemoteIdentity = router->GetRouterIdentity ();
+ m_CreationTime = m_LastActivityTimestamp;
}
virtual ~TransportSession () {};
@@ -96,7 +107,11 @@
bool IsTerminationTimeoutExpired (uint64_t ts) const
{ return ts >= m_LastActivityTimestamp + GetTerminationTimeout (); };
- virtual void SendLocalRouterInfo () { SendI2NPMessages ({ CreateDatabaseStoreMsg () }); };
+ uint32_t GetCreationTime () const { return m_CreationTime; };
+ void SetCreationTime (uint32_t ts) { m_CreationTime = ts; }; // for introducers
+
+ virtual uint32_t GetRelayTag () const { return 0; };
+ virtual void SendLocalRouterInfo (bool update = false) { SendI2NPMessages ({ CreateDatabaseStoreMsg () }); };
virtual void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) = 0;
protected:
@@ -107,6 +122,7 @@
bool m_IsOutgoing;
int m_TerminationTimeout;
uint64_t m_LastActivityTimestamp;
+ uint32_t m_CreationTime; // seconds since epoch
};
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Transports.cpp
^
|
@@ -136,7 +136,7 @@
Transports::Transports ():
m_IsOnline (true), m_IsRunning (false), m_IsNAT (true), m_CheckReserved(true), m_Thread (nullptr),
m_Service (nullptr), m_Work (nullptr), m_PeerCleanupTimer (nullptr), m_PeerTestTimer (nullptr),
- m_SSUServer (nullptr), m_NTCP2Server (nullptr),
+ m_SSUServer (nullptr), m_SSU2Server (nullptr), m_NTCP2Server (nullptr),
m_X25519KeysPairSupplier (15), // 15 pre-generated keys
m_TotalSentBytes(0), m_TotalReceivedBytes(0), m_TotalTransitTransmittedBytes (0),
m_InBandwidth (0), m_OutBandwidth (0), m_TransitBandwidth(0),
@@ -157,7 +157,7 @@
}
}
- void Transports::Start (bool enableNTCP2, bool enableSSU)
+ void Transports::Start (bool enableNTCP2, bool enableSSU, bool enableSSU2)
{
if (!m_Service)
{
@@ -217,6 +217,8 @@
}
}
}
+ // create SSU2 server
+ if (enableSSU2) m_SSU2Server = new SSU2Server ();
// bind to interfaces
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
@@ -231,6 +233,7 @@
{
if (m_NTCP2Server) m_NTCP2Server->SetLocalAddress (addr);
if (m_SSUServer) m_SSUServer->SetLocalAddress (addr);
+ if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
}
}
}
@@ -247,6 +250,7 @@
{
if (m_NTCP2Server) m_NTCP2Server->SetLocalAddress (addr);
if (m_SSUServer) m_SSUServer->SetLocalAddress (addr);
+ if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
}
}
}
@@ -266,6 +270,7 @@
// start servers
if (m_NTCP2Server) m_NTCP2Server->Start ();
+ if (m_SSU2Server) m_SSU2Server->Start ();
if (m_SSUServer)
{
LogPrint (eLogInfo, "Transports: Start listening UDP port ", ssuPort);
@@ -280,8 +285,8 @@
delete m_SSUServer;
m_SSUServer = nullptr;
}
- if (m_SSUServer) DetectExternalIP ();
}
+ if (m_SSUServer || m_SSU2Server) DetectExternalIP ();
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT));
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
@@ -305,6 +310,13 @@
m_SSUServer = nullptr;
}
+ if (m_SSU2Server)
+ {
+ m_SSU2Server->Stop ();
+ delete m_SSU2Server;
+ m_SSU2Server = nullptr;
+ }
+
if (m_NTCP2Server)
{
m_NTCP2Server->Stop ();
@@ -403,9 +415,10 @@
auto r = netdb.FindRouter (ident);
if (r && (r->IsUnreachable () || !r->IsReachableFrom (i2p::context.GetRouterInfo ()))) return; // router found but non-reachable
{
+ auto ts = i2p::util::GetSecondsSinceEpoch ();
std::unique_lock<std::mutex> l(m_PeersMutex);
it = m_Peers.insert (std::pair<i2p::data::IdentHash, Peer>(ident, { 0, r, {},
- i2p::util::GetSecondsSinceEpoch (), {} })).first;
+ ts, ts + PEER_ROUTER_INFO_UPDATE_INTERVAL, {} })).first;
}
connected = ConnectToPeer (ident, it->second);
}
@@ -440,7 +453,7 @@
peer.router = netdb.FindRouter (ident); // try to get new one from netdb
if (peer.router) // we have RI already
{
- if (peer.numAttempts < 2) // NTCP2, 0 - ipv6, 1- ipv4
+ if (peer.numAttempts < 2) // NTCP2, 0 - ipv6, 1 - ipv4
{
if (m_NTCP2Server) // we support NTCP2
{
@@ -478,26 +491,26 @@
else
peer.numAttempts = 2; // switch to SSU
}
- if (peer.numAttempts == 2 || peer.numAttempts == 3) // SSU
+ if (peer.numAttempts == 2 || peer.numAttempts == 3) // SSU2, 2 - ipv6, 3 - ipv4
{
- if (m_SSUServer)
+ if (m_SSU2Server)
{
std::shared_ptr<const RouterInfo::Address> address;
- if (peer.numAttempts == 2) // SSU ipv6
+ if (peer.numAttempts == 2) // SSU2 ipv6
{
- if (context.GetRouterInfo ().IsSSUV6 () && peer.router->IsReachableBy (RouterInfo::eSSUV6))
+ if (context.GetRouterInfo ().IsSSU2V6 () && peer.router->IsReachableBy (RouterInfo::eSSU2V6))
{
- address = peer.router->GetSSUV6Address ();
+ address = peer.router->GetSSU2V6Address ();
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
address = nullptr;
}
peer.numAttempts++;
}
- if (!address && peer.numAttempts == 3) // SSU ipv4
+ if (!address && peer.numAttempts == 3) // SSU2 ipv4
{
- if (context.GetRouterInfo ().IsSSU (true) && peer.router->IsReachableBy (RouterInfo::eSSUV4))
+ if (context.GetRouterInfo ().IsSSU2V4 () && peer.router->IsReachableBy (RouterInfo::eSSU2V4))
{
- address = peer.router->GetSSUAddress (true);
+ address = peer.router->GetSSU2V4Address ();
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
address = nullptr;
}
@@ -505,12 +518,12 @@
}
if (address && address->IsReachableSSU ())
{
- if (m_SSUServer->CreateSession (peer.router, address))
+ if (m_SSU2Server->CreateSession (peer.router, address))
return true;
}
}
else
- peer.numAttempts += 2; // switch to Mesh
+ peer.numAttempts += 2; // switch to mesh
}
if (peer.numAttempts == 4) // Mesh
{
@@ -526,6 +539,40 @@
}
}
}
+ if (peer.numAttempts == 5 || peer.numAttempts == 6) // SSU, 5 - ipv6, 6 - ipv4
+ {
+ if (m_SSUServer)
+ {
+ std::shared_ptr<const RouterInfo::Address> address;
+ if (peer.numAttempts == 5) // SSU ipv6
+ {
+ if (context.GetRouterInfo ().IsSSUV6 () && peer.router->IsReachableBy (RouterInfo::eSSUV6))
+ {
+ address = peer.router->GetSSUV6Address ();
+ if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
+ address = nullptr;
+ }
+ peer.numAttempts++;
+ }
+ if (!address && peer.numAttempts == 6) // SSU ipv4
+ {
+ if (context.GetRouterInfo ().IsSSU (true) && peer.router->IsReachableBy (RouterInfo::eSSUV4))
+ {
+ address = peer.router->GetSSUAddress (true);
+ if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
+ address = nullptr;
+ }
+ peer.numAttempts++;
+ }
+ if (address && address->IsReachableSSU ())
+ {
+ if (m_SSUServer->CreateSession (peer.router, address))
+ return true;
+ }
+ }
+ else
+ peer.numAttempts += 2;
+ }
LogPrint (eLogInfo, "Transports: No compatble NTCP2 or SSU addresses available");
i2p::data::netdb.SetUnreachable (ident, true); // we are here because all connection attempts failed
peer.Done ();
@@ -575,68 +622,109 @@
i2p::context.SetStatus (eRouterStatusOK);
return;
}
- if (m_SSUServer)
+ if (m_SSUServer || m_SSU2Server)
PeerTest ();
else
- LogPrint (eLogError, "Transports: Can't detect external IP. SSU is not available");
+ LogPrint (eLogWarning, "Transports: Can't detect external IP. SSU or SSU2 is not available");
}
void Transports::PeerTest (bool ipv4, bool ipv6)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Transports.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -22,6 +22,7 @@
#include <boost/asio.hpp>
#include "TransportSession.h"
#include "SSU.h"
+#include "SSU2.h"
#include "NTCP2.h"
#include "RouterInfo.h"
#include "I2NPProtocol.h"
@@ -61,12 +62,14 @@
};
typedef EphemeralKeysSupplier<i2p::crypto::X25519Keys> X25519KeysPairSupplier;
+ const int PEER_ROUTER_INFO_UPDATE_INTERVAL = 31*60; // in seconds
+ const int PEER_ROUTER_INFO_UPDATE_INTERVAL_VARIANCE = 7*60; // in seconds
struct Peer
{
int numAttempts;
std::shared_ptr<const i2p::data::RouterInfo> router;
std::list<std::shared_ptr<TransportSession> > sessions;
- uint64_t creationTime;
+ uint64_t creationTime, nextRouterInfoUpdateTime;
std::vector<std::shared_ptr<i2p::I2NPMessage> > delayedMessages;
void Done ()
@@ -76,7 +79,7 @@
}
};
- const size_t SESSION_CREATION_TIMEOUT = 15; // in seconds
+ const uint64_t SESSION_CREATION_TIMEOUT = 15; // in seconds
const int PEER_TEST_INTERVAL = 71; // in minutes
const int MAX_NUM_DELAYED_MESSAGES = 150;
class Transports
@@ -86,10 +89,11 @@
Transports ();
~Transports ();
- void Start (bool enableNTCP2=true, bool enableSSU=true);
+ void Start (bool enableNTCP2=true, bool enableSSU=true, bool enableSSU2=false);
void Stop ();
bool IsBoundSSU() const { return m_SSUServer != nullptr; }
+ bool IsBoundSSU2() const { return m_SSU2Server != nullptr; }
bool IsBoundNTCP2() const { return m_NTCP2Server != nullptr; }
bool IsOnline() const { return m_IsOnline; };
@@ -125,7 +129,7 @@
/** do we want to use restricted routes? */
bool RoutesRestricted() const;
/** restrict routes to use only these router families for first hops */
- void RestrictRoutesToFamilies(std::set<std::string> families);
+ void RestrictRoutesToFamilies(const std::set<std::string>& families);
/** restrict routes to use only these routers for first hops */
void RestrictRoutesToRouters(std::set<i2p::data::IdentHash> routers);
@@ -159,6 +163,7 @@
boost::asio::deadline_timer * m_PeerCleanupTimer, * m_PeerTestTimer;
SSUServer * m_SSUServer;
+ SSU2Server * m_SSU2Server;
NTCP2Server * m_NTCP2Server;
mutable std::mutex m_PeersMutex;
std::unordered_map<i2p::data::IdentHash, Peer> m_Peers;
@@ -171,7 +176,7 @@
uint64_t m_LastBandwidthUpdateTime;
/** which router families to trust for first hops */
- std::vector<std::string> m_TrustedFamilies;
+ std::vector<i2p::data::FamilyID> m_TrustedFamilies;
mutable std::mutex m_FamilyMutex;
/** which routers for first hop to trust */
@@ -185,6 +190,7 @@
// for HTTP only
const SSUServer * GetSSUServer () const { return m_SSUServer; };
const NTCP2Server * GetNTCP2Server () const { return m_NTCP2Server; };
+ const SSU2Server * GetSSU2Server () const { return m_SSU2Server; };
const decltype(m_Peers)& GetPeers () const { return m_Peers; };
};
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Tunnel.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -108,13 +108,13 @@
else
{
if (m_Config->IsShort () && m_Config->GetLastHop () &&
- m_Config->GetLastHop ()->ident->GetIdentHash () != m_Config->GetLastHop ()->nextIdent)
+ m_Config->GetLastHop ()->ident->GetIdentHash () != m_Config->GetLastHop ()->nextIdent)
{
// add garlic key/tag for reply
uint8_t key[32];
uint64_t tag = m_Config->GetLastHop ()->GetGarlicKey (key);
if (m_Pool && m_Pool->GetLocalDestination ())
- m_Pool->GetLocalDestination ()->AddECIESx25519Key (key, tag);
+ m_Pool->GetLocalDestination ()->SubmitECIESx25519Key (key, tag);
else
i2p::context.AddECIESx25519Key (key, tag);
}
@@ -235,15 +235,11 @@
m_State = state;
}
-
- void Tunnel::PrintHops (std::stringstream& s) const
+ void Tunnel::VisitTunnelHops(TunnelHopVisitor v)
{
- // hops are in inverted order, we must print in direct order
+ // hops are in inverted order, we must return in direct order
for (auto it = m_Hops.rbegin (); it != m_Hops.rend (); it++)
- {
- s << " ⇒ ";
- s << i2p::data::GetIdentHashAbbreviation ((*it).ident->GetIdentHash ());
- }
+ v((*it).ident);
}
void InboundTunnel::HandleTunnelDataMsg (std::shared_ptr<I2NPMessage>&& msg)
@@ -254,12 +250,6 @@
m_Endpoint.HandleDecryptedTunnelDataMsg (msg);
}
- void InboundTunnel::Print (std::stringstream& s) const
- {
- PrintHops (s);
- s << " ⇒ " << GetTunnelID () << ":me";
- }
-
ZeroHopsInboundTunnel::ZeroHopsInboundTunnel ():
InboundTunnel (std::make_shared<ZeroHopsTunnelConfig> ()),
m_NumReceivedBytes (0)
@@ -276,11 +266,6 @@
}
}
- void ZeroHopsInboundTunnel::Print (std::stringstream& s) const
- {
- s << " ⇒ " << GetTunnelID () << ":me";
- }
-
void OutboundTunnel::SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, std::shared_ptr<i2p::I2NPMessage> msg)
{
TunnelMessageBlock block;
@@ -315,13 +300,6 @@
LogPrint (eLogError, "Tunnel: Incoming message for outbound tunnel ", GetTunnelID ());
}
- void OutboundTunnel::Print (std::stringstream& s) const
- {
- s << GetTunnelID () << ":me";
- PrintHops (s);
- s << " ⇒ ";
- }
-
ZeroHopsOutboundTunnel::ZeroHopsOutboundTunnel ():
OutboundTunnel (std::make_shared<ZeroHopsTunnelConfig> ()),
m_NumSentBytes (0)
@@ -351,11 +329,6 @@
}
}
- void ZeroHopsOutboundTunnel::Print (std::stringstream& s) const
- {
- s << GetTunnelID () << ":me ⇒ ";
- }
-
Tunnels tunnels;
Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr),
@@ -430,10 +403,10 @@
return tunnel;
}
- std::shared_ptr<TunnelPool> Tunnels::CreateTunnelPool (int numInboundHops,
- int numOutboundHops, int numInboundTunnels, int numOutboundTunnels)
+ std::shared_ptr<TunnelPool> Tunnels::CreateTunnelPool (int numInboundHops, int numOutboundHops,
+ int numInboundTunnels, int numOutboundTunnels, int inboundVariance, int outboundVariance)
{
- auto pool = std::make_shared<TunnelPool> (numInboundHops, numOutboundHops, numInboundTunnels, numOutboundTunnels);
+ auto pool = std::make_shared<TunnelPool> (numInboundHops, numOutboundHops, numInboundTunnels, numOutboundTunnels, inboundVariance, outboundVariance);
std::unique_lock<std::mutex> l(m_PoolsMutex);
m_Pools.push_back (pool);
return pool;
@@ -783,7 +756,7 @@
int obLen; i2p::config::GetOption("exploratory.outbound.length", obLen);
int ibNum; i2p::config::GetOption("exploratory.inbound.quantity", ibNum);
int obNum; i2p::config::GetOption("exploratory.outbound.quantity", obNum);
- m_ExploratoryPool = CreateTunnelPool (ibLen, obLen, ibNum, obNum);
+ m_ExploratoryPool = CreateTunnelPool (ibLen, obLen, ibNum, obNum, 0, 0);
m_ExploratoryPool->SetLocalDestination (i2p::context.GetSharedDestination ());
}
return;
@@ -849,7 +822,7 @@
template<class TTunnel>
std::shared_ptr<TTunnel> Tunnels::CreateTunnel (std::shared_ptr<TunnelConfig> config,
- std::shared_ptr<TunnelPool> pool, std::shared_ptr<OutboundTunnel> outboundTunnel)
+ std::shared_ptr<TunnelPool> pool, std::shared_ptr<OutboundTunnel> outboundTunnel)
{
auto newTunnel = std::make_shared<TTunnel> (config);
newTunnel->SetTunnelPool (pool);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/Tunnel.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -67,6 +67,9 @@
public:
+ /** function for visiting a hops stored in a tunnel */
+ typedef std::function<void(std::shared_ptr<const i2p::data::IdentityEx>)> TunnelHopVisitor;
+
Tunnel (std::shared_ptr<const TunnelConfig> config);
~Tunnel ();
@@ -91,8 +94,6 @@
bool HandleTunnelBuildResponse (uint8_t * msg, size_t len);
- virtual void Print (std::stringstream&) const {};
-
// implements TunnelBase
void SendTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage> msg);
void EncryptTunnelMsg (std::shared_ptr<const I2NPMessage> in, std::shared_ptr<I2NPMessage> out);
@@ -107,9 +108,8 @@
bool LatencyIsKnown() const { return m_Latency > 0; }
bool IsSlow () const { return LatencyIsKnown() && (int)m_Latency > HIGH_LATENCY_PER_HOP*GetNumHops (); }
- protected:
-
- void PrintHops (std::stringstream& s) const;
+ /** visit all hops we currently store */
+ void VisitTunnelHops(TunnelHopVisitor v);
private:
@@ -134,7 +134,6 @@
virtual void SendTunnelDataMsg (const std::vector<TunnelMessageBlock>& msgs); // multiple messages
const i2p::data::IdentHash& GetEndpointIdentHash () const { return m_EndpointIdentHash; };
virtual size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
- void Print (std::stringstream& s) const;
// implements TunnelBase
void HandleTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage>&& tunnelMsg);
@@ -155,7 +154,6 @@
InboundTunnel (std::shared_ptr<const TunnelConfig> config): Tunnel (config), m_Endpoint (true) {};
void HandleTunnelDataMsg (std::shared_ptr<I2NPMessage>&& msg);
virtual size_t GetNumReceivedBytes () const { return m_Endpoint.GetNumReceivedBytes (); };
- void Print (std::stringstream& s) const;
bool IsInbound() const { return true; }
// override TunnelBase
@@ -172,7 +170,6 @@
ZeroHopsInboundTunnel ();
void SendTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage> msg);
- void Print (std::stringstream& s) const;
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
private:
@@ -186,7 +183,6 @@
ZeroHopsOutboundTunnel ();
void SendTunnelDataMsg (const std::vector<TunnelMessageBlock>& msgs);
- void Print (std::stringstream& s) const;
size_t GetNumSentBytes () const { return m_NumSentBytes; };
private:
@@ -219,8 +215,8 @@
void PostTunnelData (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
void AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr<InboundTunnel> tunnel);
void AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr<OutboundTunnel> tunnel);
- std::shared_ptr<TunnelPool> CreateTunnelPool (int numInboundHops,
- int numOuboundHops, int numInboundTunnels, int numOutboundTunnels);
+ std::shared_ptr<TunnelPool> CreateTunnelPool (int numInboundHops, int numOuboundHops,
+ int numInboundTunnels, int numOutboundTunnels, int inboundVariance, int outboundVariance);
void DeleteTunnelPool (std::shared_ptr<TunnelPool> pool);
void StopTunnelPool (std::shared_ptr<TunnelPool> pool);
@@ -230,7 +226,7 @@
template<class TTunnel>
std::shared_ptr<TTunnel> CreateTunnel (std::shared_ptr<TunnelConfig> config,
- std::shared_ptr<TunnelPool> pool, std::shared_ptr<OutboundTunnel> outboundTunnel = nullptr);
+ std::shared_ptr<TunnelPool> pool, std::shared_ptr<OutboundTunnel> outboundTunnel = nullptr);
template<class TTunnel>
std::shared_ptr<TTunnel> GetPendingTunnel (uint32_t replyMsgID, const std::map<uint32_t, std::shared_ptr<TTunnel> >& pendingTunnels);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/TunnelConfig.cpp
^
|
@@ -167,7 +167,7 @@
memset (clearText + SHORT_REQUEST_RECORD_MORE_FLAGS_OFFSET, 0, 2);
clearText[SHORT_REQUEST_RECORD_LAYER_ENCRYPTION_TYPE] = 0; // AES
htobe32buf (clearText + SHORT_REQUEST_RECORD_REQUEST_TIME_OFFSET, i2p::util::GetMinutesSinceEpoch ());
- htobe32buf (clearText + SHORT_REQUEST_RECORD_REQUEST_EXPIRATION_OFFSET , 600); // +10 minutes
+ htobe32buf (clearText + SHORT_REQUEST_RECORD_REQUEST_EXPIRATION_OFFSET , 600); // +10 minutes
htobe32buf (clearText + SHORT_REQUEST_RECORD_SEND_MSG_ID_OFFSET, replyMsgID);
memset (clearText + SHORT_REQUEST_RECORD_PADDING_OFFSET, 0, SHORT_REQUEST_RECORD_CLEAR_TEXT_SIZE - SHORT_REQUEST_RECORD_PADDING_OFFSET);
// encrypt
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/TunnelConfig.h
^
|
@@ -91,7 +91,7 @@
TunnelConfig (const std::vector<std::shared_ptr<const i2p::data::IdentityEx> >& peers,
uint32_t replyTunnelID, const i2p::data::IdentHash& replyIdent, bool isShort,
- i2p::data::RouterInfo::CompatibleTransports farEndTransports = i2p::data::RouterInfo::eAllTransports): // outbound
+ i2p::data::RouterInfo::CompatibleTransports farEndTransports = i2p::data::RouterInfo::eAllTransports): // outbound
m_IsShort (isShort), m_FarEndTransports (farEndTransports)
{
CreatePeers (peers);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/TunnelPool.cpp
^
|
@@ -30,7 +30,7 @@
{
peers.push_back (r->GetRouterIdentity ());
if (r->GetVersion () < i2p::data::NETDB_MIN_SHORT_TUNNEL_BUILD_VERSION ||
- r->GetRouterIdentity ()->GetCryptoKeyType () != i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD)
+ r->GetRouterIdentity ()->GetCryptoKeyType () != i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD)
isShort = false;
}
}
@@ -40,15 +40,25 @@
std::reverse (peers.begin (), peers.end ());
}
- TunnelPool::TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels):
+ TunnelPool::TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels,
+ int numOutboundTunnels, int inboundVariance, int outboundVariance):
m_NumInboundHops (numInboundHops), m_NumOutboundHops (numOutboundHops),
m_NumInboundTunnels (numInboundTunnels), m_NumOutboundTunnels (numOutboundTunnels),
+ m_InboundVariance (inboundVariance), m_OutboundVariance (outboundVariance),
m_IsActive (true), m_CustomPeerSelector(nullptr)
{
if (m_NumInboundTunnels > TUNNEL_POOL_MAX_INBOUND_TUNNELS_QUANTITY)
m_NumInboundTunnels = TUNNEL_POOL_MAX_INBOUND_TUNNELS_QUANTITY;
if (m_NumOutboundTunnels > TUNNEL_POOL_MAX_OUTBOUND_TUNNELS_QUANTITY)
m_NumOutboundTunnels = TUNNEL_POOL_MAX_OUTBOUND_TUNNELS_QUANTITY;
+ if (m_InboundVariance < 0 && m_NumInboundHops + m_InboundVariance <= 0)
+ m_InboundVariance = m_NumInboundHops ? -m_NumInboundHops + 1 : 0;
+ if (m_OutboundVariance < 0 && m_NumOutboundHops + m_OutboundVariance <= 0)
+ m_OutboundVariance = m_NumOutboundHops ? -m_NumOutboundHops + 1 : 0;
+ if (m_InboundVariance > 0 && m_NumInboundHops + m_InboundVariance > STANDARD_NUM_RECORDS)
+ m_InboundVariance = (m_NumInboundHops < STANDARD_NUM_RECORDS) ? STANDARD_NUM_RECORDS - m_NumInboundHops : 0;
+ if (m_OutboundVariance > 0 && m_NumOutboundHops + m_OutboundVariance > STANDARD_NUM_RECORDS)
+ m_OutboundVariance = (m_NumOutboundHops < STANDARD_NUM_RECORDS) ? STANDARD_NUM_RECORDS - m_NumOutboundHops : 0;
m_NextManageTime = i2p::util::GetSecondsSinceEpoch () + rand () % TUNNEL_POOL_MANAGE_INTERVAL;
}
@@ -217,7 +227,7 @@
if (it->IsEstablished () && it != excluded && (compatible & it->GetFarEndTransports ()))
{
if (it->IsSlow () || (HasLatencyRequirement() && it->LatencyIsKnown() &&
- !it->LatencyFitsRange(m_MinLatency, m_MaxLatency)))
+ !it->LatencyFitsRange(m_MinLatency, m_MaxLatency)))
{
i++; skipped = true;
continue;
@@ -372,7 +382,7 @@
void TunnelPool::ManageTunnels (uint64_t ts)
{
- if (ts > m_NextManageTime)
+ if (ts > m_NextManageTime || ts + 2*TUNNEL_POOL_MANAGE_INTERVAL < m_NextManageTime) // in case if clock was adjusted
{
CreateTunnels ();
TestTunnels ();
@@ -411,13 +421,18 @@
{
uint64_t dlt = i2p::util::GetMillisecondsSinceEpoch () - timestamp;
LogPrint (eLogDebug, "Tunnels: Test of ", msgID, " successful. ", dlt, " milliseconds");
- uint64_t latency = dlt / 2;
+ int numHops = 0;
+ if (test.first) numHops += test.first->GetNumHops ();
+ if (test.second) numHops += test.second->GetNumHops ();
// restore from test failed state if any
if (test.first)
{
if (test.first->GetState () == eTunnelStateTestFailed)
test.first->SetState (eTunnelStateEstablished);
// update latency
+ uint64_t latency = 0;
+ if (numHops) latency = dlt*test.first->GetNumHops ()/numHops;
+ if (!latency) latency = dlt/2;
test.first->AddLatencySample(latency);
}
if (test.second)
@@ -425,6 +440,9 @@
if (test.second->GetState () == eTunnelStateTestFailed)
test.second->SetState (eTunnelStateEstablished);
// update latency
+ uint64_t latency = 0;
+ if (numHops) latency = dlt*test.second->GetNumHops ()/numHops;
+ if (!latency) latency = dlt/2;
test.second->AddLatencySample(latency);
}
}
@@ -493,7 +511,7 @@
return false;
}
if ((i == numHops - 1) && (!hop->IsV4 () || // doesn't support ipv4
- (inbound && !hop->IsReachable ()))) // IBGW is not reachable
+ (inbound && !hop->IsReachable ()))) // IBGW is not reachable
{
auto hop1 = nextHop (prevHop, true);
if (hop1) hop = hop1;
@@ -507,7 +525,30 @@
bool TunnelPool::SelectPeers (Path& path, bool isInbound)
{
- int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops;
+ // explicit peers in use
+ if (m_ExplicitPeers) return SelectExplicitPeers (path, isInbound);
+ // calculate num hops
+ int numHops;
+ if (isInbound)
+ {
+ numHops = m_NumInboundHops;
+ if (m_InboundVariance)
+ {
+ int offset = rand () % (std::abs (m_InboundVariance) + 1);
+ if (m_InboundVariance < 0) offset = -offset;
+ numHops += offset;
+ }
+ }
+ else
+ {
+ numHops = m_NumOutboundHops;
+ if (m_OutboundVariance)
+ {
+ int offset = rand () % (std::abs (m_OutboundVariance) + 1);
+ if (m_OutboundVariance < 0) offset = -offset;
+ numHops += offset;
+ }
+ }
// peers is empty
if (numHops <= 0) return true;
// custom peer selector in use ?
@@ -516,8 +557,6 @@
if (m_CustomPeerSelector)
return m_CustomPeerSelector->SelectPeers(path, numHops, isInbound);
}
- // explicit peers in use
- if (m_ExplicitPeers) return SelectExplicitPeers (path, isInbound);
return StandardSelectPeers(path, numHops, isInbound, std::bind(&TunnelPool::SelectNextHop, this, std::placeholders::_1, std::placeholders::_2));
}
@@ -676,7 +715,7 @@
auto tunnel = tunnels.CreateInboundTunnel (
m_NumOutboundHops > 0 ? std::make_shared<TunnelConfig>(outboundTunnel->GetInvertedPeers (),
outboundTunnel->IsShortBuildMessage ()) : nullptr,
- shared_from_this (), outboundTunnel);
+ shared_from_this (), outboundTunnel);
if (tunnel->IsEstablished ()) // zero hops
TunnelCreated (tunnel);
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/TunnelPool.h
^
|
@@ -61,7 +61,8 @@
{
public:
- TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels);
+ TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels,
+ int numOutboundTunnels, int inboundVariance, int outboundVariance);
~TunnelPool ();
std::shared_ptr<i2p::garlic::GarlicDestination> GetLocalDestination () const { return m_LocalDestination; };
@@ -130,7 +131,8 @@
private:
std::shared_ptr<i2p::garlic::GarlicDestination> m_LocalDestination;
- int m_NumInboundHops, m_NumOutboundHops, m_NumInboundTunnels, m_NumOutboundTunnels;
+ int m_NumInboundHops, m_NumOutboundHops, m_NumInboundTunnels, m_NumOutboundTunnels,
+ m_InboundVariance, m_OutboundVariance;
std::shared_ptr<std::vector<i2p::data::IdentHash> > m_ExplicitPeers;
mutable std::mutex m_InboundTunnelsMutex;
std::set<std::shared_ptr<InboundTunnel>, TunnelCreationTimeCmp> m_InboundTunnels; // recent tunnel appears first
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/util.cpp
^
|
@@ -12,6 +12,7 @@
#include "util.h"
#include "Log.h"
+#include "I2PEndian.h"
#if not defined (__FreeBSD__)
#include <pthread.h>
@@ -32,14 +33,10 @@
#include <iphlpapi.h>
#include <shlobj.h>
-#ifdef _MSC_VER
-#pragma comment(lib, "IPHLPAPI.lib")
-#endif // _MSC_VER
-
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
-// inet_pton exists Windows since Vista, but XP doesn't have that function!
+// inet_pton and inet_ntop have been in Windows since Vista, but XP doesn't have these functions!
// This function was written by Petar Korponai?. See http://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found
int inet_pton_xp (int af, const char *src, void *dst)
{
@@ -65,6 +62,29 @@
}
return 0;
}
+
+const char *inet_ntop_xp(int af, const void *src, char *dst, socklen_t size)
+{
+ struct sockaddr_storage ss;
+ unsigned long s = size;
+
+ ZeroMemory(&ss, sizeof(ss));
+ ss.ss_family = af;
+
+ switch(af) {
+ case AF_INET:
+ ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
+ break;
+ case AF_INET6:
+ ((struct sockaddr_in6 *)&ss)->sin6_addr = *(struct in6_addr *)src;
+ break;
+ default:
+ return NULL;
+ }
+ /* cannot direclty use &size because of strict aliasing rules */
+ return (WSAAddressToString((struct sockaddr *)&ss, sizeof(ss), NULL, dst, &s) == 0)? dst : NULL;
+}
+
#else /* !_WIN32 => UNIX */
#include <sys/types.h>
#ifdef ANDROID
@@ -137,27 +157,12 @@
namespace net
{
#ifdef _WIN32
- bool IsWindowsXPorLater ()
- {
- static bool isRequested = false;
- static bool isXP = false;
- if (!isRequested)
- {
- // request
- OSVERSIONINFO osvi;
-
- ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
-
- isXP = osvi.dwMajorVersion <= 5;
- isRequested = true;
- }
- return isXP;
- }
-
int GetMTUWindowsIpv4 (sockaddr_in inputAddress, int fallback)
{
+ typedef const char *(* IPN)(int af, const void *src, char *dst, socklen_t size);
+ IPN inetntop = (IPN)GetProcAddress (GetModuleHandle ("ws2_32.dll"), "InetNtop");
+ if (!inetntop) inetntop = inet_ntop_xp; // use own implementation if not found
+
ULONG outBufLen = 0;
PIP_ADAPTER_ADDRESSES pAddresses = nullptr;
PIP_ADAPTER_ADDRESSES pCurrAddresses = nullptr;
@@ -176,7 +181,7 @@
if(dwRetVal != NO_ERROR)
{
- LogPrint(eLogError, "NetIface: GetMTU(): Enclosed GetAdaptersAddresses() call has failed");
+ LogPrint(eLogError, "NetIface: GetMTU: Enclosed GetAdaptersAddresses() call has failed");
FREE(pAddresses);
return fallback;
}
@@ -188,7 +193,7 @@
pUnicast = pCurrAddresses->FirstUnicastAddress;
if(pUnicast == nullptr)
- LogPrint(eLogError, "NetIface: GetMTU(): Not a unicast IPv4 address, this is not supported");
+ LogPrint(eLogError, "NetIface: GetMTU: Not a unicast IPv4 address, this is not supported");
for(int i = 0; pUnicast != nullptr; ++i)
{
@@ -196,8 +201,13 @@
sockaddr_in* localInterfaceAddress = (sockaddr_in*) lpAddr;
if(localInterfaceAddress->sin_addr.S_un.S_addr == inputAddress.sin_addr.S_un.S_addr)
{
- auto result = pAddresses->Mtu;
+ char addr[INET_ADDRSTRLEN];
+ inetntop(AF_INET, &(((struct sockaddr_in *)localInterfaceAddress)->sin_addr), addr, INET_ADDRSTRLEN);
+
+ auto result = pCurrAddresses->Mtu;
FREE(pAddresses);
+ pAddresses = nullptr;
+ LogPrint(eLogInfo, "NetIface: GetMTU: Using ", result, " bytes for IPv4 address ", addr);
return result;
}
pUnicast = pUnicast->Next;
@@ -205,19 +215,23 @@
pCurrAddresses = pCurrAddresses->Next;
}
- LogPrint(eLogError, "NetIface: GetMTU(): No usable unicast IPv4 addresses found");
+ LogPrint(eLogError, "NetIface: GetMTU: No usable unicast IPv4 addresses found");
FREE(pAddresses);
return fallback;
}
int GetMTUWindowsIpv6 (sockaddr_in6 inputAddress, int fallback)
{
+ typedef const char *(* IPN)(int af, const void *src, char *dst, socklen_t size);
+ IPN inetntop = (IPN)GetProcAddress (GetModuleHandle ("ws2_32.dll"), "InetNtop");
+ if (!inetntop) inetntop = inet_ntop_xp; // use own implementation if not found
+
ULONG outBufLen = 0;
PIP_ADAPTER_ADDRESSES pAddresses = nullptr;
PIP_ADAPTER_ADDRESSES pCurrAddresses = nullptr;
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = nullptr;
- if(GetAdaptersAddresses(AF_INET6, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen)
+ if (GetAdaptersAddresses(AF_INET6, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen)
== ERROR_BUFFER_OVERFLOW)
{
FREE(pAddresses);
@@ -228,23 +242,23 @@
AF_INET6, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen
);
- if(dwRetVal != NO_ERROR)
+ if (dwRetVal != NO_ERROR)
{
- LogPrint(eLogError, "NetIface: GetMTU(): Enclosed GetAdaptersAddresses() call has failed");
+ LogPrint(eLogError, "NetIface: GetMTU: Enclosed GetAdaptersAddresses() call has failed");
FREE(pAddresses);
return fallback;
}
bool found_address = false;
pCurrAddresses = pAddresses;
- while(pCurrAddresses)
+ while (pCurrAddresses)
{
PIP_ADAPTER_UNICAST_ADDRESS firstUnicastAddress = pCurrAddresses->FirstUnicastAddress;
pUnicast = pCurrAddresses->FirstUnicastAddress;
- if(pUnicast == nullptr)
- LogPrint(eLogError, "NetIface: GetMTU(): Not a unicast IPv6 address, this is not supported");
+ if (pUnicast == nullptr)
+ LogPrint(eLogError, "NetIface: GetMTU: Not a unicast IPv6 address, this is not supported");
- for(int i = 0; pUnicast != nullptr; ++i)
+ for (int i = 0; pUnicast != nullptr; ++i)
{
LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr;
sockaddr_in6 *localInterfaceAddress = (sockaddr_in6*) lpAddr;
@@ -259,9 +273,13 @@
if (found_address)
{
- auto result = pAddresses->Mtu;
+ char addr[INET6_ADDRSTRLEN];
+ inetntop(AF_INET6, &(((struct sockaddr_in6 *)localInterfaceAddress)->sin6_addr), addr, INET6_ADDRSTRLEN);
+
+ auto result = pCurrAddresses->Mtu;
FREE(pAddresses);
pAddresses = nullptr;
+ LogPrint(eLogInfo, "NetIface: GetMTU: Using ", result, " bytes for IPv6 address ", addr);
return result;
}
pUnicast = pUnicast->Next;
@@ -270,7 +288,7 @@
pCurrAddresses = pCurrAddresses->Next;
}
- LogPrint(eLogError, "NetIface: GetMTU(): No usable unicast IPv6 addresses found");
+ LogPrint(eLogError, "NetIface: GetMTU: No usable unicast IPv6 addresses found");
FREE(pAddresses);
return fallback;
}
@@ -302,7 +320,7 @@
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/util.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -218,6 +218,7 @@
namespace net
{
int GetMTU (const boost::asio::ip::address& localAddress);
+ int GetMaxMTU (const boost::asio::ip::address_v6& localAddress); // check tunnel broker for ipv6 address
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false);
boost::asio::ip::address_v6 GetYggdrasilAddress ();
bool IsLocalAddress (const boost::asio::ip::address& addr);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd/version.h
^
|
@@ -16,7 +16,7 @@
#define MAKE_VERSION_NUMBER(a,b,c) ((a*100+b)*100+c)
#define I2PD_VERSION_MAJOR 2
-#define I2PD_VERSION_MINOR 41
+#define I2PD_VERSION_MINOR 43
#define I2PD_VERSION_MICRO 0
#define I2PD_VERSION_PATCH 0
#ifdef GITVER
@@ -27,15 +27,11 @@
#define VERSION I2PD_VERSION
-#ifdef MESHNET
-#define I2PD_NET_ID 3
-#else
#define I2PD_NET_ID 2
-#endif
#define I2P_VERSION_MAJOR 0
#define I2P_VERSION_MINOR 9
-#define I2P_VERSION_MICRO 53
+#define I2P_VERSION_MICRO 55
#define I2P_VERSION_PATCH 0
#define I2P_VERSION MAKE_VERSION(I2P_VERSION_MAJOR, I2P_VERSION_MINOR, I2P_VERSION_MICRO)
#define I2P_VERSION_NUMBER MAKE_VERSION_NUMBER(I2P_VERSION_MAJOR, I2P_VERSION_MINOR, I2P_VERSION_MICRO)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/AddressBook.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -299,7 +299,8 @@
}
AddressBook::AddressBook (): m_Storage(nullptr), m_IsLoaded (false), m_IsDownloading (false),
- m_NumRetries (0), m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr)
+ m_NumRetries (0), m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr),
+ m_IsEnabled (true)
{
}
@@ -310,12 +311,16 @@
void AddressBook::Start ()
{
- if (!m_Storage)
- m_Storage = new AddressBookFilesystemStorage;
- m_Storage->Init();
- LoadHosts (); /* try storage, then hosts.txt, then download */
- StartSubscriptions ();
- StartLookups ();
+ i2p::config::GetOption("addressbook.enabled", m_IsEnabled);
+ if (m_IsEnabled)
+ {
+ if (!m_Storage)
+ m_Storage = new AddressBookFilesystemStorage;
+ m_Storage->Init();
+ LoadHosts (); /* try storage, then hosts.txt, then download */
+ StartSubscriptions ();
+ StartLookups ();
+ }
}
void AddressBook::StartResolvers ()
@@ -370,9 +375,10 @@
pos = address.find (".i2p");
if (pos != std::string::npos)
{
+ if (!m_IsEnabled) return nullptr;
auto addr = FindAddress (address);
if (!addr)
- LookupAddress (address); // TODO:
+ LookupAddress (address); // TODO:
return addr;
}
}
@@ -494,7 +500,7 @@
auto it = m_Addresses.find (name);
if (it != m_Addresses.end ()) // already exists ?
{
- if (it->second->IsIdentHash () && it->second->identHash != ident->GetIdentHash () && // address changed?
+ if (it->second->IsIdentHash () && it->second->identHash != ident->GetIdentHash () && // address changed?
ident->GetSigningKeyType () != i2p::data::SIGNING_KEY_TYPE_DSA_SHA1) // don't replace by DSA
{
it->second->identHash = ident->GetIdentHash ();
@@ -858,9 +864,9 @@
if (!m_LastModified.empty())
req.AddHeader("If-Modified-Since", m_LastModified);
/* convert url to relative */
- url.schema = "";
- url.host = "";
- req.uri = url.to_string();
+ url.schema = "";
+ url.host = "";
+ req.uri = url.to_string();
req.version = "HTTP/1.1";
auto stream = i2p::client::context.GetSharedLocalDestination ()->CreateStream (leaseSet, dest_port);
std::string request = req.to_string();
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/AddressBook.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -116,7 +116,7 @@
private:
std::mutex m_AddressBookMutex;
- std::map<std::string, std::shared_ptr<Address> > m_Addresses;
+ std::map<std::string, std::shared_ptr<Address> > m_Addresses;
std::map<i2p::data::IdentHash, std::shared_ptr<AddressResolver> > m_Resolvers; // local destination->resolver
std::mutex m_LookupsMutex;
std::map<uint32_t, std::string> m_Lookups; // nonce -> address
@@ -126,6 +126,7 @@
std::vector<std::shared_ptr<AddressBookSubscription> > m_Subscriptions;
std::shared_ptr<AddressBookSubscription> m_DefaultSubscription; // in case if we don't know any addresses yet
boost::asio::deadline_timer * m_SubscriptionsUpdateTimer;
+ bool m_IsEnabled;
};
class AddressBookSubscription
@@ -162,7 +163,7 @@
private:
std::shared_ptr<ClientDestination> m_LocalDestination;
- std::map<std::string, i2p::data::IdentHash> m_LocalAddresses;
+ std::map<std::string, i2p::data::IdentHash> m_LocalAddresses;
};
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/BOB.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2020, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -168,7 +168,7 @@
m_LocalDestination (localDestination),
m_OutboundTunnel (nullptr), m_InboundTunnel (nullptr),
m_Nickname(nickname), m_InHost(inhost), m_OutHost(outhost),
- m_InPort(inport), m_OutPort(outport), m_Quiet(quiet)
+ m_InPort(inport), m_OutPort(outport), m_Quiet(quiet), m_IsRunning(false)
{
}
@@ -183,6 +183,7 @@
{
if (m_OutboundTunnel) m_OutboundTunnel->Start ();
if (m_InboundTunnel) m_InboundTunnel->Start ();
+ m_IsRunning = true;
}
void BOBDestination::Stop ()
@@ -193,6 +194,7 @@
void BOBDestination::StopTunnels ()
{
+ m_IsRunning = false;
if (m_OutboundTunnel)
{
m_OutboundTunnel->Stop ();
@@ -361,7 +363,7 @@
const auto issetStr = [](const std::string &str) { return str.empty() ? "not_set" : str; }; // for inhost, outhost
const auto issetNum = [&issetStr](const int p) { return issetStr(p == 0 ? "" : std::to_string(p)); }; // for inport, outport
const auto destExists = [](const BOBDestination * const dest) { return dest != nullptr; };
- const auto destReady = [](const BOBDestination * const dest) { return dest->GetLocalDestination()->IsReady(); };
+ const auto destReady = [](const BOBDestination * const dest) { return dest->IsRunning(); };
const auto bool_str = [](const bool v) { return v ? "true" : "false"; }; // bool -> str
// tunnel info
@@ -479,26 +481,43 @@
void BOBCommandSession::SetNickCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: setnick ", operand);
- m_Nickname = operand;
- std::string msg ("Nickname set to ");
- msg += m_Nickname;
- SendReplyOK (msg.c_str ());
+ if(*operand)
+ {
+ auto dest = m_Owner.FindDestination (operand);
+ if (!dest)
+ {
+ m_Nickname = operand;
+ std::string msg ("Nickname set to ");
+ msg += m_Nickname;
+ SendReplyOK (msg.c_str ());
+ }
+ else
+ SendReplyError ("tunnel is active");
+ }
+ else
+ SendReplyError ("no nickname has been set");
}
void BOBCommandSession::GetNickCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: getnick ", operand);
- m_CurrentDestination = m_Owner.FindDestination (operand);
- if (m_CurrentDestination)
- {
- m_Keys = m_CurrentDestination->GetKeys ();
- m_Nickname = operand;
- }
- if (m_Nickname == operand)
+ if(*operand)
{
- std::string msg ("Nickname set to ");
- msg += m_Nickname;
- SendReplyOK (msg.c_str ());
+ m_CurrentDestination = m_Owner.FindDestination (operand);
+ if (m_CurrentDestination)
+ {
+ m_Keys = m_CurrentDestination->GetKeys ();
+ m_IsActive = m_CurrentDestination->IsRunning ();
+ m_Nickname = operand;
+ }
+ if (m_Nickname == operand)
+ {
+ std::string msg ("Nickname set to ");
+ msg += m_Nickname;
+ SendReplyOK (msg.c_str ());
+ }
+ else
+ SendReplyError ("no nickname has been set");
}
else
SendReplyError ("no nickname has been set");
@@ -535,7 +554,7 @@
void BOBCommandSession::SetkeysCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: setkeys ", operand);
- if (m_Keys.FromBase64 (operand))
+ if (*operand && m_Keys.FromBase64 (operand))
SendReplyOK (m_Keys.GetPublic ()->ToBase64 ().c_str ());
else
SendReplyError ("invalid keys");
@@ -562,35 +581,55 @@
void BOBCommandSession::OuthostCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: outhost ", operand);
- m_OutHost = operand;
- SendReplyOK ("outhost set");
+ if (*operand)
+ {
+ m_OutHost = operand;
+ SendReplyOK ("outhost set");
+ }
+ else
+ SendReplyError ("empty outhost");
}
void BOBCommandSession::OutportCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: outport ", operand);
- m_OutPort = std::stoi(operand);
- if (m_OutPort >= 0)
- SendReplyOK ("outbound port set");
+ if (*operand)
+ {
+ m_OutPort = std::stoi(operand);
+ if (m_OutPort >= 0)
+ SendReplyOK ("outbound port set");
+ else
+ SendReplyError ("port out of range");
+ }
else
- SendReplyError ("port out of range");
+ SendReplyError ("empty outport");
}
void BOBCommandSession::InhostCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: inhost ", operand);
- m_InHost = operand;
- SendReplyOK ("inhost set");
+ if (*operand)
+ {
+ m_InHost = operand;
+ SendReplyOK ("inhost set");
+ }
+ else
+ SendReplyError ("empty inhost");
}
void BOBCommandSession::InportCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: inport ", operand);
- m_InPort = std::stoi(operand);
- if (m_InPort >= 0)
- SendReplyOK ("inbound port set");
+ if (*operand)
+ {
+ m_InPort = std::stoi(operand);
+ if (m_InPort >= 0)
+ SendReplyOK ("inbound port set");
+ else
+ SendReplyError ("port out of range");
+ }
else
- SendReplyError ("port out of range");
+ SendReplyError ("empty inport");
}
void BOBCommandSession::QuietCommandHandler (const char * operand, size_t len)
@@ -613,52 +652,62 @@
void BOBCommandSession::LookupCommandHandler (const char * operand, size_t len)
{
LogPrint (eLogDebug, "BOB: lookup ", operand);
- auto addr = context.GetAddressBook ().GetAddress (operand);
- if (!addr)
- {
- SendReplyError ("Address Not found");
- return;
- }
- auto localDestination = m_CurrentDestination ? m_CurrentDestination->GetLocalDestination () : i2p::client::context.GetSharedLocalDestination ();
- if (addr->IsIdentHash ())
+ if (*operand)
{
- // we might have leaseset already
- auto leaseSet = localDestination->FindLeaseSet (addr->identHash);
- if (leaseSet)
+ auto addr = context.GetAddressBook ().GetAddress (operand);
+ if (!addr)
{
- SendReplyOK (leaseSet->GetIdentity ()->ToBase64 ().c_str ());
+ SendReplyError ("Address Not found");
return;
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/BOB.h
^
|
@@ -163,6 +163,7 @@
int GetInPort() const { return m_InPort; }
int GetOutPort() const { return m_OutPort; }
bool GetQuiet() const { return m_Quiet; }
+ bool IsRunning() const { return m_IsRunning; }
const i2p::data::PrivateKeys& GetKeys () const { return m_LocalDestination->GetPrivateKeys (); };
std::shared_ptr<ClientDestination> GetLocalDestination () const { return m_LocalDestination; };
@@ -176,6 +177,7 @@
std::string m_InHost, m_OutHost;
int m_InPort, m_OutPort;
bool m_Quiet;
+ bool m_IsRunning;
};
class BOBCommandChannel;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/ClientContext.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -455,6 +455,8 @@
options[I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, DEFAULT_OUTBOUND_TUNNEL_LENGTH);
options[I2CP_PARAM_INBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, DEFAULT_INBOUND_TUNNELS_QUANTITY);
options[I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, DEFAULT_OUTBOUND_TUNNELS_QUANTITY);
+ options[I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE] = GetI2CPOption (section, I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE, DEFAULT_INBOUND_TUNNELS_LENGTH_VARIANCE);
+ options[I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE, DEFAULT_OUTBOUND_TUNNELS_LENGTH_VARIANCE);
options[I2CP_PARAM_TAGS_TO_SEND] = GetI2CPOption (section, I2CP_PARAM_TAGS_TO_SEND, DEFAULT_TAGS_TO_SEND);
options[I2CP_PARAM_MIN_TUNNEL_LATENCY] = GetI2CPOption(section, I2CP_PARAM_MIN_TUNNEL_LATENCY, DEFAULT_MIN_TUNNEL_LATENCY);
options[I2CP_PARAM_MAX_TUNNEL_LATENCY] = GetI2CPOption(section, I2CP_PARAM_MAX_TUNNEL_LATENCY, DEFAULT_MAX_TUNNEL_LATENCY);
@@ -487,10 +489,14 @@
options[I2CP_PARAM_INBOUND_TUNNEL_LENGTH] = value;
if (i2p::config::GetOption(prefix + I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, value))
options[I2CP_PARAM_INBOUND_TUNNELS_QUANTITY] = value;
+ if (i2p::config::GetOption(prefix + I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE, value))
+ options[I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE] = value;
if (i2p::config::GetOption(prefix + I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, value))
options[I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH] = value;
if (i2p::config::GetOption(prefix + I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, value))
options[I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY] = value;
+ if (i2p::config::GetOption(prefix + I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE, value))
+ options[I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE] = value;
if (i2p::config::GetOption(prefix + I2CP_PARAM_MIN_TUNNEL_LATENCY, value))
options[I2CP_PARAM_MIN_TUNNEL_LATENCY] = value;
if (i2p::config::GetOption(prefix + I2CP_PARAM_MAX_TUNNEL_LATENCY, value))
@@ -602,21 +608,29 @@
if (type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT) {
// udp client
// TODO: hostnames
- boost::asio::ip::udp::endpoint end(boost::asio::ip::address::from_string(address), port);
+ boost::asio::ip::udp::endpoint end (boost::asio::ip::address::from_string(address), port);
if (!localDestination)
localDestination = m_SharedLocalDestination;
bool gzip = section.second.get (I2P_CLIENT_TUNNEL_GZIP, true);
- auto clientTunnel = std::make_shared<I2PUDPClientTunnel>(name, dest, end, localDestination, destinationPort, gzip);
+ auto clientTunnel = std::make_shared<I2PUDPClientTunnel> (name, dest, end, localDestination, destinationPort, gzip);
- auto ins = m_ClientForwards.insert(std::make_pair(end, clientTunnel));
+ auto ins = m_ClientForwards.insert (std::make_pair (end, clientTunnel));
if (ins.second)
{
- clientTunnel->Start();
+ clientTunnel->Start ();
numClientTunnels++;
}
else
{
+ // TODO: update
+ if (ins.first->second->GetLocalDestination () != clientTunnel->GetLocalDestination ())
+ {
+ LogPrint (eLogInfo, "Clients: I2P UDP client tunnel destination updated");
+ ins.first->second->Stop ();
+ ins.first->second->SetLocalDestination (clientTunnel->GetLocalDestination ());
+ ins.first->second->Start ();
+ }
ins.first->second->isUpdated = true;
LogPrint(eLogError, "Clients: I2P Client forward for endpoint ", end, " already exists");
}
@@ -850,6 +864,8 @@
uint16_t httpProxyPort; i2p::config::GetOption("httpproxy.port", httpProxyPort);
std::string httpOutProxyURL; i2p::config::GetOption("httpproxy.outproxy", httpOutProxyURL);
bool httpAddresshelper; i2p::config::GetOption("httpproxy.addresshelper", httpAddresshelper);
+ if (httpAddresshelper)
+ i2p::config::GetOption("addressbook.enabled", httpAddresshelper); // addresshelper is not supported without address book
i2p::data::SigningKeyType sigType; i2p::config::GetOption("httpproxy.signaturetype", sigType);
LogPrint(eLogInfo, "Clients: Starting HTTP Proxy at ", httpProxyAddr, ":", httpProxyPort);
if (httpProxyKeys.length () > 0)
@@ -884,7 +900,7 @@
bool socksproxy; i2p::config::GetOption("socksproxy.enabled", socksproxy);
if (socksproxy)
{
- std::string httpProxyKeys; i2p::config::GetOption("httpproxy.keys", httpProxyKeys);
+ std::string httpProxyKeys; i2p::config::GetOption("httpproxy.keys", httpProxyKeys);
// we still need httpProxyKeys to compare with sockProxyKeys
std::string socksProxyKeys; i2p::config::GetOption("socksproxy.keys", socksProxyKeys);
std::string socksProxyAddr; i2p::config::GetOption("socksproxy.address", socksProxyAddr);
@@ -970,11 +986,11 @@
}
}
- /* // TODO: Write correct UDP tunnels stop
+ // TODO: Write correct UDP tunnels stop
for (auto it = m_ClientForwards.begin (); it != m_ClientForwards.end ();)
{
if(clean && !it->second->isUpdated) {
- it->second = nullptr;
+ it->second->Stop ();
it = m_ClientForwards.erase(it);
} else {
it->second->isUpdated = false;
@@ -985,13 +1001,13 @@
for (auto it = m_ServerForwards.begin (); it != m_ServerForwards.end ();)
{
if(clean && !it->second->isUpdated) {
- it->second = nullptr;
+ it->second->Stop ();
it = m_ServerForwards.erase(it);
} else {
it->second->isUpdated = false;
it++;
}
- } */
+ }
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/ClientContext.h
^
|
@@ -142,8 +142,8 @@
i2p::proxy::HTTPProxy * m_HttpProxy;
i2p::proxy::SOCKSProxy * m_SocksProxy;
- std::map<boost::asio::ip::tcp::endpoint, std::shared_ptr<I2PService> > m_ClientTunnels; // local endpoint->tunnel
- std::map<std::pair<i2p::data::IdentHash, int>, std::shared_ptr<I2PServerTunnel> > m_ServerTunnels; // <destination,port>->tunnel
+ std::map<boost::asio::ip::tcp::endpoint, std::shared_ptr<I2PService> > m_ClientTunnels; // local endpoint -> tunnel
+ std::map<std::pair<i2p::data::IdentHash, int>, std::shared_ptr<I2PServerTunnel> > m_ServerTunnels; // <destination,port> -> tunnel
std::mutex m_ForwardsMutex;
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<I2PUDPClientTunnel> > m_ClientForwards; // local endpoint -> udp tunnel
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/HTTPProxy.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -32,7 +32,13 @@
namespace i2p {
namespace proxy {
- std::map<std::string, std::string> jumpservices = {
+ static const std::vector<std::string> jumporder = {
+ "reg.i2p",
+ "stats.i2p",
+ "identiguy.i2p",
+ };
+
+ static const std::map<std::string, std::string> jumpservices = {
{ "reg.i2p", "http://shx5vqsw7usdaunyzr2qmes2fq37oumybpudrd4jjj4e4vk4uusa.b32.i2p/jump/" },
{ "identiguy.i2p", "http://3mzmrus2oron5fxptw7hw2puho3bnqmw2hqy7nw64dsrrjwdilva.b32.i2p/cgi-bin/query?hostname=" },
{ "stats.i2p", "http://7tbay5p4kzeekxvyvbf6v7eauazemsnnl2aoyqhg5jzpr5eke7tq.b32.i2p/cgi-bin/jump.cgi?a=" },
@@ -174,8 +180,11 @@
<< "<p>" << tr("Remote host not found in router's addressbook") << "</p>\r\n"
<< "<p>" << tr("You may try to find this host on jump services below") << ":</p>\r\n"
<< "<ul>\r\n";
- for (const auto& js : jumpservices) {
- ss << " <li><a href=\"" << js.second << host << "\">" << js.first << "</a></li>\r\n";
+ for (const auto& jump : jumporder)
+ {
+ auto js = jumpservices.find (jump);
+ if (js != jumpservices.end())
+ ss << " <li><a href=\"" << js->second << host << "\">" << js->first << "</a></li>\r\n";
}
ss << "</ul>\r\n";
std::string content = ss.str();
@@ -237,14 +246,14 @@
/**
* according to i2p ticket #1862:
- * leave Referrer if requested URL with same schema, host and port,
+ * leave Referer if requested URL with same schema, host and port,
* otherwise, drop it.
*/
- if(req.GetHeader("Referrer") != "") {
+ if(req.GetHeader("Referer") != "") {
i2p::http::URL reqURL; reqURL.parse(req.uri);
- i2p::http::URL refURL; refURL.parse(req.GetHeader("Referrer"));
+ i2p::http::URL refURL; refURL.parse(req.GetHeader("Referer"));
if(!boost::iequals(reqURL.schema, refURL.schema) || !boost::iequals(reqURL.host, refURL.host) || reqURL.port != refURL.port)
- req.RemoveHeader("Referrer");
+ req.RemoveHeader("Referer");
}
/* add headers */
@@ -304,7 +313,7 @@
std::string full_url = m_RequestURL.to_string();
std::stringstream ss;
ss << tr("Host") << " " << m_RequestURL.host << " <font color=red>" << tr("already in router's addressbook") << "</font>. ";
- ss << tr("Click here to update record:") << " <a href=\"" << full_url << (full_url.find('?') != std::string::npos ? "&i2paddresshelper=" : "?i2paddresshelper=");
+ ss << tr(/* tr: The "record" means addressbook's record. That message appears when domain was already added to addressbook, but helper link is opened for it. */ "Click here to update record:" ) << " <a href=\"" << full_url << (full_url.find('?') != std::string::npos ? "&i2paddresshelper=" : "?i2paddresshelper=");
ss << jump << "&update=true\">" << tr("Continue") << "</a>.";
GenericProxyInfo(tr("Addresshelper found"), ss.str());
return true; /* request processed */
@@ -413,8 +422,8 @@
void HTTPReqHandler::ForwardToUpstreamProxy()
{
LogPrint(eLogDebug, "HTTPProxy: Forwarded to upstream");
- // build http request
+ /* build http request */
m_ClientRequestURL = m_RequestURL;
LogPrint(eLogDebug, "HTTPProxy: ", m_ClientRequestURL.host);
m_ClientRequestURL.schema = "";
@@ -422,17 +431,17 @@
std::string origURI = m_ClientRequest.uri; // TODO: what do we need to change uri for?
m_ClientRequest.uri = m_ClientRequestURL.to_string();
- // update User-Agent to ESR version of Firefox, same as Tor Browser below version 8, for non-HTTPS connections
+ /* update User-Agent to ESR version of Firefox, same as Tor Browser below version 8, for non-HTTPS connections */
if(m_ClientRequest.method != "CONNECT")
m_ClientRequest.UpdateHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0");
m_ClientRequest.write(m_ClientRequestBuffer);
m_ClientRequestBuffer << m_recv_buf.substr(m_req_len);
- // assume http if empty schema
+ /* assume http if empty schema */
if (m_ProxyURL.schema == "" || m_ProxyURL.schema == "http")
{
- // handle upstream http proxy
+ /* handle upstream http proxy */
if (!m_ProxyURL.port) m_ProxyURL.port = 80;
if (m_ProxyURL.is_i2p())
{
@@ -440,9 +449,9 @@
auto auth = i2p::http::CreateBasicAuthorizationString (m_ProxyURL.user, m_ProxyURL.pass);
if (!auth.empty ())
{
- // remove existing authorization if any
+ /* remove existing authorization if any */
m_ClientRequest.RemoveHeader("Proxy-");
- // add own http proxy authorization
+ /* add own http proxy authorization */
m_ClientRequest.AddHeader("Proxy-Authorization", auth);
}
m_send_buf = m_ClientRequest.to_string();
@@ -461,7 +470,7 @@
}
else if (m_ProxyURL.schema == "socks")
{
- // handle upstream socks proxy
+ /* handle upstream socks proxy */
if (!m_ProxyURL.port) m_ProxyURL.port = 9050; // default to tor default if not specified
boost::asio::ip::tcp::resolver::query q(m_ProxyURL.host, std::to_string(m_ProxyURL.port));
m_proxy_resolver.async_resolve(q, std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this, std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep) {
@@ -470,7 +479,7 @@
}
else
{
- // unknown type, complain
+ /* unknown type, complain */
GenericProxyError(tr("unknown outproxy url"), m_ProxyURL.to_string());
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/I2CP.cpp
^
|
@@ -24,7 +24,7 @@
{
I2CPDestination::I2CPDestination (boost::asio::io_service& service, std::shared_ptr<I2CPSession> owner,
- std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params):
+ std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params):
LeaseSetDestination (service, isPublic, ¶ms),
m_Owner (owner), m_Identity (identity), m_EncryptionKeyType (m_Identity->GetCryptoKeyType ()),
m_IsCreatingLeaseSet (false), m_LeaseSetCreationTimer (service)
@@ -208,12 +208,12 @@
if (leases.empty ())
leases = remote->GetNonExpiredLeases (true); // with threshold
if (!leases.empty ())
- {
+ {
remoteLease = leases[rand () % leases.size ()];
auto leaseRouter = i2p::data::netdb.FindRouter (remoteLease->tunnelGateway);
outboundTunnel = GetTunnelPool ()->GetNextOutboundTunnel (nullptr,
leaseRouter ? leaseRouter->GetCompatibleTransports (false) : (i2p::data::RouterInfo::CompatibleTransports)i2p::data::RouterInfo::eAllTransports);
- }
+ }
if (remoteLease && outboundTunnel)
remoteSession->SetSharedRoutingPath (std::make_shared<i2p::garlic::GarlicRoutingPath> (
i2p::garlic::GarlicRoutingPath{outboundTunnel, remoteLease, 10000, 0, 0})); // 10 secs RTT
@@ -453,8 +453,8 @@
{
auto len = m_SendQueue.Get (m_SendBuffer, I2CP_MAX_MESSAGE_LENGTH);
boost::asio::async_write (*socket, boost::asio::buffer (m_SendBuffer, len),
- boost::asio::transfer_all (),std::bind(&I2CPSession::HandleI2CPMessageSent,
- shared_from_this (), std::placeholders::_1, std::placeholders::_2));
+ boost::asio::transfer_all (),std::bind(&I2CPSession::HandleI2CPMessageSent,
+ shared_from_this (), std::placeholders::_1, std::placeholders::_2));
}
else
m_IsSending = false;
@@ -538,7 +538,7 @@
LogPrint (eLogError, "I2CP: Create session duplicate address ", identity->GetIdentHash ().ToBase32 ());
SendSessionStatusMessage (eI2CPSessionStatusInvalid); // invalid
return;
- }
+ }
uint16_t optionsSize = bufbe16toh (buf + offset);
offset += 2;
if (optionsSize > len - offset)
@@ -561,16 +561,16 @@
std::make_shared<I2CPDestination>(m_Owner.GetService (), shared_from_this (), identity, true, params):
std::make_shared<RunnableI2CPDestination>(shared_from_this (), identity, true, params);
if (m_Owner.InsertSession (shared_from_this ()))
- {
+ {
SendSessionStatusMessage (eI2CPSessionStatusCreated); // created
LogPrint (eLogDebug, "I2CP: Session ", m_SessionID, " created");
m_Destination->Start ();
- }
+ }
else
{
LogPrint (eLogError, "I2CP: Session already exists");
SendSessionStatusMessage (eI2CPSessionStatusRefused);
- }
+ }
}
else
{
@@ -712,7 +712,7 @@
{
if (offset + 4 > len) return;
uint16_t keyType = bufbe16toh (buf + offset); offset += 2; // encryption type
- uint16_t keyLen = bufbe16toh (buf + offset); offset += 2; // private key length
+ uint16_t keyLen = bufbe16toh (buf + offset); offset += 2; // private key length
if (offset + keyLen > len) return;
if (keyType == i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD)
m_Destination->SetECIESx25519EncryptionPrivateKey (buf + offset);
@@ -1030,13 +1030,13 @@
for (const auto& it: m_Sessions)
{
if (it.second)
- {
+ {
auto dest = it.second->GetDestination ();
if (dest && dest->GetIdentHash () == ident)
return it.second;
- }
+ }
}
return nullptr;
- }
+ }
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/I2CP.h
^
|
@@ -69,7 +69,7 @@
eI2CPSessionStatusInvalid = 3,
eI2CPSessionStatusRefused = 4
};
-
+
// params
const char I2CP_PARAM_MESSAGE_RELIABILITY[] = "i2cp.messageReliability";
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/I2PTunnel.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -7,6 +7,7 @@
*/
#include <cassert>
+#include <boost/algorithm/string.hpp>
#include "Base.h"
#include "Log.h"
#include "Destination.h"
@@ -340,7 +341,7 @@
m_InHeader.clear ();
m_InHeader.write ((const char *)buf, len);
std::string line;
- bool endOfHeader = false;
+ bool endOfHeader = false, connection = false;
while (!endOfHeader)
{
std::getline(m_InHeader, line);
@@ -349,9 +350,33 @@
if (line == "\r") endOfHeader = true;
else
{
- if (m_Host.length () > 0 && !line.compare(0, 5, "Host:"))
+ // strip up some headers
+ static const std::vector<std::string> excluded // list of excluded headers
+ {
+ "Keep-Alive:", "X-I2P"
+ };
+ bool matched = false;
+ for (const auto& it: excluded)
+ if (boost::iequals (line.substr (0, it.length ()), it))
+ {
+ matched = true;
+ break;
+ }
+ if (matched) break;
+
+ // replace some headers
+ if (!m_Host.empty () && boost::iequals (line.substr (0, 5), "Host:"))
m_OutHeader << "Host: " << m_Host << "\r\n"; // override host
- else
+ else if (boost::iequals (line.substr (0, 11), "Connection:"))
+ {
+ auto x = line.find("pgrade");
+ if (x != std::string::npos && x && std::tolower(line[x - 1]) != 'u') // upgrade or Upgrade
+ m_OutHeader << line << "\n";
+ else
+ m_OutHeader << "Connection: close\r\n";
+ connection = true;
+ }
+ else // forward as is
m_OutHeader << line << "\n";
}
}
@@ -361,6 +386,9 @@
if (endOfHeader)
{
+ // add Connection if not presented
+ if (!connection)
+ m_OutHeader << "Connection: close\r\n";
// add X-I2P fields
if (m_From)
{
@@ -583,7 +611,7 @@
{
if (m_KeepAliveTimer)
{
- m_KeepAliveTimer->expires_from_now (boost::posix_time::seconds(m_KeepAliveInterval));
+ m_KeepAliveTimer->expires_from_now (boost::posix_time::seconds (m_KeepAliveInterval));
m_KeepAliveTimer->async_wait (std::bind (&I2PClientTunnel::HandleKeepAliveTimer,
this, std::placeholders::_1));
}
@@ -632,6 +660,12 @@
void I2PServerTunnel::Stop ()
{
+ if (m_PortDestination)
+ m_PortDestination->ResetAcceptor ();
+ auto localDestination = GetLocalDestination ();
+ if (localDestination)
+ localDestination->StopAcceptingStreams ();
+
ClearHandlers ();
}
@@ -796,7 +830,8 @@
}
}
- void I2PUDPServerTunnel::ExpireStale(const uint64_t delta) {
+ void I2PUDPServerTunnel::ExpireStale(const uint64_t delta)
+ {
std::lock_guard<std::mutex> lock(m_SessionsMutex);
uint64_t now = i2p::util::GetMillisecondsSinceEpoch();
auto itr = m_Sessions.begin();
@@ -808,7 +843,8 @@
}
}
- void I2PUDPClientTunnel::ExpireStale(const uint64_t delta) {
+ void I2PUDPClientTunnel::ExpireStale(const uint64_t delta)
+ {
std::lock_guard<std::mutex> lock(m_SessionsMutex);
uint64_t now = i2p::util::GetMillisecondsSinceEpoch();
std::vector<uint16_t> removePorts;
@@ -864,7 +900,8 @@
Receive();
}
- void UDPSession::Receive() {
+ void UDPSession::Receive()
+ {
LogPrint(eLogDebug, "UDPSession: Receive");
IPSocket.async_receive_from(boost::asio::buffer(m_Buffer, I2P_UDP_MAX_MTU),
FromEndpoint, std::bind(&UDPSession::HandleReceived, this, std::placeholders::_1, std::placeholders::_2));
@@ -901,227 +938,241 @@
LogPrint(eLogError, "UDPSession: ", ecode.message());
}
- I2PUDPServerTunnel::I2PUDPServerTunnel(const std::string & name, std::shared_ptr<i2p::client::ClientDestination> localDestination,
+ I2PUDPServerTunnel::I2PUDPServerTunnel (const std::string & name, std::shared_ptr<i2p::client::ClientDestination> localDestination,
boost::asio::ip::address localAddress, boost::asio::ip::udp::endpoint forwardTo, uint16_t port, bool gzip) :
- m_IsUniqueLocal(true),
- m_Name(name),
- m_LocalAddress(localAddress),
- m_RemoteEndpoint(forwardTo)
+ m_IsUniqueLocal (true), m_Name (name), m_LocalAddress (localAddress),
+ m_RemoteEndpoint (forwardTo), m_LocalDest (localDestination), m_Gzip (gzip)
{
- m_LocalDest = localDestination;
- m_LocalDest->Start();
- auto dgram = m_LocalDest->CreateDatagramDestination(gzip);
- dgram->SetReceiver(std::bind(&I2PUDPServerTunnel::HandleRecvFromI2P, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
- dgram->SetRawReceiver(std::bind(&I2PUDPServerTunnel::HandleRecvFromI2PRaw, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
}
- I2PUDPServerTunnel::~I2PUDPServerTunnel()
+ I2PUDPServerTunnel::~I2PUDPServerTunnel ()
{
- auto dgram = m_LocalDest->GetDatagramDestination();
- if (dgram) dgram->ResetReceiver();
+ Stop ();
+ }
+
+ void I2PUDPServerTunnel::Start ()
+ {
+ m_LocalDest->Start ();
- LogPrint(eLogInfo, "UDPServer: Done");
+ auto dgram = m_LocalDest->CreateDatagramDestination (m_Gzip);
+ dgram->SetReceiver (std::bind (&I2PUDPServerTunnel::HandleRecvFromI2P, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
+ dgram->SetRawReceiver (std::bind (&I2PUDPServerTunnel::HandleRecvFromI2PRaw, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
}
- void I2PUDPServerTunnel::Start()
+ void I2PUDPServerTunnel::Stop ()
{
- m_LocalDest->Start();
+ auto dgram = m_LocalDest->GetDatagramDestination ();
+ if (dgram) dgram->ResetReceiver ();
}
- std::vector<std::shared_ptr<DatagramSessionInfo> > I2PUDPServerTunnel::GetSessions()
+ std::vector<std::shared_ptr<DatagramSessionInfo> > I2PUDPServerTunnel::GetSessions ()
{
std::vector<std::shared_ptr<DatagramSessionInfo> > sessions;
- std::lock_guard<std::mutex> lock(m_SessionsMutex);
+ std::lock_guard<std::mutex> lock (m_SessionsMutex);
- for ( UDPSessionPtr s : m_Sessions )
+ for (UDPSessionPtr s: m_Sessions)
{
if (!s->m_Destination) continue;
- auto info = s->m_Destination->GetInfoForRemote(s->Identity);
- if(!info) continue;
+ auto info = s->m_Destination->GetInfoForRemote (s->Identity);
+ if (!info) continue;
- auto sinfo = std::make_shared<DatagramSessionInfo>();
+ auto sinfo = std::make_shared<DatagramSessionInfo> ();
sinfo->Name = m_Name;
- sinfo->LocalIdent = std::make_shared<i2p::data::IdentHash>(m_LocalDest->GetIdentHash().data());
- sinfo->RemoteIdent = std::make_shared<i2p::data::IdentHash>(s->Identity.data());
+ sinfo->LocalIdent = std::make_shared<i2p::data::IdentHash> (m_LocalDest->GetIdentHash ().data ());
+ sinfo->RemoteIdent = std::make_shared<i2p::data::IdentHash> (s->Identity.data ());
sinfo->CurrentIBGW = info->IBGW;
sinfo->CurrentOBEP = info->OBEP;
- sessions.push_back(sinfo);
+ sessions.push_back (sinfo);
}
return sessions;
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/I2PTunnel.h
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -31,7 +31,7 @@
const int I2P_TUNNEL_CONNECTION_MAX_IDLE = 3600; // in seconds
const int I2P_TUNNEL_DESTINATION_REQUEST_TIMEOUT = 10; // in seconds
// for HTTP tunnels
- const char X_I2P_DEST_HASH[] = "X-I2P-DestHash"; // hash in base64
+ const char X_I2P_DEST_HASH[] = "X-I2P-DestHash"; // hash in base64
const char X_I2P_DEST_B64[] = "X-I2P-DestB64"; // full address in base64
const char X_I2P_DEST_B32[] = "X-I2P-DestB32"; // .b32.i2p address
@@ -43,7 +43,7 @@
std::shared_ptr<const i2p::data::LeaseSet> leaseSet, int port = 0); // to I2P
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
std::shared_ptr<i2p::stream::Stream> stream); // to I2P using simplified API
- I2PTunnelConnection (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
+ I2PTunnelConnection (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
const boost::asio::ip::tcp::endpoint& target, bool quiet = true); // from I2P
~I2PTunnelConnection ();
void I2PConnect (const uint8_t * msg = nullptr, size_t len = 0);
@@ -230,25 +230,27 @@
{
public:
- I2PUDPServerTunnel(const std::string & name,
+ I2PUDPServerTunnel (const std::string & name,
std::shared_ptr<i2p::client::ClientDestination> localDestination,
boost::asio::ip::address localAddress,
boost::asio::ip::udp::endpoint forwardTo, uint16_t port, bool gzip);
- ~I2PUDPServerTunnel();
+ ~I2PUDPServerTunnel ();
+
/** expire stale udp conversations */
- void ExpireStale(const uint64_t delta=I2P_UDP_SESSION_TIMEOUT);
- void Start();
- const char * GetName() const { return m_Name.c_str(); }
- std::vector<std::shared_ptr<DatagramSessionInfo> > GetSessions();
+ void ExpireStale (const uint64_t delta=I2P_UDP_SESSION_TIMEOUT);
+ void Start ();
+ void Stop ();
+ const char * GetName () const { return m_Name.c_str(); }
+ std::vector<std::shared_ptr<DatagramSessionInfo> > GetSessions ();
std::shared_ptr<ClientDestination> GetLocalDestination () const { return m_LocalDest; }
- void SetUniqueLocal(bool isUniqueLocal = true) { m_IsUniqueLocal = isUniqueLocal; }
+ void SetUniqueLocal (bool isUniqueLocal = true) { m_IsUniqueLocal = isUniqueLocal; }
private:
- void HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
+ void HandleRecvFromI2P (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
void HandleRecvFromI2PRaw (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
- UDPSessionPtr ObtainUDPSession(const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort);
+ UDPSessionPtr ObtainUDPSession (const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort);
private:
@@ -260,6 +262,7 @@
std::vector<UDPSessionPtr> m_Sessions;
std::shared_ptr<i2p::client::ClientDestination> m_LocalDest;
UDPSessionPtr m_LastSession;
+ bool m_Gzip;
public:
@@ -270,27 +273,36 @@
{
public:
- I2PUDPClientTunnel(const std::string & name, const std::string &remoteDest,
+ I2PUDPClientTunnel (const std::string & name, const std::string &remoteDest,
boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination,
uint16_t remotePort, bool gzip);
- ~I2PUDPClientTunnel();
- void Start();
- const char * GetName() const { return m_Name.c_str(); }
- std::vector<std::shared_ptr<DatagramSessionInfo> > GetSessions();
+ ~I2PUDPClientTunnel ();
+
+ void Start ();
+ void Stop ();
+ const char * GetName () const { return m_Name.c_str(); }
+ std::vector<std::shared_ptr<DatagramSessionInfo> > GetSessions ();
- bool IsLocalDestination(const i2p::data::IdentHash & destination) const { return destination == m_LocalDest->GetIdentHash(); }
+ bool IsLocalDestination (const i2p::data::IdentHash & destination) const { return destination == m_LocalDest->GetIdentHash(); }
std::shared_ptr<ClientDestination> GetLocalDestination () const { return m_LocalDest; }
- void ExpireStale(const uint64_t delta=I2P_UDP_SESSION_TIMEOUT);
+ inline void SetLocalDestination (std::shared_ptr<ClientDestination> dest)
+ {
+ if (m_LocalDest) m_LocalDest->Release ();
+ if (dest) dest->Acquire ();
+ m_LocalDest = dest;
+ }
+
+ void ExpireStale (const uint64_t delta=I2P_UDP_SESSION_TIMEOUT);
private:
typedef std::pair<boost::asio::ip::udp::endpoint, uint64_t> UDPConvo;
- void RecvFromLocal();
- void HandleRecvFromLocal(const boost::system::error_code & e, std::size_t transferred);
- void HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
- void HandleRecvFromI2PRaw(uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
- void TryResolving();
+ void RecvFromLocal ();
+ void HandleRecvFromLocal (const boost::system::error_code & e, std::size_t transferred);
+ void HandleRecvFromI2P (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
+ void HandleRecvFromI2PRaw (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
+ void TryResolving ();
private:
@@ -302,11 +314,12 @@
const boost::asio::ip::udp::endpoint m_LocalEndpoint;
i2p::data::IdentHash * m_RemoteIdent;
std::thread * m_ResolveThread;
- boost::asio::ip::udp::socket m_LocalSocket;
+ std::unique_ptr<boost::asio::ip::udp::socket> m_LocalSocket;
boost::asio::ip::udp::endpoint m_RecvEndpoint;
uint8_t m_RecvBuff[I2P_UDP_MAX_MTU];
uint16_t RemotePort, m_LastPort;
bool m_cancel_resolve;
+ bool m_Gzip;
std::shared_ptr<UDPConvo> m_LastSession;
public:
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/SAM.cpp
^
|
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013-2021, The PurpleI2P Project
+* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -1078,7 +1078,7 @@
auto s = shared_from_this ();
newSocket->GetSocket ().async_connect (ep,
[s, newSocket, stream](const boost::system::error_code& ecode)
- {
+ {
if (!ecode)
{
s->m_Owner.AddSocket (newSocket);
@@ -1446,8 +1446,8 @@
void SAMBridge::SendTo (const std::vector<boost::asio::const_buffer>& bufs, const boost::asio::ip::udp::endpoint& ep)
{
m_DatagramSocket.send_to (bufs, ep);
- }
-
+ }
+
void SAMBridge::ReceiveDatagram ()
{
m_DatagramSocket.async_receive_from (
@@ -1478,14 +1478,21 @@
auto session = FindSession (sessionID);
if (session)
{
- i2p::data::IdentityEx dest;
- dest.FromBase64 (destination);
- if (session->Type == eSAMSessionTypeDatagram)
- session->GetLocalDestination ()->GetDatagramDestination ()->
- SendDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ());
- else // raw
- session->GetLocalDestination ()->GetDatagramDestination ()->
- SendRawDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ());
+ auto localDest = session->GetLocalDestination ();
+ auto datagramDest = localDest ? localDest->GetDatagramDestination () : nullptr;
+ if (datagramDest)
+ {
+ i2p::data::IdentityEx dest;
+ dest.FromBase64 (destination);
+ if (session->Type == eSAMSessionTypeDatagram)
+ datagramDest->SendDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ());
+ else if (session->Type == eSAMSessionTypeRaw)
+ datagramDest->SendRawDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ());
+ else
+ LogPrint (eLogError, "SAM: Unexpected session type ", (int)session->Type, "for session ", sessionID);
+ }
+ else
+ LogPrint (eLogError, "SAM: Datagram destination is not set for session ", sessionID);
}
else
LogPrint (eLogError, "SAM: Session ", sessionID, " not found");
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/upstream/libi2pd_client/SAM.h
^
|
@@ -250,7 +250,7 @@
/** send raw data to remote endpoint from our UDP Socket */
void SendTo (const std::vector<boost::asio::const_buffer>& bufs, const boost::asio::ip::udp::endpoint& ep);
-
+
void AddSocket(std::shared_ptr<SAMSocket> socket);
void RemoveSocket(const std::shared_ptr<SAMSocket> & socket);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd.yaml
^
|
@@ -1,7 +1,7 @@
Name: i2pd
Summary: End-to-End encrypted and anonymous Internet daemon
-Version: 2.41.0
-Release: 3
+Version: 2.43.0
+Release: 1
Group: Applications/Internet
License: BSD-3-Clause
URL: https://i2pd.website
|