[-]
[+]
|
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.43.0+git1</param>
+ <param name="revision">2.44.0+git1</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:i2pd-2.43.0+git1.tar.gz/icons/icons.pro
^
|
@@ -1,11 +0,0 @@
-TEMPLATE = aux
-# Configures svg to png
-THEMENAME=sailfish-default
-CONFIG += sailfish-svg2png
-INSTALLS += svg
-
-# also install SVG:
-svg.path = /usr/share/icons/hicolor/scalable/apps
-svg.files = \
- svgs/icon-m-i2p.svg \
- svgs/i2p-banner-dots.svg
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/.github/workflows/build-deb.yml
^
|
@@ -0,0 +1,32 @@
+name: Build Debian packages
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ name: ${{ matrix.dist }}
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ dist: ['buster', 'bullseye', 'bookworm']
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - name: change debian changelog
+ run: |
+ sudo apt-get update
+ sudo apt-get install devscripts
+ debchange -v "`git describe --tags`-${{ matrix.dist }}" -b -M --distribution ${{ matrix.dist }} "trunk build"
+ - uses: jtdor/build-deb-action@v1
+ with:
+ docker-image: debian:${{ matrix.dist }}-slim
+ buildpackage-opts: --build=binary --no-sign
+ - uses: actions/upload-artifact@v3
+ with:
+ name: i2pd_${{ matrix.dist }}
+ path: debian/artifacts/i2pd_*.deb
+ - uses: actions/upload-artifact@v3
+ with:
+ name: i2pd-dbgsym_${{ matrix.dist }}
+ path: debian/artifacts/i2pd-dbgsym_*.deb
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/.github/workflows/build-freebsd.yml
^
|
@@ -10,12 +10,19 @@
- uses: actions/checkout@v2
- name: Test in FreeBSD
id: test
- uses: vmactions/freebsd-vm@v0.2.0
+ uses: vmactions/freebsd-vm@v0.3.0
with:
usesh: true
mem: 2048
- prepare: pkg install -y devel/cmake devel/gmake devel/boost-libs security/openssl net/miniupnpc
+ sync: rsync
+ copyback: true
+ prepare: pkg install -y devel/cmake devel/gmake devel/boost-libs security/openssl net/miniupnpc
run: |
cd build
cmake -DWITH_UPNP=ON -DCMAKE_BUILD_TYPE=Release .
gmake -j2
+ - name: Upload artifacts
+ uses: actions/upload-artifact@v2
+ with:
+ name: i2pd-freebsd
+ path: build/i2pd
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/.github/workflows/build.yml
^
|
@@ -38,51 +38,3 @@
cd build
cmake -DWITH_UPNP=${{ matrix.with_upnp }} .
make -j3
- build-deb-stretch:
- name: Build package for stretch
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- fetch-depth: 0
- - name: change debian changelog
- run: |
- sudo apt-get update
- sudo apt-get install devscripts
- debchange -v "`git describe --tags`-stretch" -b -M --distribution stretch "trunk build"
- - uses: singingwolfboy/build-dpkg-stretch@v1
- id: build
- with:
- args: --unsigned-source --unsigned-changes -b
- - uses: actions/upload-artifact@v1
- with:
- name: ${{ steps.build.outputs.filename }}
- path: ${{ steps.build.outputs.filename }}
- - uses: actions/upload-artifact@v1
- with:
- name: ${{ steps.build.outputs.filename-dbgsym }}
- path: ${{ steps.build.outputs.filename-dbgsym }}
- build-deb-buster:
- name: Build package for buster
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- fetch-depth: 0
- - name: change debian changelog
- run: |
- sudo apt-get update
- sudo apt-get install devscripts
- debchange -v "`git describe --tags`-buster" -b -M --distribution buster "trunk build"
- - uses: singingwolfboy/build-dpkg-buster@v1
- id: build
- with:
- args: --unsigned-source --unsigned-changes -b
- - uses: actions/upload-artifact@v1
- with:
- name: ${{ steps.build.outputs.filename }}
- path: ${{ steps.build.outputs.filename }}
- - uses: actions/upload-artifact@v1
- with:
- name: ${{ steps.build.outputs.filename-dbgsym }}
- path: ${{ steps.build.outputs.filename-dbgsym }}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/.github/workflows/docker.yml
^
|
@@ -4,67 +4,137 @@
push:
branches:
- openssl
+ - docker
tags:
- '*'
jobs:
- docker:
+ build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
+ strategy:
+ matrix:
+ include: [
+ { platform: 'linux/amd64', archname: 'amd64' },
+ { platform: 'linux/386', archname: 'i386' },
+ { platform: 'linux/arm64', archname: 'arm64' },
+ { platform: 'linux/arm/v7', archname: 'armv7' },
+ ]
+
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
- uses: docker/setup-qemu-action@v1
+ uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
+ uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
- uses: docker/login-action@v1
+ uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container registry
- uses: docker/login-action@v1
+ uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- - name: Build and push trunk container
- if: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: docker/build-push-action@v2
+ - name: Build container for ${{ matrix.archname }}
+ uses: docker/build-push-action@v3
with:
context: ./contrib/docker
file: ./contrib/docker/Dockerfile
- platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
+ platforms: ${{ matrix.platform }}
push: true
tags: |
- purplei2p/i2pd:latest
- ghcr.io/purplei2p/i2pd:latest
+ purplei2p/i2pd:latest-${{ matrix.archname }}
+ ghcr.io/purplei2p/i2pd:latest-${{ matrix.archname }}
+
+ push:
+ runs-on: ubuntu-latest
+ permissions:
+ packages: write
+ contents: read
+
+ needs: build
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Login to GitHub Container registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Create and push latest manifest image to Docker Hub
+ uses: Noelware/docker-manifest-action@master
+ with:
+ base-image: purplei2p/i2pd:latest
+ extra-images: purplei2p/i2pd:latest-amd64,purplei2p/i2pd:latest-i386,purplei2p/i2pd:latest-arm64,purplei2p/i2pd:latest-armv7
+ push: true
- - name: Set env
+ - name: Create and push latest manifest image to GHCR
+ uses: Noelware/docker-manifest-action@master
+ with:
+ base-image: ghcr.io/purplei2p/i2pd:latest
+ extra-images: ghcr.io/purplei2p/i2pd:latest-amd64,ghcr.io/purplei2p/i2pd:latest-i386,ghcr.io/purplei2p/i2pd:latest-arm64,ghcr.io/purplei2p/i2pd:latest-armv7
+ push: true
+
+ - name: Store release version to env
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- - name: Build and push release container
+ - name: Create and push release manifest image to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
- uses: docker/build-push-action@v2
+ uses: Noelware/docker-manifest-action@master
with:
- context: ./contrib/docker
- file: ./contrib/docker/Dockerfile
- platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
+ base-image: purplei2p/i2pd:latest-release
+ extra-images: purplei2p/i2pd:latest-amd64,purplei2p/i2pd:latest-i386,purplei2p/i2pd:latest-arm64,purplei2p/i2pd:latest-armv7
+ push: true
+
+ - name: Create and push release manifest image to GHCR
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
+ uses: Noelware/docker-manifest-action@master
+ with:
+ base-image: ghcr.io/purplei2p/i2pd:latest-release
+ extra-images: ghcr.io/purplei2p/i2pd:latest-amd64,ghcr.io/purplei2p/i2pd:latest-i386,ghcr.io/purplei2p/i2pd:latest-arm64,ghcr.io/purplei2p/i2pd:latest-armv7
+ push: true
+
+ - name: Create and push versioned manifest image to Docker Hub
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
+ uses: Noelware/docker-manifest-action@master
+ with:
+ base-image: purplei2p/i2pd:release-${{ env.RELEASE_VERSION }}
+ extra-images: purplei2p/i2pd:latest-amd64,purplei2p/i2pd:latest-i386,purplei2p/i2pd:latest-arm64,purplei2p/i2pd:latest-armv7
+ push: true
+
+ - name: Create and push versioned manifest image to GHCR
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
+ uses: Noelware/docker-manifest-action@master
+ with:
+ base-image: ghcr.io/purplei2p/i2pd:release-${{ env.RELEASE_VERSION }}
+ extra-images: ghcr.io/purplei2p/i2pd:latest-amd64,ghcr.io/purplei2p/i2pd:latest-i386,ghcr.io/purplei2p/i2pd:latest-arm64,ghcr.io/purplei2p/i2pd:latest-armv7
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.44.0+git1.tar.gz/upstream/ChangeLog
^
|
@@ -1,6 +1,36 @@
# for this file format description,
# see https://github.com/olivierlacan/keep-a-changelog
+## [2.44.0] - 2022-11-20
+### Added
+- SSL connection for server I2P tunnels
+- Localization to Italian and Spanish
+- SSU2 through SOCKS5 UDP proxy
+- Reload tunnels through web console
+- SSU2 send immediate ack request flag
+- SSU2 send and verify path challenge
+- Configurable ssu2.mtu4 and ssu2.mtu6
+### Changed
+- SSU2 is enbaled and SSU is disabled by default
+- Separate network status and error
+- Random selection between NTCP2 and SSU2 priority
+- Added notbob.i2p to jump services
+- Remove DoNotTrack flag from HTTP Request header
+- Skip addresshelper page if destination was not changed
+- SSU2 allow different ports from RelayReponse and HolePunch
+- SSU2 resend PeerTest msg 1 and msg 2
+- SSU2 Send Retry instead SessionCreated if clock skew detected
+### Fixed
+- Long HTTP headers for HTTP proxy and HTTP server tunnel
+- SSU2 resends and resend limits
+- Crash at startup if addressbook is disabled
+- NTCP2 ipv6 connection through SOCKS5 proxy
+- SSU2 SessionRequest with zero token
+- SSU2 MTU less than 1280
+- SSU2 port=1
+- Incorrect addresses from network interfaces
+- Definitions for Darwin PPC; do not use pthread_setname_np
+
## [2.43.0] - 2022-08-22
### Added
- Complete SSU2 implementation
@@ -411,7 +441,7 @@
### Added
- Client auth flag for b33 address
### Changed
-- Remove incoming NTCP2 session from pending list when established
+- Remove incoming NTCP2 session from pending list when established
- Handle errors for NTCP2 SessionConfrimed send
### Fixed
- Failure to start on Windows XP
@@ -715,7 +745,7 @@
### Added
- Datagram i2p tunnels
- Unique local addresses for server tunnels
-- Configurable list of reseed servers and initial addressbook
+- Configurable list of reseed servers and initial addressbook
- Configurable netid
- Initial iOS support
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/Win32/Win32App.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
*
@@ -154,25 +154,23 @@
case eRouterStatusUnknown: s << "Unk"; break;
case eRouterStatusProxy: s << "Proxy"; break;
case eRouterStatusMesh: s << "Mesh"; break;
- case eRouterStatusError:
+ default: s << "Unk";
+ };
+ if (i2p::context.GetError () != eRouterErrorNone)
+ {
+ switch (i2p::context.GetError ())
{
- s << "Err";
- switch (i2p::context.GetError ())
- {
- case eRouterErrorClockSkew:
- s << " - Clock skew";
- break;
- case eRouterErrorOffline:
- s << " - Offline";
- break;
- case eRouterErrorSymmetricNAT:
- s << " - Symmetric NAT";
- break;
- default: ;
- }
+ case eRouterErrorClockSkew:
+ s << " - Clock skew";
+ break;
+ case eRouterErrorOffline:
+ s << " - Offline";
break;
+ case eRouterErrorSymmetricNAT:
+ s << " - Symmetric NAT";
+ break;
+ default: ;
}
- default: s << "Unk";
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/build/CMakeLists.txt
^
|
@@ -85,6 +85,7 @@
"${DAEMON_SRC_DIR}/Daemon.cpp"
"${DAEMON_SRC_DIR}/HTTPServer.cpp"
"${DAEMON_SRC_DIR}/I2PControl.cpp"
+ "${DAEMON_SRC_DIR}/I2PControlHandlers.cpp"
"${DAEMON_SRC_DIR}/i2pd.cpp"
"${DAEMON_SRC_DIR}/UPnP.cpp"
)
@@ -171,6 +172,13 @@
endif()
+# Enable usage of STD's Atomic instead of Boost's on PowerPC
+# For more information refer to https://github.com/PurpleI2P/i2pd/issues/1726#issuecomment-1306335111
+if(ARCHITECTURE MATCHES "ppc")
+ add_definitions(-DBOOST_SP_USE_STD_ATOMIC)
+endif()
+
+
# libraries
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/build/cmake_modules/TargetArch.cmake
^
|
@@ -61,7 +61,7 @@
#else
#error cmake_ARCH mips
#endif
-#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
+#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) || defined(__POWERPC__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/contrib/docker/Dockerfile
^
|
@@ -1,5 +1,18 @@
+#
+# Copyright (c) 2017-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
+#
+
FROM alpine:latest
-LABEL authors "Mikal Villa <mikal@sigterm.no>, Darknet Villain <supervillain@riseup.net>"
+LABEL authors="Mikal Villa <mikal@sigterm.no>, Darknet Villain <supervillain@riseup.net>"
+LABEL maintainer="R4SAS <r4sas@i2pmail.org>"
+
+LABEL org.opencontainers.image.source=https://github.com/PurpleI2P/i2pd
+LABEL org.opencontainers.image.documentation=https://i2pd.readthedocs.io/en/latest/
+LABEL org.opencontainers.image.licenses=BSD3
# Expose git branch, tag and URL variables as arguments
ARG GIT_BRANCH="openssl"
@@ -11,27 +24,28 @@
ENV I2PD_HOME="/home/i2pd"
ENV DATA_DIR="${I2PD_HOME}/data"
-ENV DEFAULT_ARGS=" --datadir=$DATA_DIR --reseed.verify=true --upnp.enabled=false --http.enabled=true --http.address=0.0.0.0 --httpproxy.enabled=true --httpproxy.address=0.0.0.0 --socksproxy.enabled=true --socksproxy.address=0.0.0.0 --sam.enabled=true --sam.address=0.0.0.0"
+ENV DEFAULT_ARGS=" --datadir=$DATA_DIR"
RUN mkdir -p "$I2PD_HOME" "$DATA_DIR" \
&& adduser -S -h "$I2PD_HOME" i2pd \
&& chown -R i2pd:nobody "$I2PD_HOME"
+
+# 1. Building binary
+# Each RUN is a layer, adding the dependencies and building i2pd in one layer takes around 8-900Mb, so to keep the
+# image under 20mb we need to remove all the build dependencies in the same "RUN" / layer.
#
-# Each RUN is a layer, adding the dependencies and building i2pd in one layer takes around 8-900Mb, so to keep the
-# image under 20mb we need to remove all the build dependencies in the same "RUN" / layer.
-#
+# 1. install deps, clone and build.
+# 2. strip binaries.
+# 3. Purge all dependencies and other unrelated packages, including build directory.
-# 1. install deps, clone and build.
-# 2. strip binaries.
-# 3. Purge all dependencies and other unrelated packages, including build directory.
RUN apk update \
&& apk --no-cache --virtual build-dependendencies add make gcc g++ libtool zlib-dev boost-dev build-base openssl-dev openssl miniupnpc-dev git \
&& mkdir -p /tmp/build \
&& cd /tmp/build && git clone -b ${GIT_BRANCH} ${REPO_URL} \
&& cd i2pd \
&& if [ -n "${GIT_TAG}" ]; then git checkout tags/${GIT_TAG}; fi \
- && make USE_UPNP=yes \
+ && make -j$(nproc) USE_UPNP=yes \
&& cp -R contrib/certificates /i2pd_certificates \
&& mkdir -p /usr/local/bin \
&& mv i2pd /usr/local/bin \
@@ -45,6 +59,9 @@
# 2. Adding required libraries to run i2pd to ensure it will run.
RUN apk --no-cache add boost-filesystem boost-system boost-program_options boost-date_time boost-thread boost-iostreams openssl miniupnpc musl-utils libstdc++
+# 3. Copy preconfigured config file and entrypoint
+COPY i2pd-docker.conf "$I2PD_HOME/i2pd.conf"
+RUN chown i2pd:nobody "$I2PD_HOME/i2pd.conf"
COPY entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/contrib/docker/i2pd-docker.conf
^
|
@@ -0,0 +1,52 @@
+## Preconfigured i2pd configuration file for a Docker container
+## See https://i2pd.readthedocs.io/en/latest/user-guide/configuration/
+## for more options you can use in this file.
+
+## Note that for exposing ports outside of container you need to bind all services to 0.0.0.0
+
+log = file
+loglevel = none
+
+ipv4 = true
+ipv6 = false
+
+# bandwidth = L
+# notransit = false
+# floodfill = false
+
+[ntcp2]
+enabled = true
+published = true
+
+[ssu2]
+enabled = true
+published = true
+
+[http]
+enabled = true
+address = 0.0.0.0
+port = 7070
+
+[httpproxy]
+enabled = true
+address = 0.0.0.0
+port = 4444
+
+[socksproxy]
+enabled = true
+address = 0.0.0.0
+port = 4447
+
+[sam]
+enabled = true
+address = 0.0.0.0
+port = 7656
+
+[upnp]
+enabled = false
+
+[reseed]
+verify = true
+
+[limits]
+# transittunnels = 2500
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/contrib/i18n/README.md
^
|
@@ -10,7 +10,7 @@
```
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
+out: #{"$2", {"$3", "$5", "$7", "$9", "$11"}},\n
```
```
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/contrib/i2pd.conf
^
|
@@ -75,7 +75,7 @@
## Enable communication through ipv6
ipv6 = false
-## Enable SSU transport (default = true)
+## Enable SSU transport
ssu = false
## Bandwidth configuration
@@ -105,10 +105,10 @@
# 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
+## Enable SSU2 transport
+# enabled = true
+## Publish address in RouterInfo
+# published = true
## Port for incoming connections (default is global port option value or port + 1 if SSU is enabled)
# port = 4567
@@ -127,7 +127,7 @@
# pass = changeme
## Select webconsole language
## Currently supported english (default), afrikaans, armenian, chinese, french,
-## german, russian, turkmen, ukrainian and uzbek languages
+## german, italian, russian, spanish, turkmen, ukrainian and uzbek languages
# lang = english
[httpproxy]
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.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.43.0
+Version: 2.44.0
Release: git%{git_hash}%{?dist}
Summary: I2P router written in C++
Conflicts: i2pd
@@ -158,6 +158,9 @@
%changelog
+* Sun Nov 20 2022 orignal <orignal@i2pmail.org> - 2.44.0
+- update to 2.44.0
+
* Mon Aug 22 2022 orignal <orignal@i2pmail.org> - 2.43.0
- update to 2.43.0
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/contrib/rpm/i2pd.spec
^
|
@@ -1,5 +1,5 @@
Name: i2pd
-Version: 2.43.0
+Version: 2.44.0
Release: 1%{?dist}
Summary: I2P router written in C++
Conflicts: i2pd-git
@@ -155,6 +155,9 @@
%changelog
+* Sun Nov 20 2022 orignal <orignal@i2pmail.org> - 2.44.0
+- update to 2.44.0
+
* Mon Aug 22 2022 orignal <orignal@i2pmail.org> - 2.43.0
- update to 2.43.0
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/daemon/Daemon.cpp
^
|
@@ -31,7 +31,6 @@
#include "Crypto.h"
#include "UPnP.h"
#include "Timestamp.h"
-#include "util.h"
#include "I18N.h"
namespace i2p
@@ -158,113 +157,13 @@
precomputation = false; // we don't elgamal table if no ssu, unless it's specified explicitly
i2p::crypto::InitCrypto (precomputation, aesni, avx, forceCpuExt);
+ i2p::transport::InitAddressFromIface (); // get address4/6 from interfaces
+
int netID; i2p::config::GetOption("netid", netID);
i2p::context.SetNetID (netID);
i2p::context.Init ();
- bool ipv6; i2p::config::GetOption("ipv6", ipv6);
- bool ipv4; i2p::config::GetOption("ipv4", ipv4);
-
- // ifname -> address
- std::string ifname; i2p::config::GetOption("ifname", ifname);
- if (ipv4 && i2p::config::IsDefault ("address4"))
- {
- std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
- if (!ifname4.empty ())
- i2p::config::SetOption ("address4", i2p::util::net::GetInterfaceAddress(ifname4, false).to_string ()); // v4
- else if (!ifname.empty ())
- i2p::config::SetOption ("address4", i2p::util::net::GetInterfaceAddress(ifname, false).to_string ()); // v4
- }
- if (ipv6 && i2p::config::IsDefault ("address6"))
- {
- std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
- if (!ifname6.empty ())
- i2p::config::SetOption ("address6", i2p::util::net::GetInterfaceAddress(ifname6, true).to_string ()); // v6
- else if (!ifname.empty ())
- i2p::config::SetOption ("address6", i2p::util::net::GetInterfaceAddress(ifname, true).to_string ()); // v6
- }
-
- bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
- boost::asio::ip::address_v6 yggaddr;
- if (ygg)
- {
- std::string yggaddress; i2p::config::GetOption ("meshnets.yggaddress", yggaddress);
- if (!yggaddress.empty ())
- {
- yggaddr = boost::asio::ip::address_v6::from_string (yggaddress);
- if (yggaddr.is_unspecified () || !i2p::util::net::IsYggdrasilAddress (yggaddr) ||
- !i2p::util::net::IsLocalAddress (yggaddr))
- {
- LogPrint(eLogWarning, "Daemon: Can't find Yggdrasil address ", yggaddress);
- ygg = false;
- }
- }
- else
- {
- yggaddr = i2p::util::net::GetYggdrasilAddress ();
- if (yggaddr.is_unspecified ())
- {
- LogPrint(eLogWarning, "Daemon: Yggdrasil is not running. Disabled");
- ygg = false;
- }
- }
- }
-
- uint16_t port; i2p::config::GetOption("port", port);
- if (!i2p::config::IsDefault("port"))
- {
- LogPrint(eLogInfo, "Daemon: Accepting incoming connections at port ", port);
- i2p::context.UpdatePort (port);
- }
- i2p::context.SetSupportsV6 (ipv6);
- i2p::context.SetSupportsV4 (ipv4);
- i2p::context.SetSupportsMesh (ygg, yggaddr);
-
- i2p::context.RemoveNTCPAddress (!ipv6); // TODO: remove later
- bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
- if (ntcp2)
- {
- bool published; i2p::config::GetOption("ntcp2.published", published);
- if (published)
- {
- std::string ntcp2proxy; i2p::config::GetOption("ntcp2.proxy", ntcp2proxy);
- if (!ntcp2proxy.empty ()) published = false;
- }
- if (published)
- {
- uint16_t ntcp2port; i2p::config::GetOption("ntcp2.port", ntcp2port);
- if (!ntcp2port) ntcp2port = port; // use standard port
- i2p::context.PublishNTCP2Address (ntcp2port, true, ipv4, ipv6, false); // publish
- if (ipv6)
- {
- std::string ipv6Addr; i2p::config::GetOption("ntcp2.addressv6", ipv6Addr);
- auto addr = boost::asio::ip::address_v6::from_string (ipv6Addr);
- if (!addr.is_unspecified () && addr != boost::asio::ip::address_v6::any ())
- i2p::context.UpdateNTCP2V6Address (addr); // set ipv6 address if configured
- }
- }
- else
- i2p::context.PublishNTCP2Address (port, false, ipv4, ipv6, false); // unpublish
- }
- if (ygg)
- {
- i2p::context.PublishNTCP2Address (port, true, false, false, true);
- i2p::context.UpdateNTCP2V6Address (yggaddr);
- 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
- }
+ i2p::transport::InitTransports ();
bool transit; i2p::config::GetOption("notransit", transit);
i2p::context.SetAcceptsTunnels (!transit);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/daemon/HTTPServer.cpp
^
|
@@ -80,7 +80,7 @@
const char HTTP_COMMAND_SHUTDOWN_CANCEL[] = "shutdown_cancel";
const char HTTP_COMMAND_SHUTDOWN_NOW[] = "terminate";
const char HTTP_COMMAND_RUN_PEER_TEST[] = "run_peer_test";
- const char HTTP_COMMAND_RELOAD_CONFIG[] = "reload_config";
+ const char HTTP_COMMAND_RELOAD_TUNNELS_CONFIG[] = "reload_tunnels_config";
const char HTTP_COMMAND_LOGLEVEL[] = "set_loglevel";
const char HTTP_COMMAND_KILLSTREAM[] = "closestream";
const char HTTP_COMMAND_LIMITTRANSIT[] = "limittransit";
@@ -232,25 +232,24 @@
case eRouterStatusUnknown: s << tr("Unknown"); break;
case eRouterStatusProxy: s << tr("Proxy"); break;
case eRouterStatusMesh: s << tr("Mesh"); break;
- case eRouterStatusError:
+ default: s << tr("Unknown");
+ }
+ if (error != eRouterErrorNone)
+ {
+ s << "<br>";
+ switch (error)
{
- s << tr("Error");
- switch (error)
- {
- case eRouterErrorClockSkew:
- s << " - " << tr("Clock skew");
- break;
- case eRouterErrorOffline:
- s << " - " << tr("Offline");
- break;
- case eRouterErrorSymmetricNAT:
- s << " - " << tr("Symmetric NAT");
- break;
- default: ;
- }
+ case eRouterErrorClockSkew:
+ s << " - " << tr("Clock skew");
+ break;
+ case eRouterErrorOffline:
+ s << " - " << tr("Offline");
break;
+ case eRouterErrorSymmetricNAT:
+ s << " - " << tr("Symmetric NAT");
+ break;
+ default: ;
}
- default: s << tr("Unknown");
}
}
@@ -699,8 +698,7 @@
s << "<b>" << tr("Router commands") << "</b><br>\r\n<br>\r\n<div class=\"commands\">\r\n";
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_RUN_PEER_TEST << "&token=" << token << "\">" << tr("Run peer test") << "</a><br>\r\n";
-
- // s << " <a href=\"/?cmd=" << HTTP_COMMAND_RELOAD_CONFIG << "\">Reload config</a><br>\r\n";
+ s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_RELOAD_TUNNELS_CONFIG << "&token=" << token << "\">" << tr("Reload tunnels configuration") << "</a><br>\r\n";
if (i2p::context.AcceptsTunnels ())
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_DISABLE_TRANSIT << "&token=" << token << "\">" << tr("Decline transit tunnels") << "</a><br>\r\n";
@@ -1247,7 +1245,7 @@
std::string cmd = params["cmd"];
if (cmd == HTTP_COMMAND_RUN_PEER_TEST)
i2p::transport::transports.PeerTest ();
- else if (cmd == HTTP_COMMAND_RELOAD_CONFIG)
+ else if (cmd == HTTP_COMMAND_RELOAD_TUNNELS_CONFIG)
i2p::client::context.ReloadConfig ();
else if (cmd == HTTP_COMMAND_ENABLE_TRANSIT)
i2p::context.SetAcceptsTunnels (true);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/daemon/I2PControl.cpp
^
|
@@ -14,25 +14,17 @@
// Use global placeholders from boost introduced when local_time.hpp is loaded
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
-#include <boost/lexical_cast.hpp>
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
+#include <boost/lexical_cast.hpp>
-#include "Crypto.h"
#include "FS.h"
#include "Log.h"
#include "Config.h"
#include "NetDb.hpp"
-#include "RouterContext.h"
-#include "Daemon.h"
#include "Tunnel.h"
-#include "Timestamp.h"
-#include "Transports.h"
-#include "version.h"
-#include "util.h"
-#include "ClientContext.h"
+#include "Daemon.h"
#include "I2PControl.h"
namespace i2p
@@ -69,44 +61,18 @@
m_MethodHandlers["Authenticate"] = &I2PControlService::AuthenticateHandler;
m_MethodHandlers["Echo"] = &I2PControlService::EchoHandler;
m_MethodHandlers["I2PControl"] = &I2PControlService::I2PControlHandler;
- m_MethodHandlers["RouterInfo"] = &I2PControlService::RouterInfoHandler;
+ m_MethodHandlers["RouterInfo"] = &I2PControlHandlers::RouterInfoHandler;
m_MethodHandlers["RouterManager"] = &I2PControlService::RouterManagerHandler;
- m_MethodHandlers["NetworkSetting"] = &I2PControlService::NetworkSettingHandler;
- m_MethodHandlers["ClientServicesInfo"] = &I2PControlService::ClientServicesInfoHandler;
+ m_MethodHandlers["NetworkSetting"] = &I2PControlHandlers::NetworkSettingHandler;
+ m_MethodHandlers["ClientServicesInfo"] = &I2PControlHandlers::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.net.tunnels.participating"] = &I2PControlService::TunnelsParticipatingHandler;
- 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;
-
// RouterManager
m_RouterManagerHandlers["Reseed"] = &I2PControlService::ReseedHandler;
m_RouterManagerHandlers["Shutdown"] = &I2PControlService::ShutdownHandler;
m_RouterManagerHandlers["ShutdownGraceful"] = &I2PControlService::ShutdownGracefulHandler;
-
- // NetworkSetting
- m_NetworkSettingHandlers["i2p.router.net.bw.in"] = &I2PControlService::InboundBandwidthLimit;
- m_NetworkSettingHandlers["i2p.router.net.bw.out"] = &I2PControlService::OutboundBandwidthLimit;
-
- // 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;
}
I2PControlService::~I2PControlService ()
@@ -280,37 +246,6 @@
}
}
- void I2PControlService::InsertParam (std::ostringstream& ss, const std::string& name, int value) const
- {
- ss << "\"" << name << "\":" << value;
- }
-
- void I2PControlService::InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value, bool quotes) const
- {
- ss << "\"" << name << "\":";
- if (value.length () > 0)
- {
- if (quotes)
- ss << "\"" << value << "\"";
- else
- ss << value;
- }
- else
- ss << "null";
- }
-
- void I2PControlService::InsertParam (std::ostringstream& ss, const std::string& name, double value) const
- {
- ss << "\"" << name << "\":" << std::fixed << std::setprecision(2) << value;
- }
-
- void I2PControlService::InsertParam (std::ostringstream& ss, const std::string& name, const boost::property_tree::ptree& value) const
- {
- std::ostringstream buf;
- boost::property_tree::write_json (buf, value, false);
- ss << "\"" << name << "\":" << buf.str();
- }
-
void I2PControlService::SendResponse (std::shared_ptr<ssl_socket> socket,
std::shared_ptr<I2PControlBuffer> buf, std::ostringstream& response, bool isHtml)
{
@@ -396,91 +331,6 @@
m_Tokens.clear ();
}
-// RouterInfo
-
- void I2PControlService::RouterInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results)
- {
- bool first = true;
- for (auto it = params.begin (); it != params.end (); it++)
- {
- LogPrint (eLogDebug, "I2PControl: RouterInfo request: ", it->first);
- auto it1 = m_RouterInfoHandlers.find (it->first);
- if (it1 != m_RouterInfoHandlers.end ())
- {
- if (!first) results << ",";
- else first = false;
- (this->*(it1->second))(results);
- }
- else
- LogPrint (eLogError, "I2PControl: RouterInfo unknown request ", it->first);
- }
- }
-
- void I2PControlService::UptimeHandler (std::ostringstream& results)
- {
- InsertParam (results, "i2p.router.uptime", std::to_string (i2p::context.GetUptime ()*1000LL), false);
- }
-
- void I2PControlService::VersionHandler (std::ostringstream& results)
- {
- InsertParam (results, "i2p.router.version", VERSION);
- }
-
- void I2PControlService::StatusHandler (std::ostringstream& results)
- {
- auto dest = i2p::client::context.GetSharedLocalDestination ();
- InsertParam (results, "i2p.router.status", (dest && dest->IsReady ()) ? "1" : "0");
- }
-
- void I2PControlService::NetDbKnownPeersHandler (std::ostringstream& results)
- {
- InsertParam (results, "i2p.router.netdb.knownpeers", i2p::data::netdb.GetNumRouters ());
- }
-
- void I2PControlService::NetDbActivePeersHandler (std::ostringstream& results)
- {
- InsertParam (results, "i2p.router.netdb.activepeers", (int)i2p::transport::transports.GetPeers ().size ());
- }
-
- void I2PControlService::NetStatusHandler (std::ostringstream& results)
- {
- InsertParam (results, "i2p.router.net.status", (int)i2p::context.GetStatus ());
- }
-
- void I2PControlService::TunnelsParticipatingHandler (std::ostringstream& results)
- {
- int transit = i2p::tunnel::tunnels.GetTransitTunnels ().size ();
- InsertParam (results, "i2p.router.net.tunnels.participating", transit);
- }
-
- void I2PControlService::TunnelsSuccessRateHandler (std::ostringstream& results)
- {
- int rate = i2p::tunnel::tunnels.GetTunnelCreationSuccessRate ();
- InsertParam (results, "i2p.router.net.tunnels.successrate", rate);
- }
-
- void I2PControlService::InboundBandwidth1S (std::ostringstream& results)
- {
- double bw = i2p::transport::transports.GetInBandwidth ();
- InsertParam (results, "i2p.router.net.bw.inbound.1s", bw);
- }
-
- void I2PControlService::OutboundBandwidth1S (std::ostringstream& results)
- {
- double bw = i2p::transport::transports.GetOutBandwidth ();
- InsertParam (results, "i2p.router.net.bw.outbound.1s", bw);
- }
-
- void I2PControlService::NetTotalReceivedBytes (std::ostringstream& results)
- {
- InsertParam (results, "i2p.router.net.total.received.bytes", (double)i2p::transport::transports.GetTotalReceivedBytes ());
- }
-
- void I2PControlService::NetTotalSentBytes (std::ostringstream& results)
- {
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/daemon/I2PControl.h
^
|
@@ -20,6 +20,7 @@
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/property_tree/ptree.hpp>
+#include "I2PControlHandlers.h"
namespace i2p
{
@@ -32,7 +33,7 @@
const char I2P_CONTROL_CERTIFICATE_COMMON_NAME[] = "i2pd.i2pcontrol";
const char I2P_CONTROL_CERTIFICATE_ORGANIZATION[] = "Purple I2P";
- class I2PControlService
+ class I2PControlService: public I2PControlHandlers
{
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
@@ -63,61 +64,24 @@
private:
- void InsertParam (std::ostringstream& ss, const std::string& name, int value) const;
- void InsertParam (std::ostringstream& ss, const std::string& name, double value) const;
- void InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value, bool quotes = true) const;
- void InsertParam (std::ostringstream& ss, const std::string& name, const boost::property_tree::ptree& value) const;
-
// methods
typedef void (I2PControlService::*MethodHandler)(const boost::property_tree::ptree& params, std::ostringstream& results);
void AuthenticateHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
void EchoHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
void I2PControlHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
- void RouterInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
void RouterManagerHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
- void NetworkSettingHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
- void ClientServicesInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
// I2PControl
typedef void (I2PControlService::*I2PControlRequestHandler)(const std::string& value);
void PasswordHandler (const std::string& value);
- // RouterInfo
- typedef void (I2PControlService::*RouterInfoRequestHandler)(std::ostringstream& results);
- void UptimeHandler (std::ostringstream& results);
- void VersionHandler (std::ostringstream& results);
- void StatusHandler (std::ostringstream& results);
- void NetDbKnownPeersHandler (std::ostringstream& results);
- void NetDbActivePeersHandler (std::ostringstream& results);
- void NetStatusHandler (std::ostringstream& results);
- void TunnelsParticipatingHandler (std::ostringstream& results);
- void TunnelsSuccessRateHandler (std::ostringstream& results);
- void InboundBandwidth1S (std::ostringstream& results);
- void OutboundBandwidth1S (std::ostringstream& results);
- void NetTotalReceivedBytes (std::ostringstream& results);
- void NetTotalSentBytes (std::ostringstream& results);
-
// RouterManager
typedef void (I2PControlService::*RouterManagerRequestHandler)(std::ostringstream& results);
void ShutdownHandler (std::ostringstream& results);
void ShutdownGracefulHandler (std::ostringstream& results);
void ReseedHandler (std::ostringstream& results);
- // NetworkSetting
- typedef void (I2PControlService::*NetworkSettingRequestHandler)(const std::string& value, std::ostringstream& results);
- void InboundBandwidthLimit (const std::string& value, std::ostringstream& results);
- void OutboundBandwidthLimit (const std::string& value, std::ostringstream& results);
-
- // ClientServicesInfo
- typedef void (I2PControlService::*ClientServicesInfoRequestHandler)(std::ostringstream& results);
- void I2PTunnelInfoHandler (std::ostringstream& results);
- void HTTPProxyInfoHandler (std::ostringstream& results);
- void SOCKSInfoHandler (std::ostringstream& results);
- void SAMInfoHandler (std::ostringstream& results);
- void BOBInfoHandler (std::ostringstream& results);
- void I2CPInfoHandler (std::ostringstream& results);
-
private:
std::string m_Password;
@@ -132,10 +96,7 @@
std::map<std::string, MethodHandler> m_MethodHandlers;
std::map<std::string, I2PControlRequestHandler> m_I2PControlHandlers;
- std::map<std::string, RouterInfoRequestHandler> m_RouterInfoHandlers;
std::map<std::string, RouterManagerRequestHandler> m_RouterManagerHandlers;
- std::map<std::string, NetworkSettingRequestHandler> m_NetworkSettingHandlers;
- std::map<std::string, ClientServicesInfoRequestHandler> m_ClientServicesInfoHandlers;
};
}
}
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/daemon/I2PControlHandlers.cpp
^
|
@@ -0,0 +1,376 @@
+/*
+* 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 <iomanip>
+#define BOOST_BIND_GLOBAL_PLACEHOLDERS
+#include <boost/lexical_cast.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
+#include "Log.h"
+#include "RouterContext.h"
+#include "NetDb.hpp"
+#include "Tunnel.h"
+#include "Transports.h"
+#include "version.h"
+#include "ClientContext.h"
+#include "I2PControlHandlers.h"
+
+namespace i2p
+{
+namespace client
+{
+ I2PControlHandlers::I2PControlHandlers ()
+ {
+ // RouterInfo
+ m_RouterInfoHandlers["i2p.router.uptime"] = &I2PControlHandlers::UptimeHandler;
+ m_RouterInfoHandlers["i2p.router.version"] = &I2PControlHandlers::VersionHandler;
+ m_RouterInfoHandlers["i2p.router.status"] = &I2PControlHandlers::StatusHandler;
+ m_RouterInfoHandlers["i2p.router.netdb.knownpeers"] = &I2PControlHandlers::NetDbKnownPeersHandler;
+ m_RouterInfoHandlers["i2p.router.netdb.activepeers"] = &I2PControlHandlers::NetDbActivePeersHandler;
+ m_RouterInfoHandlers["i2p.router.net.bw.inbound.1s"] = &I2PControlHandlers::InboundBandwidth1S;
+ m_RouterInfoHandlers["i2p.router.net.bw.outbound.1s"] = &I2PControlHandlers::OutboundBandwidth1S;
+ m_RouterInfoHandlers["i2p.router.net.status"] = &I2PControlHandlers::NetStatusHandler;
+ m_RouterInfoHandlers["i2p.router.net.tunnels.participating"] = &I2PControlHandlers::TunnelsParticipatingHandler;
+ m_RouterInfoHandlers["i2p.router.net.tunnels.successrate"] = &I2PControlHandlers::TunnelsSuccessRateHandler;
+ m_RouterInfoHandlers["i2p.router.net.total.received.bytes"] = &I2PControlHandlers::NetTotalReceivedBytes;
+ m_RouterInfoHandlers["i2p.router.net.total.sent.bytes"] = &I2PControlHandlers::NetTotalSentBytes;
+
+ // NetworkSetting
+ m_NetworkSettingHandlers["i2p.router.net.bw.in"] = &I2PControlHandlers::InboundBandwidthLimit;
+ m_NetworkSettingHandlers["i2p.router.net.bw.out"] = &I2PControlHandlers::OutboundBandwidthLimit;
+
+ // ClientServicesInfo
+ m_ClientServicesInfoHandlers["I2PTunnel"] = &I2PControlHandlers::I2PTunnelInfoHandler;
+ m_ClientServicesInfoHandlers["HTTPProxy"] = &I2PControlHandlers::HTTPProxyInfoHandler;
+ m_ClientServicesInfoHandlers["SOCKS"] = &I2PControlHandlers::SOCKSInfoHandler;
+ m_ClientServicesInfoHandlers["SAM"] = &I2PControlHandlers::SAMInfoHandler;
+ m_ClientServicesInfoHandlers["BOB"] = &I2PControlHandlers::BOBInfoHandler;
+ m_ClientServicesInfoHandlers["I2CP"] = &I2PControlHandlers::I2CPInfoHandler;
+ }
+
+ void I2PControlHandlers::InsertParam (std::ostringstream& ss, const std::string& name, int value) const
+ {
+ ss << "\"" << name << "\":" << value;
+ }
+
+ void I2PControlHandlers::InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value, bool quotes) const
+ {
+ ss << "\"" << name << "\":";
+ if (value.length () > 0)
+ {
+ if (quotes)
+ ss << "\"" << value << "\"";
+ else
+ ss << value;
+ }
+ else
+ ss << "null";
+ }
+
+ void I2PControlHandlers::InsertParam (std::ostringstream& ss, const std::string& name, double value) const
+ {
+ ss << "\"" << name << "\":" << std::fixed << std::setprecision(2) << value;
+ }
+
+ void I2PControlHandlers::InsertParam (std::ostringstream& ss, const std::string& name, const boost::property_tree::ptree& value) const
+ {
+ std::ostringstream buf;
+ boost::property_tree::write_json (buf, value, false);
+ ss << "\"" << name << "\":" << buf.str();
+ }
+
+// RouterInfo
+
+ void I2PControlHandlers::RouterInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results)
+ {
+ bool first = true;
+ for (auto it = params.begin (); it != params.end (); it++)
+ {
+ LogPrint (eLogDebug, "I2PControl: RouterInfo request: ", it->first);
+ auto it1 = m_RouterInfoHandlers.find (it->first);
+ if (it1 != m_RouterInfoHandlers.end ())
+ {
+ if (!first) results << ",";
+ else first = false;
+ (this->*(it1->second))(results);
+ }
+ else
+ LogPrint (eLogError, "I2PControl: RouterInfo unknown request ", it->first);
+ }
+ }
+
+ void I2PControlHandlers::UptimeHandler (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.uptime", std::to_string (i2p::context.GetUptime ()*1000LL), false);
+ }
+
+ void I2PControlHandlers::VersionHandler (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.version", VERSION);
+ }
+
+ void I2PControlHandlers::StatusHandler (std::ostringstream& results)
+ {
+ auto dest = i2p::client::context.GetSharedLocalDestination ();
+ InsertParam (results, "i2p.router.status", (dest && dest->IsReady ()) ? "1" : "0");
+ }
+
+ void I2PControlHandlers::NetDbKnownPeersHandler (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.netdb.knownpeers", i2p::data::netdb.GetNumRouters ());
+ }
+
+ void I2PControlHandlers::NetDbActivePeersHandler (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.netdb.activepeers", (int)i2p::transport::transports.GetPeers ().size ());
+ }
+
+ void I2PControlHandlers::NetStatusHandler (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.net.status", (int)i2p::context.GetStatus ());
+ }
+
+ void I2PControlHandlers::TunnelsParticipatingHandler (std::ostringstream& results)
+ {
+ int transit = i2p::tunnel::tunnels.GetTransitTunnels ().size ();
+ InsertParam (results, "i2p.router.net.tunnels.participating", transit);
+ }
+
+ void I2PControlHandlers::TunnelsSuccessRateHandler (std::ostringstream& results)
+ {
+ int rate = i2p::tunnel::tunnels.GetTunnelCreationSuccessRate ();
+ InsertParam (results, "i2p.router.net.tunnels.successrate", rate);
+ }
+
+ void I2PControlHandlers::InboundBandwidth1S (std::ostringstream& results)
+ {
+ double bw = i2p::transport::transports.GetInBandwidth ();
+ InsertParam (results, "i2p.router.net.bw.inbound.1s", bw);
+ }
+
+ void I2PControlHandlers::OutboundBandwidth1S (std::ostringstream& results)
+ {
+ double bw = i2p::transport::transports.GetOutBandwidth ();
+ InsertParam (results, "i2p.router.net.bw.outbound.1s", bw);
+ }
+
+ void I2PControlHandlers::NetTotalReceivedBytes (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.net.total.received.bytes", (double)i2p::transport::transports.GetTotalReceivedBytes ());
+ }
+
+ void I2PControlHandlers::NetTotalSentBytes (std::ostringstream& results)
+ {
+ InsertParam (results, "i2p.router.net.total.sent.bytes", (double)i2p::transport::transports.GetTotalSentBytes ());
+ }
+
+// network setting
+ void I2PControlHandlers::NetworkSettingHandler (const boost::property_tree::ptree& params, std::ostringstream& results)
+ {
+ for (auto it = params.begin (); it != params.end (); it++)
+ {
+ LogPrint (eLogDebug, "I2PControl: NetworkSetting request: ", it->first);
+ auto it1 = m_NetworkSettingHandlers.find (it->first);
+ if (it1 != m_NetworkSettingHandlers.end ()) {
+ if (it != params.begin ()) results << ",";
+ (this->*(it1->second))(it->second.data (), results);
+ } else
+ LogPrint (eLogError, "I2PControl: NetworkSetting unknown request: ", it->first);
+ }
+ }
+
+ void I2PControlHandlers::InboundBandwidthLimit (const std::string& value, std::ostringstream& results)
+ {
+ if (value != "null")
+ i2p::context.SetBandwidth (std::atoi(value.c_str()));
+ int bw = i2p::context.GetBandwidthLimit();
+ InsertParam (results, "i2p.router.net.bw.in", bw);
+ }
+
+ void I2PControlHandlers::OutboundBandwidthLimit (const std::string& value, std::ostringstream& results)
+ {
+ if (value != "null")
+ i2p::context.SetBandwidth (std::atoi(value.c_str()));
+ int bw = i2p::context.GetBandwidthLimit();
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/daemon/I2PControlHandlers.h
^
|
@@ -0,0 +1,80 @@
+/*
+* 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 I2P_CONTROL_HANDLERS_H__
+#define I2P_CONTROL_HANDLERS_H__
+
+#include <sstream>
+#include <map>
+#include <string>
+#include <boost/property_tree/ptree.hpp>
+
+namespace i2p
+{
+namespace client
+{
+ class I2PControlHandlers
+ {
+ public:
+
+ I2PControlHandlers ();
+
+ // methods
+ // TODO: make protected
+ void RouterInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
+ void NetworkSettingHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
+ void ClientServicesInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results);
+
+ protected:
+
+ void InsertParam (std::ostringstream& ss, const std::string& name, int value) const;
+ void InsertParam (std::ostringstream& ss, const std::string& name, double value) const;
+ void InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value, bool quotes = true) const;
+ void InsertParam (std::ostringstream& ss, const std::string& name, const boost::property_tree::ptree& value) const;
+
+ private:
+
+ // RouterInfo
+ typedef void (I2PControlHandlers::*RouterInfoRequestHandler)(std::ostringstream& results);
+ void UptimeHandler (std::ostringstream& results);
+ void VersionHandler (std::ostringstream& results);
+ void StatusHandler (std::ostringstream& results);
+ void NetDbKnownPeersHandler (std::ostringstream& results);
+ void NetDbActivePeersHandler (std::ostringstream& results);
+ void NetStatusHandler (std::ostringstream& results);
+ void TunnelsParticipatingHandler (std::ostringstream& results);
+ void TunnelsSuccessRateHandler (std::ostringstream& results);
+ void InboundBandwidth1S (std::ostringstream& results);
+ void OutboundBandwidth1S (std::ostringstream& results);
+ void NetTotalReceivedBytes (std::ostringstream& results);
+ void NetTotalSentBytes (std::ostringstream& results);
+
+ // NetworkSetting
+ typedef void (I2PControlHandlers::*NetworkSettingRequestHandler)(const std::string& value, std::ostringstream& results);
+ void InboundBandwidthLimit (const std::string& value, std::ostringstream& results);
+ void OutboundBandwidthLimit (const std::string& value, std::ostringstream& results);
+
+ // ClientServicesInfo
+ typedef void (I2PControlHandlers::*ClientServicesInfoRequestHandler)(std::ostringstream& results);
+ void I2PTunnelInfoHandler (std::ostringstream& results);
+ void HTTPProxyInfoHandler (std::ostringstream& results);
+ void SOCKSInfoHandler (std::ostringstream& results);
+ void SAMInfoHandler (std::ostringstream& results);
+ void BOBInfoHandler (std::ostringstream& results);
+ void I2CPInfoHandler (std::ostringstream& results);
+
+ private:
+
+ std::map<std::string, RouterInfoRequestHandler> m_RouterInfoHandlers;
+ std::map<std::string, NetworkSettingRequestHandler> m_NetworkSettingHandlers;
+ std::map<std::string, ClientServicesInfoRequestHandler> m_ClientServicesInfoHandlers;
+ };
+}
+}
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/debian/changelog
^
|
@@ -1,3 +1,9 @@
+i2pd (2.44.0-1) unstable; urgency=medium
+
+ * updated to version 2.44.0/0.9.56
+
+ -- orignal <orignal@i2pmail.org> Sun, 20 Nov 2022 19:00:00 +0000
+
i2pd (2.43.0-1) unstable; urgency=medium
* updated to version 2.43.0/0.9.55
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/i18n/Chinese.cpp
^
|
@@ -38,9 +38,9 @@
{"building", "正在构建"},
{"failed", "连接失败"},
{"expiring", "即将过期"},
- {"established", "连接已建立"},
+ {"established", "连接成功"},
{"unknown", "未知"},
- {"exploratory", "探测"},
+ {"exploratory", "探索"},
{"Purple I2P Webconsole", "Purple I2P 网页控制台"},
{"<b>i2pd</b> webconsole", "<b>i2pd</b> 网页控制台"},
{"Main page", "主页"},
@@ -91,7 +91,7 @@
{"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。"},
+ {"<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", "加密类型"},
@@ -120,18 +120,18 @@
{"EndDate", "结束日期"},
{"not floodfill", "非洪泛"},
{"Queue size", "队列大小"},
- {"Run peer test", "运行群体测试"},
+ {"Run peer test", "运行节点测试"},
{"Decline transit tunnels", "拒绝中转隧道"},
{"Accept transit tunnels", "允许中转隧道"},
- {"Cancel graceful shutdown", "取消离线"},
- {"Start graceful shutdown", "优雅地离线"},
+ {"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", "日志级别"},
+ {"Logging level", "日志记录级别"},
{"Transit tunnels limit", "中转隧道限制"},
- {"Change", "更换"},
- {"Change language", "更换语言"},
+ {"Change", "修改"},
+ {"Change language", "更改语言"},
{"no transit tunnels currently built", "目前未构建中转隧道"},
{"SAM disabled", "SAM 已禁用"},
{"no sessions currently running", "没有正在运行的会话"},
@@ -141,7 +141,7 @@
{"Client Forwards", "客户端转发"},
{"Server Forwards", "服务器转发"},
{"Unknown page", "未知页面"},
- {"Invalid token", "无效凭证"},
+ {"Invalid token", "无效令牌"},
{"SUCCESS", "成功"},
{"Stream closed", "流已关闭"},
{"Stream not found or already was closed", "流未找到或已关闭"},
@@ -162,22 +162,22 @@
{"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", "您可以尝试在下方的跳转服务上找到这个主机"},
+ {"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", "将此地址从地址助手添加到地址簿"},
+ {"added to router's addressbook from helper", "将此地址从地址助手添加到路由地址簿"},
{"Click here to proceed:", "点击此处继续:"},
{"Continue", "继续"},
- {"Addresshelper found", "找到地址助手"},
- {"already in router's addressbook", "已在路由器的地址簿中"},
+ {"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", "出口代理失效"},
+ {"Outproxy failure", "出口代理故障"},
{"bad outproxy settings", "错误的出口代理设置"},
{"not inside I2P network, but outproxy is not enabled", "该地址不在 I2P 网络内,但未启用出口代理"},
{"unknown outproxy url", "未知的出口代理地址"},
@@ -200,7 +200,7 @@
static std::map<std::string, std::vector<std::string>> plurals
{
- {"days", {"天"}},
+ {"days", {"日"}},
{"hours", {"时"}},
{"minutes", {"分"}},
{"seconds", {"秒"}},
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/i18n/German.cpp
^
|
@@ -31,7 +31,6 @@
static std::map<std::string, std::string> strings
{
- {"Purple I2P Webconsole", "Purple-I2P-Webkonsole"},
{"KiB", "KiB"},
{"MiB", "MiB"},
{"GiB", "GiB"},
@@ -41,6 +40,7 @@
{"established", "hergestellt"},
{"unknown", "Unbekannt"},
{"exploratory", "erforschend"},
+ {"Purple I2P Webconsole", "Purple I2P-Webkonsole"},
{"<b>i2pd</b> webconsole", "<b>i2pd</b>-Webkonsole"},
{"Main page", "Startseite"},
{"Router commands", "Routerbefehle"},
@@ -49,8 +49,8 @@
{"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"},
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/i18n/I18N_langs.h
^
|
@@ -77,7 +77,9 @@
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 italian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace russian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
+ namespace spanish { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace turkmen { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace ukrainian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
namespace uzbek { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
@@ -88,14 +90,16 @@
static std::map<std::string, langData> languages
{
{ "afrikaans", {"Afrikaans", "af", i2p::i18n::afrikaans::GetLocale} },
- { "armenian", {"հայերէն", "hy", i2p::i18n::armenian::GetLocale} },
+ { "armenian", {"hայերէն", "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} },
- { "ukrainian", {"украї́нська мо́ва", "uk", i2p::i18n::ukrainian::GetLocale} },
+ { "italian", {"Italiano", "it", i2p::i18n::italian::GetLocale} },
+ { "russian", {"Русский язык", "ru", i2p::i18n::russian::GetLocale} },
+ { "spanish", {"Español", "es", i2p::i18n::spanish::GetLocale} },
+ { "turkmen", {"Türkmen dili", "tk", i2p::i18n::turkmen::GetLocale} },
+ { "ukrainian", {"Украї́нська мо́ва", "uk", i2p::i18n::ukrainian::GetLocale} },
{ "uzbek", {"Oʻzbek", "uz", i2p::i18n::uzbek::GetLocale} },
};
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/i18n/Italian.cpp
^
|
@@ -0,0 +1,216 @@
+/*
+* 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"
+
+// Italian localization file
+
+namespace i2p
+{
+namespace i18n
+{
+namespace italian // language namespace
+{
+ // language name in lowercase
+ static std::string language = "italian";
+
+ // 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", "KiB"},
+ {"MiB", "MiB"},
+ {"GiB", "GiB"},
+ {"building", "in costruzione"},
+ {"failed", "fallito"},
+ {"expiring", "in scadenza"},
+ {"established", "stabilita"},
+ {"unknown", "sconosciuto"},
+ {"exploratory", "esplorativo"},
+ {"Purple I2P Webconsole", "Terminale web Purple I2P"},
+ {"<b>i2pd</b> webconsole", "Terminal web <b>i2pd</b>"},
+ {"Main page", "Pagina principale"},
+ {"Router commands", "Comandi router"},
+ {"Local Destinations", "Destinazioni locali"},
+ {"LeaseSets", "LeaseSets"},
+ {"Tunnels", "Tunnel"},
+ {"Transit Tunnels", "Tunnel di transito"},
+ {"Transports", "Trasporti"},
+ {"I2P tunnels", "Tunnel I2P"},
+ {"SAM sessions", "Sessioni SAM"},
+ {"ERROR", "ERRORE"},
+ {"OK", "OK"},
+ {"Testing", "Testando"},
+ {"Firewalled", "Protetto da firewall"},
+ {"Unknown", "Sconosciuto"},
+ {"Proxy", "Proxy"},
+ {"Mesh", "Mesh"},
+ {"Error", "Errore"},
+ {"Clock skew", "Orologio disallineato"},
+ {"Offline", "Disconnesso"},
+ {"Symmetric NAT", "NAT simmetrico"},
+ {"Uptime", "In funzione da"},
+ {"Network status", "Stato della rete"},
+ {"Network status v6", "Stato della rete v6"},
+ {"Stopping in", "Arresto in"},
+ {"Family", "Famiglia"},
+ {"Tunnel creation success rate", "Percentuale di tunnel creati con successo"},
+ {"Received", "Ricevuti"},
+ {"KiB/s", "KiB/s"},
+ {"Sent", "Inviati"},
+ {"Transit", "Transitati"},
+ {"Data path", "Percorso dati"},
+ {"Hidden content. Press on text to see.", "Contenuto nascosto. Premi sul testo per vedere."},
+ {"Router Ident", "Identificativo del router"},
+ {"Router Family", "Famiglia del router"},
+ {"Router Caps", "Limiti del router"},
+ {"Version", "Versione"},
+ {"Our external address", "Il nostro indirizzo esterno"},
+ {"supported", "supportato"},
+ {"Routers", "Router"},
+ {"Floodfills", "Floodfill"},
+ {"Client Tunnels", "Tunnel client"},
+ {"Services", "Servizi"},
+ {"Enabled", "Abilitato"},
+ {"Disabled", "Disabilitato"},
+ {"Encrypted B33 address", "Indirizzo criptato B33"},
+ {"Address registration line", "Linea di registrazione indirizzo"},
+ {"Domain", "Dominio"},
+ {"Generate", "Genera"},
+ {"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>Nota:</b> la stringa risultante può essere utilizzata solo per registrare domini 2LD (example.i2p). Per registrare i sottodomini, si prega di utilizzare i2pd-tools."},
+ {"Address", "Indirizzo"},
+ {"Type", "Tipologia"},
+ {"EncType", "Tipo di crittografia"},
+ {"Inbound tunnels", "Tunnel in entrata"},
+ {"ms", "ms"},
+ {"Outbound tunnels", "Tunnel in uscita"},
+ {"Tags", "Tag"},
+ {"Incoming", "In entrata"},
+ {"Outgoing", "In uscita"},
+ {"Destination", "Destinazione"},
+ {"Amount", "Quantità"},
+ {"Incoming Tags", "Tag in entrata"},
+ {"Tags sessions", "Sessioni dei tag"},
+ {"Status", "Stato"},
+ {"Local Destination", "Destinazione locale"},
+ {"Streams", "Flussi"},
+ {"Close stream", "Interrompi il flusso"},
+ {"I2CP session not found", "Sessione I2CP non trovata"},
+ {"I2CP is not enabled", "I2CP non è abilitato"},
+ {"Invalid", "Invalido"},
+ {"Store type", "Tipologia di archivio"},
+ {"Expires", "Scade"},
+ {"Non Expired Leases", "Lease non scaduti"},
+ {"Gateway", "Gateway"},
+ {"TunnelID", "TunnelID"},
+ {"EndDate", "Data di fine"},
+ {"not floodfill", "no floodfill"},
+ {"Queue size", "Dimensione della coda"},
+ {"Run peer test", "Esegui il test dei peer"},
+ {"Decline transit tunnels", "Rifiuta tunnel di transito"},
+ {"Accept transit tunnels", "Accetta tunnel di transito"},
+ {"Cancel graceful shutdown", "Annulla l'interruzione controllata"},
+ {"Start graceful shutdown", "Avvia l'interruzione controllata"},
+ {"Force shutdown", "Forza l'arresto"},
+ {"Reload external CSS styles", "Ricarica gli stili CSS esterni"},
+ {"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b>Nota:</b> qualsiasi azione effettuata qui non è persistente e non modifica i file di configurazione."},
+ {"Logging level", "Livello di log"},
+ {"Transit tunnels limit", "Limite di tunnel di transito"},
+ {"Change", "Modifica"},
+ {"Change language", "Modifica linguaggio"},
+ {"no transit tunnels currently built", "Attualmente non ci sono tunnel di transito instaurati"},
+ {"SAM disabled", "SAM disabilitato"},
+ {"no sessions currently running", "Attualmente non ci sono sessioni attive"},
+ {"SAM session not found", "Sessione SAM non trovata"},
+ {"SAM Session", "Sessione SAM"},
+ {"Server Tunnels", "Tunnel server"},
+ {"Client Forwards", "Client di inoltro"},
+ {"Server Forwards", "Server di inoltro"},
+ {"Unknown page", "Pagina sconosciuta"},
+ {"Invalid token", "Token non valido"},
+ {"SUCCESS", "SUCCESSO"},
+ {"Stream closed", "Flusso terminato"},
+ {"Stream not found or already was closed", "Il flusso non è stato trovato oppure è già stato terminato"},
+ {"Destination not found", "Destinazione non trovata"},
+ {"StreamID can't be null", "Lo StreamID non può essere null"},
+ {"Return to destination page", "Ritorna alla pagina di destinazione"},
+ {"You will be redirected in 5 seconds", "Verrai reindirizzato in 5 secondi"},
+ {"Transit tunnels count must not exceed 65535", "Il numero di tunnel di transito non può superare i 65535"},
+ {"Back to commands list", "Ritorna alla lista dei comandi"},
+ {"Register at reg.i2p", "Registra a reg.i2p"},
+ {"Description", "Descrizione"},
+ {"A bit information about service on domain", "Alcune informazioni riguardo il servizio sul dominio"},
+ {"Submit", "Invia"},
+ {"Domain can't end with .b32.i2p", "I domini non possono terminare con .b32.i2p"},
+ {"Domain must end with .i2p", "I domini devono terminare con .i2p"},
+ {"Such destination is not found", "Questa destinazione non è stata trovata"},
+ {"Unknown command", "Comando sconosciuto"},
+ {"Command accepted", "Comando accettato"},
+ {"Proxy error", "Errore del proxy"},
+ {"Proxy info", "Informazioni del proxy"},
+ {"Proxy error: Host not found", "Errore del proxy: Host non trovato"},
+ {"Remote host not found in router's addressbook", "L'host remoto non è stato trovato nella rubrica del router"},
+ {"You may try to find this host on jump services below", "Si può provare a trovare questo host sui servizi di salto qui sotto"},
+ {"Invalid request", "Richiesta non valida"},
+ {"Proxy unable to parse your request", "Il proxy non è in grado di elaborare la tua richiesta"},
+ {"addresshelper is not supported", "addresshelper non è supportato"},
+ {"Host", "Host"},
+ {"added to router's addressbook from helper", "aggiunto alla rubrica tramite l'helper"},
+ {"Click here to proceed:", "Clicca qui per procedere:"},
+ {"Continue", "Continua"},
+ {"Addresshelper found", "Addresshelper trovato"},
+ {"already in router's addressbook", "già presente nella rubrica del router"},
+ {"Click here to update record:", "Clicca qui per aggiornare l'elemento:"},
+ {"invalid request uri", "uri della richiesta non valido"},
+ {"Can't detect destination host from request", "Impossibile determinare l'host di destinazione dalla richiesta"},
+ {"Outproxy failure", "Fallimento del proxy di uscita"},
+ {"bad outproxy settings", "impostazioni errate del proxy di uscita"},
+ {"not inside I2P network, but outproxy is not enabled", "non all'interno della rete I2P, ma il proxy di uscita non è abilitato"},
+ {"unknown outproxy url", "url del proxy di uscita sconosciuto"},
+ {"cannot resolve upstream proxy", "impossibile identificare il flusso a monte del proxy"},
+ {"hostname too long", "il nome dell'host è troppo lungo"},
+ {"cannot connect to upstream socks proxy", "impossibile connettersi al flusso a monte del proxy socks"},
+ {"Cannot negotiate with socks proxy", "Impossibile negoziare con il proxy socks"},
+ {"CONNECT error", "Errore di connessione"},
+ {"Failed to Connect", "Connessione fallita"},
+ {"socks proxy error", "errore del proxy socks"},
+ {"failed to send request to upstream", "invio della richiesta a monte non riuscito"},
+ {"No Reply From socks proxy", "Nessuna risposta dal proxy socks"},
+ {"cannot connect", "impossibile connettersi"},
+ {"http out proxy not implemented", "proxy http di uscita non implementato"},
+ {"cannot connect to upstream http proxy", "impossibile connettersi al proxy http a monte"},
+ {"Host is down", "L'host è offline"},
+ {"Can't create connection to requested host, it may be down. Please try again later.", "Impossibile creare la connessione all'host richiesto, probabilmente è offline. Riprova più tardi."},
+ {"", ""},
+ };
+
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/i18n/Spanish.cpp
^
|
@@ -0,0 +1,216 @@
+/*
+* 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"
+
+// Spanish localization file
+
+namespace i2p
+{
+namespace i18n
+{
+namespace spanish // language namespace
+{
+ // language name in lowercase
+ static std::string language = "spanish";
+
+ // 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", "KiB"},
+ {"MiB", "MiB"},
+ {"GiB", "GiB"},
+ {"building", "pendiente"},
+ {"failed", "fallido"},
+ {"expiring", "expiró"},
+ {"established", "establecido"},
+ {"unknown", "desconocido"},
+ {"exploratory", "exploratorio"},
+ {"Purple I2P Webconsole", "Consola web de Purple I2P"},
+ {"<b>i2pd</b> webconsole", "Consola web de <b>i2pd</b>"},
+ {"Main page", "Inicio"},
+ {"Router commands", "Comandos de enrutador"},
+ {"Local Destinations", "Destinos locales"},
+ {"LeaseSets", "LeaseSets"},
+ {"Tunnels", "Túneles"},
+ {"Transit Tunnels", "Túneles de Tránsito"},
+ {"Transports", "Transportes"},
+ {"I2P tunnels", "Túneles I2P"},
+ {"SAM sessions", "Sesiones SAM"},
+ {"ERROR", "ERROR"},
+ {"OK", "VALE"},
+ {"Testing", "Probando"},
+ {"Firewalled", "Con cortafuegos"},
+ {"Unknown", "Desconocido"},
+ {"Proxy", "Proxy"},
+ {"Mesh", "Malla"},
+ {"Error", "Error"},
+ {"Clock skew", "Reloj desfasado"},
+ {"Offline", "Desconectado"},
+ {"Symmetric NAT", "NAT simétrico"},
+ {"Uptime", "Tiempo en línea"},
+ {"Network status", "Estado de red"},
+ {"Network status v6", "Estado de red v6"},
+ {"Stopping in", "Parando en"},
+ {"Family", "Familia"},
+ {"Tunnel creation success rate", "Tasa de éxito de creación de túneles"},
+ {"Received", "Recibido"},
+ {"KiB/s", "KiB/s"},
+ {"Sent", "Enviado"},
+ {"Transit", "Tránsito"},
+ {"Data path", "Ruta de datos"},
+ {"Hidden content. Press on text to see.", "Contenido oculto. Presione para ver."},
+ {"Router Ident", "Ident del Enrutador"},
+ {"Router Family", "Familia de enrutador"},
+ {"Router Caps", "Atributos del Enrutador"},
+ {"Version", "Versión"},
+ {"Our external address", "Nuestra dirección externa"},
+ {"supported", "soportado"},
+ {"Routers", "Enrutadores"},
+ {"Floodfills", "Inundaciones"},
+ {"Client Tunnels", "Túneles de cliente"},
+ {"Services", "Servicios"},
+ {"Enabled", "Activado"},
+ {"Disabled", "Desactivado"},
+ {"Encrypted B33 address", "Dirección encriptada B33"},
+ {"Address registration line", "Línea para registrar direcciones"},
+ {"Domain", "Dominio"},
+ {"Generate", "Generar"},
+ {"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>Nota:</b> la cadena resultante solo se puede usar para registrar dominios 2LD (ejemplo.i2p). Para registrar subdominios, por favor utilice i2pd-tools."},
+ {"Address", "Dirección"},
+ {"Type", "Tipo"},
+ {"EncType", "TipoEncrip"},
+ {"Inbound tunnels", "Túneles entrantes"},
+ {"ms", "ms"},
+ {"Outbound tunnels", "Túneles salientes"},
+ {"Tags", "Etiquetas"},
+ {"Incoming", "Entrante"},
+ {"Outgoing", "Saliente"},
+ {"Destination", "Destino"},
+ {"Amount", "Cantidad"},
+ {"Incoming Tags", "Etiquetas entrantes"},
+ {"Tags sessions", "Sesiones de etiquetas"},
+ {"Status", "Estado"},
+ {"Local Destination", "Destino Local"},
+ {"Streams", "Flujos"},
+ {"Close stream", "Cerrar flujo"},
+ {"I2CP session not found", "Sesión I2CP no encontrada"},
+ {"I2CP is not enabled", "I2CP no está activado"},
+ {"Invalid", "Inválido"},
+ {"Store type", "Tipo de almacenamiento"},
+ {"Expires", "Caduca"},
+ {"Non Expired Leases", "Sesiones No Expiradas"},
+ {"Gateway", "Puerta de enlace"},
+ {"TunnelID", "TunnelID"},
+ {"EndDate", "FechaVenc"},
+ {"not floodfill", "no inundado"},
+ {"Queue size", "Tamaño de cola"},
+ {"Run peer test", "Ejecutar prueba de par"},
+ {"Decline transit tunnels", "Rechazar túneles de tránsito"},
+ {"Accept transit tunnels", "Aceptar túneles de tránsito"},
+ {"Cancel graceful shutdown", "Cancelar apagado con gracia"},
+ {"Start graceful shutdown", "Iniciar apagado con gracia"},
+ {"Force shutdown", "Forzar apagado"},
+ {"Reload external CSS styles", "Recargar estilos CSS externos"},
+ {"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b>Nota:</b> cualquier acción hecha aquí no es persistente y no cambia tus archivos de configuración."},
+ {"Logging level", "Nivel de registro de errores"},
+ {"Transit tunnels limit", "Límite de túneles de tránsito"},
+ {"Change", "Cambiar"},
+ {"Change language", "Cambiar idioma"},
+ {"no transit tunnels currently built", "no hay túneles de tránsito actualmente construidos"},
+ {"SAM disabled", "SAM desactivado"},
+ {"no sessions currently running", "no hay sesiones ejecutándose ahora"},
+ {"SAM session not found", "Sesión SAM no encontrada"},
+ {"SAM Session", "Sesión SAM"},
+ {"Server Tunnels", "Túneles de Servidor"},
+ {"Client Forwards", "Redirecciones de Cliente"},
+ {"Server Forwards", "Redirecciones de Servidor"},
+ {"Unknown page", "Página desconocida"},
+ {"Invalid token", "Token inválido"},
+ {"SUCCESS", "ÉXITO"},
+ {"Stream closed", "Transmisión cerrada"},
+ {"Stream not found or already was closed", "No se encontró la transmisión o ya se cerró"},
+ {"Destination not found", "Destino no encontrado"},
+ {"StreamID can't be null", "StreamID no puede ser nulo"},
+ {"Return to destination page", "Volver a la página de destino"},
+ {"You will be redirected in 5 seconds", "Serás redirigido en 5 segundos"},
+ {"Transit tunnels count must not exceed 65535", "La cantidad de túneles de tránsito no puede exceder 65535"},
+ {"Back to commands list", "Volver a lista de comandos"},
+ {"Register at reg.i2p", "Registrar en reg.i2p"},
+ {"Description", "Descripción"},
+ {"A bit information about service on domain", "Un poco de información sobre el servicio en el dominio"},
+ {"Submit", "Enviar"},
+ {"Domain can't end with .b32.i2p", "El dominio no puede terminar con .b32.i2p"},
+ {"Domain must end with .i2p", "El dominio debe terminar con .i2p"},
+ {"Such destination is not found", "No se encontró el destino"},
+ {"Unknown command", "Comando desconocido"},
+ {"Command accepted", "Comando aceptado"},
+ {"Proxy error", "Error de proxy"},
+ {"Proxy info", "Información del proxy"},
+ {"Proxy error: Host not found", "Error de proxy: Host no encontrado"},
+ {"Remote host not found in router's addressbook", "Servidor remoto no encontrado en la libreta de direcciones del enrutador"},
+ {"You may try to find this host on jump services below", "Puede intentar encontrar este dominio en los siguientes servicios de salto"},
+ {"Invalid request", "Solicitud inválida"},
+ {"Proxy unable to parse your request", "Proxy no puede procesar su solicitud"},
+ {"addresshelper is not supported", "ayudante de dirección no soportado"},
+ {"Host", "Dominio"},
+ {"added to router's addressbook from helper", "añadido a la libreta de direcciones desde el ayudante"},
+ {"Click here to proceed:", "Haga clic aquí para continuar:"},
+ {"Continue", "Continuar"},
+ {"Addresshelper found", "Se encontró ayudante de dirección"},
+ {"already in router's addressbook", "ya se encontró en libreta de direcciones"},
+ {"Click here to update record:", "Haga clic aquí para actualizar el registro:"},
+ {"invalid request uri", "uri de solicitud inválida"},
+ {"Can't detect destination host from request", "No se puede detectar el host de destino de la solicitud"},
+ {"Outproxy failure", "Fallo en el proxy saliente"},
+ {"bad outproxy settings", "configuración de outproxy incorrecta"},
+ {"not inside I2P network, but outproxy is not enabled", "no está dentro de la red I2P, pero el proxy de salida no está activado"},
+ {"unknown outproxy url", "url de proxy outproxy desconocido"},
+ {"cannot resolve upstream proxy", "no se puede resolver el proxy de upstream"},
+ {"hostname too long", "nombre de dominio muy largo"},
+ {"cannot connect to upstream socks proxy", "no se puede conectar al proxy socks principal"},
+ {"Cannot negotiate with socks proxy", "No se puede negociar con el proxy socks"},
+ {"CONNECT error", "Error de CONNECT"},
+ {"Failed to Connect", "Error al Conectar"},
+ {"socks proxy error", "error de proxy socks"},
+ {"failed to send request to upstream", "no se pudo enviar petición al principal"},
+ {"No Reply From socks proxy", "Sin respuesta del proxy socks"},
+ {"cannot connect", "no se puede conectar"},
+ {"http out proxy not implemented", "proxy externo http no implementado"},
+ {"cannot connect to upstream http proxy", "no se puede conectar al proxy http principal"},
+ {"Host is down", "Servidor caído"},
+ {"Can't create connection to requested host, it may be down. Please try again later.", "No se puede crear la conexión al servidor solicitado, puede estar caído. Intente de nuevo más tarde."},
+ {"", ""},
+ };
+
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Config.cpp
^
|
@@ -64,7 +64,7 @@
("bandwidth", value<std::string>()->default_value(""), "Transit traffic bandwidth limit: integer in KBps or letters: L (32), O (256), P (2048), X (>9000)")
("share", value<int>()->default_value(100), "Limit of transit traffic from max bandwidth in percents. (default: 100)")
("ntcp", bool_switch()->default_value(false), "Ignored. Always false")
- ("ssu", bool_switch()->default_value(true), "Enable SSU transport (default: enabled)")
+ ("ssu", bool_switch()->default_value(false), "Enable SSU transport (default: disabled)")
("ntcpproxy", value<std::string>()->default_value(""), "Ignored")
#ifdef _WIN32
("svcctl", value<std::string>()->default_value(""), "Ignored")
@@ -274,9 +274,12 @@
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.enabled", value<bool>()->default_value(true), "Enable SSU2 (default: enabled)")
+ ("ssu2.published", value<bool>()->default_value(true), "Publish SSU2 (default: enabled)")
("ssu2.port", value<uint16_t>()->default_value(0), "Port to listen for incoming SSU2 packets (default: auto)")
+ ("ssu2.mtu4", value<uint16_t>()->default_value(0), "MTU for ipv4 address (default: detect)")
+ ("ssu2.mtu6", value<uint16_t>()->default_value(0), "MTU for ipv6 address (default: detect)")
+ ("ssu2.proxy", value<std::string>()->default_value(""), "Socks5 proxy URL for SSU2 transport")
;
options_description nettime("Time sync options");
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Datagram.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
*
@@ -15,6 +15,7 @@
#include <map>
#include <vector>
#include "Base.h"
+#include "Gzip.h"
#include "Identity.h"
#include "LeaseSet.h"
#include "I2NPProtocol.h"
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Destination.cpp
^
|
@@ -1096,7 +1096,13 @@
}
auto leaseSet = FindLeaseSet (dest);
if (leaseSet)
- streamRequestComplete(CreateStream (leaseSet, port));
+ {
+ auto stream = CreateStream (leaseSet, port);
+ GetService ().post ([streamRequestComplete, stream]()
+ {
+ streamRequestComplete(stream);
+ });
+ }
else
{
auto s = GetSharedFromThis ();
@@ -1129,6 +1135,35 @@
});
}
+ template<typename Dest>
+ std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStreamSync (const Dest& dest, int port)
+ {
+ std::shared_ptr<i2p::stream::Stream> stream;
+ std::condition_variable streamRequestComplete;
+ std::mutex streamRequestCompleteMutex;
+ std::unique_lock<std::mutex> l(streamRequestCompleteMutex);
+ CreateStream (
+ [&streamRequestComplete, &streamRequestCompleteMutex, &stream](std::shared_ptr<i2p::stream::Stream> s)
+ {
+ stream = s;
+ std::unique_lock<std::mutex> l(streamRequestCompleteMutex);
+ streamRequestComplete.notify_all ();
+ },
+ dest, port);
+ streamRequestComplete.wait (l);
+ return stream;
+ }
+
+ std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (const i2p::data::IdentHash& dest, int port)
+ {
+ return CreateStreamSync (dest, port);
+ }
+
+ std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port)
+ {
+ return CreateStreamSync (dest, port);
+ }
+
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port)
{
if (m_StreamingDestination)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Destination.h
^
|
@@ -247,6 +247,8 @@
// following methods operate with default streaming destination
void CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, int port = 0);
void CreateStream (StreamRequestComplete streamRequestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port = 0);
+ std::shared_ptr<i2p::stream::Stream> CreateStream (const i2p::data::IdentHash& dest, int port = 0); // sync
+ std::shared_ptr<i2p::stream::Stream> CreateStream (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port = 0); // sync
std::shared_ptr<i2p::stream::Stream> CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port = 0);
void SendPing (const i2p::data::IdentHash& to);
void SendPing (std::shared_ptr<const i2p::data::BlindedPublicKey> to);
@@ -282,6 +284,9 @@
void PersistTemporaryKeys (EncryptionKey * keys, bool isSingleKey);
void ReadAuthKey (const std::string& group, const std::map<std::string, std::string> * params);
+ template<typename Dest>
+ std::shared_ptr<i2p::stream::Stream> CreateStreamSync (const Dest& dest, int port);
+
private:
i2p::data::PrivateKeys m_Keys;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/HTTP.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
*
@@ -135,6 +135,7 @@
? url.substr(pos_p, std::string::npos)
: url.substr(pos_p, pos_c - pos_p);
/* stoi throws exception on failure, we don't need it */
+ port = 0;
for (char c : port_str) {
if (c < '0' || c > '9')
return false;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Identity.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
*
@@ -49,13 +49,30 @@
IdentityEx::IdentityEx(const uint8_t * publicKey, const uint8_t * signingKey, SigningKeyType type, CryptoKeyType cryptoType)
{
+ /*uint8_t randomPaddingBlock[32];
+ RAND_bytes (randomPaddingBlock, 32);*/
if (cryptoType == CRYPTO_KEY_TYPE_ECIES_X25519_AEAD)
{
- memcpy (m_StandardIdentity.publicKey, publicKey, 32);
- RAND_bytes (m_StandardIdentity.publicKey + 32, 224);
+ /*memcpy (m_StandardIdentity.publicKey, publicKey ? publicKey : randomPaddingBlock, 32);
+ for (int i = 0; i < 7; i++) // 224 bytes
+ memcpy (m_StandardIdentity.publicKey + 32*(i + 1), randomPaddingBlock, 32);*/
+ if (publicKey)
+ {
+ memcpy (m_StandardIdentity.publicKey, publicKey, 32);
+ RAND_bytes (m_StandardIdentity.publicKey + 32, 224);
+ }
+ else
+ RAND_bytes (m_StandardIdentity.publicKey, 256);
}
else
- memcpy (m_StandardIdentity.publicKey, publicKey, 256);
+ {
+ if (publicKey)
+ memcpy (m_StandardIdentity.publicKey, publicKey, 256);
+ else
+ RAND_bytes (m_StandardIdentity.publicKey, 256);
+ /*for (int i = 0; i < 8; i++) // 256 bytes
+ memcpy (m_StandardIdentity.publicKey + 32*i, randomPaddingBlock, 32);*/
+ }
if (type != SIGNING_KEY_TYPE_DSA_SHA1)
{
size_t excessLen = 0;
@@ -93,7 +110,9 @@
case SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519:
{
size_t padding = 128 - i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH; // 96 = 128 - 32
- RAND_bytes (m_StandardIdentity.signingKey, padding);
+ /*for (int i = 0; i < 3; i++) // 96 bytes
+ memcpy (m_StandardIdentity.signingKey + 32*i, randomPaddingBlock, 32);*/
+ RAND_bytes (m_StandardIdentity.signingKey, 96);
memcpy (m_StandardIdentity.signingKey + padding, signingKey, i2p::crypto::EDDSA25519_PUBLIC_KEY_LENGTH);
break;
}
@@ -695,7 +714,7 @@
return nullptr;
}
- PrivateKeys PrivateKeys::CreateRandomKeys (SigningKeyType type, CryptoKeyType cryptoType)
+ PrivateKeys PrivateKeys::CreateRandomKeys (SigningKeyType type, CryptoKeyType cryptoType, bool isDestination)
{
if (type != SIGNING_KEY_TYPE_DSA_SHA1)
{
@@ -705,9 +724,12 @@
GenerateSigningKeyPair (type, keys.m_SigningPrivateKey, signingPublicKey);
// encryption
uint8_t publicKey[256];
- GenerateCryptoKeyPair (cryptoType, keys.m_PrivateKey, publicKey);
+ if (isDestination)
+ RAND_bytes (keys.m_PrivateKey, 256);
+ else
+ GenerateCryptoKeyPair (cryptoType, keys.m_PrivateKey, publicKey);
// identity
- keys.m_Public = std::make_shared<IdentityEx> (publicKey, signingPublicKey, type, cryptoType);
+ keys.m_Public = std::make_shared<IdentityEx> (isDestination ? nullptr : publicKey, signingPublicKey, type, cryptoType);
keys.CreateSigner ();
return keys;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Identity.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
*
@@ -171,7 +171,7 @@
std::shared_ptr<i2p::crypto::CryptoKeyDecryptor> CreateDecryptor (const uint8_t * key) const;
static std::shared_ptr<i2p::crypto::CryptoKeyDecryptor> CreateDecryptor (CryptoKeyType cryptoType, const uint8_t * key);
- static PrivateKeys CreateRandomKeys (SigningKeyType type = SIGNING_KEY_TYPE_DSA_SHA1, CryptoKeyType cryptoType = CRYPTO_KEY_TYPE_ELGAMAL);
+ static PrivateKeys CreateRandomKeys (SigningKeyType type = SIGNING_KEY_TYPE_DSA_SHA1, CryptoKeyType cryptoType = CRYPTO_KEY_TYPE_ELGAMAL, bool isDestination = false);
static void GenerateSigningKeyPair (SigningKeyType type, uint8_t * priv, uint8_t * pub);
static void GenerateCryptoKeyPair (CryptoKeyType type, uint8_t * priv, uint8_t * pub); // priv and pub are 256 bytes long
static i2p::crypto::Signer * CreateSigner (SigningKeyType keyType, const uint8_t * priv);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/NTCP2.cpp
^
|
@@ -1558,7 +1558,7 @@
case eSocksProxy:
{
// TODO: support username/password auth etc
- static const uint8_t buff[3] = {0x05, 0x01, 0x00};
+ static const uint8_t buff[3] = {SOCKS5_VER, 0x01, 0x00};
boost::asio::async_write(conn->GetSocket(), boost::asio::buffer(buff, 3), boost::asio::transfer_all(),
[] (const boost::system::error_code & ec, std::size_t transferred)
{
@@ -1672,21 +1672,21 @@
size_t sz = 6; // header + port
auto buff = std::make_shared<std::vector<int8_t> >(256);
auto readbuff = std::make_shared<std::vector<int8_t> >(256);
- (*buff)[0] = 0x05;
- (*buff)[1] = 0x01;
+ (*buff)[0] = SOCKS5_VER;
+ (*buff)[1] = SOCKS5_CMD_CONNECT;
(*buff)[2] = 0x00;
auto& ep = conn->GetRemoteEndpoint ();
if(ep.address ().is_v4 ())
{
- (*buff)[3] = 0x01;
+ (*buff)[3] = SOCKS5_ATYP_IPV4;
auto addrbytes = ep.address ().to_v4().to_bytes();
sz += 4;
memcpy(buff->data () + 4, addrbytes.data(), 4);
}
else if (ep.address ().is_v6 ())
{
- (*buff)[3] = 0x04;
+ (*buff)[3] = SOCKS5_ATYP_IPV6;
auto addrbytes = ep.address ().to_v6().to_bytes();
sz += 16;
memcpy(buff->data () + 4, addrbytes.data(), 16);
@@ -1708,22 +1708,24 @@
}
});
- boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff->data (), 10),
+ boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff->data (), SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE), // read min reply size
+ boost::asio::transfer_all(),
[timer, conn, sz, readbuff](const boost::system::error_code & e, std::size_t transferred)
{
- if(e)
- {
+ if (e)
LogPrint(eLogError, "NTCP2: SOCKS proxy read error ", e.message());
- }
- else if(transferred == sz)
+ else if (!(*readbuff)[1]) // succeeded
{
- if((*readbuff)[1] == 0x00)
- {
- timer->cancel();
- conn->ClientLogin();
- return;
- }
+ boost::system::error_code ec;
+ size_t moreBytes = conn->GetSocket ().available(ec);
+ if (moreBytes) // read remaining portion of reply if ipv6 received
+ boost::asio::read (conn->GetSocket (), boost::asio::buffer(readbuff->data (), moreBytes), boost::asio::transfer_all (), ec);
+ timer->cancel();
+ conn->ClientLogin();
+ return;
}
+ else
+ LogPrint(eLogError, "NTCP2: Proxy reply error ", (int)(*readbuff)[1]);
timer->cancel();
conn->Terminate();
});
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/NetDb.cpp
^
|
@@ -274,7 +274,7 @@
{
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
{
@@ -438,14 +438,14 @@
// 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");
@@ -628,7 +628,8 @@
(it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
it.second->SetUnreachable (false);
// find & mark expired routers
- if (!it.second->IsReachable () && it.second->IsSSU (false))
+ if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & (RouterInfo::eSSUV4 | RouterInfo::eSSU2V4)))
+ // non-reachable router, but reachable by ipv4 SSU or SSU2 means introducers
{
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
// RouterInfo expires after 1 hour if uses introducer
@@ -1217,7 +1218,7 @@
router->IsSSU2PeerTesting (v4) && !excluded.count (router->GetIdentHash ());
});
}
-
+
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSUV6Router () const
{
return GetRandomRouter (
@@ -1242,11 +1243,11 @@
return GetRandomRouter (
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
{
- return !router->IsHidden () && router->IsSSU2Introducer (v4) &&
+ return !router->IsHidden () && router->IsSSU2Introducer (v4) &&
!excluded.count (router->GetIdentHash ());
});
}
-
+
std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const
{
return GetRandomRouter (
@@ -1454,6 +1455,6 @@
{
if (!r || r->GetBuffer ()) return;
r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
- }
+ }
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/NetDb.hpp
^
|
@@ -125,8 +125,8 @@
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); };
+ 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; };
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/RouterContext.cpp
^
|
@@ -121,7 +121,7 @@
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;
@@ -170,7 +170,7 @@
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
@@ -201,8 +201,8 @@
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);
@@ -354,7 +354,7 @@
(*it)->s = m_NTCP2Keys->staticPublicKey;
memcpy ((*it)->i, m_NTCP2Keys->iv, 16);
it++;
- }
+ }
else
it = addresses.erase (it);
updated = true;
@@ -382,9 +382,9 @@
{
newPort = address->port;
break;
- }
+ }
if (!newPort) newPort = SelectRandomPort ();
- }
+ }
bool updated = false;
for (auto& address : m_RouterInfo.GetAddresses ())
{
@@ -419,8 +419,8 @@
(*it)->s = m_SSU2Keys->staticPublicKey;
(*it)->i = m_SSU2Keys->intro;
it++;
- }
- else
+ }
+ else
it = addresses.erase (it);
updated = true;
}
@@ -438,12 +438,12 @@
if (ipv6) m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::AddressCaps::eV6);
}
else
- {
+ {
uint8_t addressCaps = 0;
if (ipv4) addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4;
if (ipv6) addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6;
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, addressCaps);
- }
+ }
updated = true;
}
if (updated)
@@ -462,8 +462,8 @@
address->host = host;
updated = true;
}
- if (host.is_v6 () && address->IsV6 () && address->ssu &&
- (!address->ssu->mtu || updated))
+ if (host.is_v6 () && address->IsV6 () && address->ssu &&
+ (!address->ssu->mtu || updated) && m_StatusV6 != eRouterStatusProxy)
{
// update MTU
auto mtu = i2p::util::net::GetMTU (host);
@@ -471,8 +471,8 @@
{
LogPrint (eLogDebug, "Router: Our v6 MTU=", mtu);
int maxMTU = i2p::util::net::GetMaxMTU (host.to_v6 ());
- if (mtu > maxMTU)
- {
+ if (mtu > maxMTU)
+ {
mtu = maxMTU;
LogPrint(eLogWarning, "Router: MTU dropped to upper limit of ", maxMTU, " bytes");
}
@@ -531,8 +531,8 @@
}
if (updated)
UpdateRouterInfo ();
- }
-
+ }
+
void RouterContext::SetFloodfill (bool floodfill)
{
m_IsFloodfill = floodfill;
@@ -658,17 +658,17 @@
for (auto it = addresses.begin (); it != addresses.end ();)
{
if ((*it)->transportStyle == i2p::data::RouterInfo::eTransportSSU)
- {
+ {
it = addresses.erase (it);
updated = true;
- }
+ }
else
++it;
}
if (updated)
m_RouterInfo.UpdateSupportedTransports ();
}
-
+
void RouterContext::SetUnreachableSSU2 (bool v4, bool v6)
{
if (IsSSU2Only ())
@@ -691,7 +691,7 @@
// delete previous introducers
auto& addresses = m_RouterInfo.GetAddresses ();
for (auto& addr : addresses)
- if (addr->ssu && (!addr->IsSSU2 () || IsSSU2Only ()) &&
+ if (addr->ssu && (!addr->IsSSU2 () || IsSSU2Only ()) &&
((v4 && addr->IsV4 ()) || (v6 && addr->IsV6 ())))
{
addr->published = false;
@@ -727,7 +727,7 @@
i2p::config::GetOption ("ssu2.published", isSSU2Published);
auto& addresses = m_RouterInfo.GetAddresses ();
for (auto& addr : addresses)
- if (addr->ssu && (!addr->IsSSU2 () || isSSU2Published) &&
+ if (addr->ssu && (!addr->IsSSU2 () || isSSU2Published) &&
((v4 && addr->IsV4 ()) || (v6 && addr->IsV6 ())))
{
addr->published = true;
@@ -781,11 +781,11 @@
}
port = addr->port;
}
- if (!port)
- {
+ if (!port)
+ {
i2p::config::GetOption("port", port);
if (!port) port = SelectRandomPort ();
- }
+ }
// SSU
bool ssu; i2p::config::GetOption("ssu", ssu);
if (!foundSSU && ssu)
@@ -871,11 +871,11 @@
}
if (addr->port) port = addr->port;
}
- if (!port)
- {
+ if (!port)
+ {
i2p::config::GetOption("port", port);
if (!port) port = SelectRandomPort ();
- }
+ }
// SSU
bool ssu; i2p::config::GetOption("ssu", ssu);
if (!foundSSU && ssu)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/RouterContext.h
^
|
@@ -37,10 +37,9 @@
eRouterStatusOK = 0,
eRouterStatusTesting = 1,
eRouterStatusFirewalled = 2,
- eRouterStatusError = 3,
- eRouterStatusUnknown = 4,
- eRouterStatusProxy = 5,
- eRouterStatusMesh = 6
+ eRouterStatusUnknown = 3,
+ eRouterStatusProxy = 4,
+ eRouterStatusMesh = 5
};
enum RouterError
@@ -105,12 +104,12 @@
void SetStatus (RouterStatus status);
void SetStatusSSU2 (RouterStatus status);
RouterError GetError () const { return m_Error; };
- void SetError (RouterError error) { m_Status = eRouterStatusError; m_Error = error; };
+ void SetError (RouterError error) { 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; };
+ void SetErrorV6 (RouterError error) { 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);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/RouterInfo.cpp
^
|
@@ -257,20 +257,38 @@
if (!ecode && !address->host.is_unspecified ()) isHost = true;
}
else if (!strcmp (key, "port"))
- address->port = boost::lexical_cast<int>(value);
+ {
+ try
+ {
+ address->port = boost::lexical_cast<int>(value);
+ }
+ catch (std::exception& ex)
+ {
+ LogPrint (eLogWarning, "RouterInfo: 'port' exception ", ex.what ());
+ }
+ }
else if (!strcmp (key, "mtu"))
{
if (address->ssu)
- address->ssu->mtu = boost::lexical_cast<int>(value);
+ {
+ try
+ {
+ address->ssu->mtu = boost::lexical_cast<int>(value);
+ }
+ catch (std::exception& ex)
+ {
+ LogPrint (eLogWarning, "RouterInfo: 'mtu' exception ", ex.what ());
+ }
+ }
else
- LogPrint (eLogWarning, "RouterInfo: Unexpected field 'mtu' for NTCP");
+ LogPrint (eLogWarning, "RouterInfo: Unexpected field 'mtu' for NTCP2");
}
else if (!strcmp (key, "key"))
{
if (address->ssu)
isIntroKey = (Base64ToByteStream (value, strlen (value), address->i, 32) == 32);
else
- LogPrint (eLogWarning, "RouterInfo: Unexpected field 'key' for NTCP");
+ LogPrint (eLogWarning, "RouterInfo: Unexpected field 'key' for NTCP2");
}
else if (!strcmp (key, "caps"))
address->caps = ExtractAddressCaps (value);
@@ -327,13 +345,40 @@
introducer.iHost = boost::asio::ip::address::from_string (value, ecode);
}
else if (!strcmp (key, "iport"))
- introducer.iPort = boost::lexical_cast<int>(value);
+ {
+ try
+ {
+ introducer.iPort = boost::lexical_cast<int>(value);
+ }
+ catch (std::exception& ex)
+ {
+ LogPrint (eLogWarning, "RouterInfo: 'iport' exception ", ex.what ());
+ }
+ }
else if (!strcmp (key, "itag"))
- introducer.iTag = boost::lexical_cast<uint32_t>(value);
+ {
+ try
+ {
+ introducer.iTag = boost::lexical_cast<uint32_t>(value);
+ }
+ catch (std::exception& ex)
+ {
+ LogPrint (eLogWarning, "RouterInfo: 'itag' exception ", ex.what ());
+ }
+ }
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);
+ {
+ try
+ {
+ introducer.iExp = boost::lexical_cast<uint32_t>(value);
+ }
+ catch (std::exception& ex)
+ {
+ LogPrint (eLogWarning, "RouterInfo: 'iexp' exception ", ex.what ());
+ }
+ }
}
if (!s) return;
}
@@ -386,10 +431,10 @@
((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;
@@ -422,16 +467,16 @@
int numValid = 0;
for (auto& it: address->ssu->introducers)
{
- if (it.iTag && ts <= it.iExp)
+ if (it.iTag && ts <= it.iExp)
numValid++;
- else
+ else
it.iTag = 0;
}
if (numValid)
m_ReachableTransports |= supportedTransports;
else
address->ssu->introducers.resize (0);
- }
+ }
}
else
{
@@ -445,15 +490,15 @@
ssu2addr->ssu.reset (new SSUExt ()); ssu2addr->ssu->mtu = address->ssu->mtu;
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
if (!address->ssu->introducers.empty ())
- {
+ {
for (const auto& introducer: address->ssu->introducers)
if (!introducer.iPort && introducer.iHost.is_unspecified () && ts < introducer.iExp) // SSU2
ssu2addr->ssu->introducers.push_back (introducer);
if (!ssu2addr->ssu->introducers.empty ())
m_ReachableTransports |= supportedTransports;
- }
+ }
addresses->push_back(ssu2addr);
- }
+ }
}
if (supportedTransports)
{
@@ -937,7 +982,7 @@
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSU2Address (bool v4) const
{
if (v4)
- {
+ {
if (m_SupportedTransports & eSSU2V4)
return GetSSU2V4Address ();
}
@@ -945,10 +990,10 @@
{
if (m_SupportedTransports & eSSU2V6)
return GetSSU2V6Address ();
- }
+ }
return nullptr;
- }
-
+ }
+
template<typename Filter>
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetAddress (Filter filter) const
{
@@ -980,7 +1025,7 @@
return GetAddress (
[key, isV6](std::shared_ptr<const RouterInfo::Address> address)->bool
{
- return address->IsSSU2 () && !memcmp (address->s, key, 32) &&
+ return address->IsSSU2 () && !memcmp (address->s, key, 32) &&
((isV6 && address->IsV6 ()) || (!isV6 && address->IsV4 ()));
});
}
@@ -1054,8 +1099,8 @@
return (address->IsSSU2 ()) && address->IsPeerTesting () &&
((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ())) && address->IsReachableSSU ();
});
- }
-
+ }
+
bool RouterInfo::IsIntroducer (bool v4) const
{
if (!(m_SupportedTransports & (v4 ? eSSUV4 : eSSUV6))) return false;
@@ -1077,7 +1122,7 @@
((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ())) && !address->host.is_unspecified ();
});
}
-
+
void RouterInfo::SetUnreachableAddressesTransportCaps (uint8_t transports)
{
for (auto& addr: *m_Addresses)
@@ -1099,7 +1144,7 @@
{
uint8_t transports = 0;
switch (addr->transportStyle)
- {
+ {
case eTransportNTCP:
if (addr->IsV4 ()) transports |= eNTCP2V4;
if (addr->IsV6 ())
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/RouterInfo.h
^
|
@@ -276,7 +276,7 @@
void RefreshTimestamp ();
const Addresses& GetAddresses () const { return *m_Addresses; };
CompatibleTransports GetReachableTransports () const { return m_ReachableTransports; };
- void SetReachableTransports (CompatibleTransports transports) { m_ReachableTransports = transports; };
+ void SetReachableTransports (CompatibleTransports transports) { m_ReachableTransports = transports; };
private:
@@ -321,7 +321,7 @@
bool AddSSU2Introducer (const Introducer& introducer, bool v4);
bool RemoveSSU2Introducer (const IdentHash& h, bool v4);
-
+
private:
void WriteToStream (std::ostream& s) const;
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/SSU2.cpp
^
|
@@ -17,14 +17,14 @@
namespace i2p
{
namespace transport
-{
+{
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_TerminationTimer (GetService ()), m_ResendTimer (GetService ()),
m_IntroducersUpdateTimer (GetService ()), m_IntroducersUpdateTimerV6 (GetService ()),
- m_IsPublished (true), m_IsSyncClockFromPeers (true)
+ m_IsPublished (true), m_IsSyncClockFromPeers (true), m_IsThroughProxy (false)
{
}
@@ -42,6 +42,25 @@
if (!address) continue;
if (address->transportStyle == i2p::data::RouterInfo::eTransportSSU2)
{
+ if (m_IsThroughProxy)
+ {
+ found = true;
+ if (address->IsV6 ())
+ {
+ uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
+ if (!mtu || mtu > SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE)
+ mtu = SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE;
+ i2p::context.SetMTU (mtu, false);
+ }
+ else
+ {
+ uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
+ if (!mtu || mtu > SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE)
+ mtu = SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE;
+ i2p::context.SetMTU (mtu, true);
+ }
+ continue; // we don't need port for proxy
+ }
auto port = address->port;
if (!port)
{
@@ -84,32 +103,43 @@
}
}
if (found)
+ {
+ if (m_IsThroughProxy)
+ ConnectToProxy ();
m_ReceiveService.Start ();
+ }
ScheduleTermination ();
+ ScheduleResend (false);
}
}
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 ();
+
+ if (m_UDPAssociateSocket)
+ {
+ m_UDPAssociateSocket->close ();
+ m_UDPAssociateSocket.reset (nullptr);
+ }
StopIOService ();
@@ -125,47 +155,56 @@
{
if (localAddress.is_unspecified ()) return;
if (localAddress.is_v4 ())
- {
+ {
m_AddressV4 = localAddress;
- int mtu = i2p::util::net::GetMTU (localAddress);
+ uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
+ if (!mtu) 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;
+ uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
+ if (!mtu)
+ {
+ int maxMTU = i2p::util::net::GetMaxMTU (localAddress.to_v6 ());
+ mtu = i2p::util::net::GetMTU (localAddress);
+ if (mtu > maxMTU) mtu = maxMTU;
+ }
+ else
+ if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
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 (m_IsThroughProxy)
+ return m_SocketV4.is_open ();
if (addr.is_v4 ())
- {
- if (m_SocketV4.is_open ())
+ {
+ if (m_SocketV4.is_open ())
return true;
- }
+ }
else if (addr.is_v6 ())
- {
- if (m_SocketV6.is_open ())
+ {
+ if (m_SocketV6.is_open ())
return true;
}
return false;
- }
+ }
uint16_t SSU2Server::GetPort (bool v4) const
{
boost::system::error_code ec;
- boost::asio::ip::udp::endpoint ep = v4 ? m_SocketV4.local_endpoint (ec) : m_SocketV6.local_endpoint (ec);
+ boost::asio::ip::udp::endpoint ep = (v4 || m_IsThroughProxy) ? m_SocketV4.local_endpoint (ec) : m_SocketV6.local_endpoint (ec);
if (ec) return 0;
return ep.port ();
- }
-
+ }
+
boost::asio::ip::udp::socket& SSU2Server::OpenSocket (const boost::asio::ip::udp::endpoint& localEndpoint)
{
boost::asio::ip::udp::socket& socket = localEndpoint.address ().is_v6 () ? m_SocketV6 : m_SocketV4;
@@ -238,10 +277,20 @@
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint (eLogError, "SSU2: Receive error: code ", ecode.value(), ": ", ecode.message ());
- auto ep = socket.local_endpoint ();
- socket.close ();
- OpenSocket (ep);
- Receive (socket);
+ if (m_IsThroughProxy)
+ {
+ m_UDPAssociateSocket.reset (nullptr);
+ m_ProxyRelayEndpoint.reset (nullptr);
+ m_SocketV4.close ();
+ ConnectToProxy ();
+ }
+ else
+ {
+ auto ep = socket.local_endpoint ();
+ socket.close ();
+ OpenSocket (ep);
+ Receive (socket);
+ }
}
}
}
@@ -250,19 +299,26 @@
{
if (packet)
{
- ProcessNextPacket (packet->buf, packet->len, packet->from);
+ if (m_IsThroughProxy)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/SSU2.h
^
|
@@ -18,14 +18,18 @@
namespace transport
{
const int SSU2_TERMINATION_CHECK_TIMEOUT = 30; // in seconds
- const int SSU2_RESEND_CHECK_TIMEOUT = 500; // in milliseconds
+ const int SSU2_RESEND_CHECK_TIMEOUT = 400; // in milliseconds
+ const int SSU2_RESEND_CHECK_TIMEOUT_VARIANCE = 100; // in milliseconds
+ const int SSU2_RESEND_CHECK_MORE_TIMEOUT = 10; // in milliseconds
+ const size_t SSU2_MAX_RESEND_PACKETS = 128; // packets to resend at the time
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
-
+ const int SSU2_KEEP_ALIVE_INTERVAL = 30; // in seconds
+ const int SSU2_PROXY_CONNECT_RETRY_TIMEOUT = 30; // in seconds
+
class SSU2Server: private i2p::util::RunnableServiceWithWork
{
struct Packet
@@ -54,10 +58,12 @@
void Stop ();
boost::asio::io_service& GetService () { return GetIOService (); };
void SetLocalAddress (const boost::asio::ip::address& localAddress);
+ bool SetProxy (const std::string& address, uint16_t port);
+ bool UsesProxy () const { return m_IsThroughProxy; };
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);
@@ -67,7 +73,7 @@
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);
@@ -80,17 +86,17 @@
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 ();
i2p::util::MemoryPool<SSU2SentPacket>& GetSentPacketsPool () { return m_SentPacketsPool; };
-
+
private:
boost::asio::ip::udp::socket& OpenSocket (const boost::asio::ip::udp::endpoint& localEndpoint);
@@ -104,17 +110,28 @@
void ScheduleTermination ();
void HandleTerminationTimer (const boost::system::error_code& ecode);
- void ScheduleResend ();
+ void ScheduleResend (bool more);
void HandleResendTimer (const boost::system::error_code& ecode);
void ConnectThroughIntroducer (std::shared_ptr<SSU2Session> session);
- std::list<std::shared_ptr<SSU2Session> > FindIntroducers (int maxNumIntroducers,
+ 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 ();
-
+
+ void SendThroughProxy (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);
+ void ProcessNextPacketFromProxy (uint8_t * buf, size_t len);
+ void ConnectToProxy ();
+ void ReconnectToProxy ();
+ void HandshakeWithProxy ();
+ void ReadHandshakeWithProxyReply ();
+ void SendUDPAssociateRequest ();
+ void ReadUDPAssociateReply ();
+ void ReadUDPAssociateSocket (); // handle if closed by peer
+
private:
ReceiveService m_ReceiveService;
@@ -133,7 +150,15 @@
std::shared_ptr<SSU2Session> m_LastSession;
bool m_IsPublished; // if we maintain introducers
bool m_IsSyncClockFromPeers;
-
+
+ // proxy
+ bool m_IsThroughProxy;
+ uint8_t m_UDPRequestHeader[SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE];
+ std::unique_ptr<boost::asio::ip::tcp::endpoint> m_ProxyEndpoint;
+ std::unique_ptr<boost::asio::ip::tcp::socket> m_UDPAssociateSocket;
+ std::unique_ptr<boost::asio::ip::udp::endpoint> m_ProxyRelayEndpoint;
+ std::unique_ptr<boost::asio::deadline_timer> m_ProxyConnectRetryTimer;
+
public:
// for HTTP/I2PControl
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/SSU2Session.cpp
^
|
@@ -31,16 +31,16 @@
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_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
{
@@ -68,17 +68,17 @@
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;
+ {
+ m_State = eSSU2SessionStateUnknown;
SendTokenRequest ();
- }
- }
+ }
+ }
}
void SSU2Session::ScheduleConnectTimer ()
@@ -98,7 +98,7 @@
Terminate ();
}
}
-
+
bool SSU2Session::Introduce (std::shared_ptr<SSU2Session> session, uint32_t relayTag)
{
// we are Alice
@@ -155,48 +155,51 @@
// create new connID
uint64_t oldConnID = GetConnID ();
RAND_bytes ((uint8_t *)&m_DestConnID, 8);
- RAND_bytes ((uint8_t *)&m_SourceConnID, 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 ();
+ auto ts = i2p::util::GetMillisecondsSinceEpoch ();
// session for message 5
auto session = std::make_shared<SSU2Session> (m_Server);
session->SetState (eSSU2SessionStatePeerTest);
- m_PeerTests.emplace (nonce, std::make_pair (session, ts));
+ m_PeerTests.emplace (nonce, std::make_pair (session, ts/1000));
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);
- }
- }
+ auto packet = m_Server.GetSentPacketsPool ().AcquireShared ();
+ packet->payloadSize = CreatePeerTestBlock (packet->payload, m_MaxPayloadSize, nonce);
+ if (packet->payloadSize > 0)
+ {
+ packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
+ uint32_t packetNum = SendData (packet->payload, packet->payloadSize, SSU2_FLAG_IMMEDIATE_ACK_REQUESTED);
+ packet->sendTime = ts;
+ m_SentPackets.emplace (packetNum, packet);
+ LogPrint (eLogDebug, "SSU2: PeerTest msg=1 sent to ", i2p::data::GetIdentHashAbbreviation (GetRemoteIdentity ()->GetIdentHash ()));
+ }
+ }
void SSU2Session::SendKeepAlive ()
{
if (IsEstablished ())
- {
+ {
uint8_t payload[20];
size_t payloadSize = CreatePaddingBlock (payload, 20, 5);
SendData (payload, payloadSize);
- }
- }
-
+ }
+ }
+
void SSU2Session::Terminate ()
{
if (m_State != eSSU2SessionStateTerminated)
@@ -207,6 +210,8 @@
if (m_RelayTag)
m_Server.RemoveRelay (m_RelayTag);
m_SentHandshakePacket.reset (nullptr);
+ m_SessionConfirmedFragment.reset (nullptr);
+ m_PathChallenge.reset (nullptr);
m_SendQueue.clear ();
m_SentPackets.clear ();
m_IncompleteMessages.clear ();
@@ -226,8 +231,8 @@
SendTermination ();
}
m_State = eSSU2SessionStateClosing;
- }
-
+ }
+
void SSU2Session::Established ()
{
m_State = eSSU2SessionStateEstablished;
@@ -238,11 +243,11 @@
m_ConnectTimer.cancel ();
SetTerminationTimeout (SSU2_TERMINATION_TIMEOUT);
transports.PeerConnected (shared_from_this ());
- if (m_OnEstablished)
- {
+ if (m_OnEstablished)
+ {
m_OnEstablished ();
m_OnEstablished = nullptr;
- }
+ }
}
void SSU2Session::Done ()
@@ -253,7 +258,7 @@
void SSU2Session::SendLocalRouterInfo (bool update)
{
if (update || !IsOutgoing ())
- {
+ {
auto s = shared_from_this ();
m_Server.GetService ().post ([s]()
{
@@ -265,14 +270,14 @@
if (payloadSize < s->m_MaxPayloadSize)
payloadSize += s->CreatePaddingBlock (payload + payloadSize, s->m_MaxPayloadSize - payloadSize);
s->SendData (payload, payloadSize);
- }
+ }
else
s->SendFragmentedMessage (CreateDatabaseStoreMsg ());
});
- }
+ }
+
+ }
- }
-
void SSU2Session::SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs)
{
m_Server.GetService ().post (std::bind (&SSU2Session::PostI2NPMessages, shared_from_this (), msgs));
@@ -286,16 +291,16 @@
SendQueue ();
if (m_SendQueue.size () > 0) // windows is full
- {
+ {
if (m_SendQueue.size () <= SSU2_MAX_OUTGOING_QUEUE_SIZE)
Resend (i2p::util::GetMillisecondsSinceEpoch ());
- else
+ else
{
LogPrint (eLogWarning, "SSU2: Outgoing messages queue size to ",
GetIdentHashBase64(), " exceeds ", SSU2_MAX_OUTGOING_QUEUE_SIZE);
RequestTermination (eSSU2TerminationReasonTimeout);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/SSU2Session.h
^
|
@@ -48,6 +48,9 @@
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
+ // flags
+ const uint8_t SSU2_FLAG_IMMEDIATE_ACK_REQUESTED = 0x01;
+
enum SSU2MessageType
{
eSSU2SessionRequest = 0,
@@ -101,7 +104,8 @@
eSSU2SessionStateFailed,
eSSU2SessionStateIntroduced,
eSSU2SessionStatePeerTest,
- eSSU2SessionStatePeerTestReceived // 5 before 4
+ eSSU2SessionStatePeerTestReceived, // 5 before 4
+ eSSU2SessionStateTokenRequestReceived
};
enum SSU2PeerTestCode
@@ -119,7 +123,7 @@
eSSU2PeerTestCodeCharlieAliceIsBanned = 69,
eSSU2PeerTestCodeCharlieAliceIsUnknown = 70,
eSSU2PeerTestCodeUnspecified = 128
- };
+ };
enum SSU2RelayResponseCode
{
@@ -128,7 +132,7 @@
eSSU2RelayResponseCodeCharlieUnsupportedAddress = 65,
eSSU2RelayResponseCodeCharlieSignatureFailure = 67,
eSSU2RelayResponseCodeCharlieAliceIsUnknown = 70
- };
+ };
enum SSU2TerminationReason
{
@@ -155,8 +159,8 @@
eSSU2TerminationReasonIncompatibleVersion = 20,
eSSU2TerminationReasonWrongNetID = 21,
eSSU2TerminationReasonReplacedByNewSession = 22
- };
-
+ };
+
struct SSU2IncompleteMessage
{
struct Fragment
@@ -181,7 +185,7 @@
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;
@@ -239,7 +243,7 @@
void SendLocalRouterInfo (bool update) override;
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) override;
uint32_t GetRelayTag () const override { return m_RelayTag; };
- void Resend (uint64_t ts);
+ size_t Resend (uint64_t ts); // return number or resent packets
bool IsEstablished () const { return m_State == eSSU2SessionStateEstablished; };
uint64_t GetConnID () const { return m_SourceConnID; };
SSU2SessionState GetState () const { return m_State; };
@@ -251,7 +255,7 @@
bool ProcessRetry (uint8_t * buf, size_t len);
bool ProcessHolePunch (uint8_t * buf, size_t len);
bool ProcessPeerTest (uint8_t * buf, size_t len);
- void ProcessData (uint8_t * buf, size_t len);
+ void ProcessData (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& from);
private:
@@ -264,7 +268,7 @@
bool SendFragmentedMessage (std::shared_ptr<I2NPMessage> msg);
void ResendHandshakePacket ();
void ConnectAfterIntroduction ();
-
+
void ProcessSessionRequest (Header& header, uint8_t * buf, size_t len);
void ProcessTokenRequest (Header& header, uint8_t * buf, size_t len);
@@ -274,13 +278,14 @@
void KDFDataPhase (uint8_t * keydata_ab, uint8_t * keydata_ba);
void SendTokenRequest ();
void SendRetry ();
- uint32_t SendData (const uint8_t * buf, size_t len); // returns packet num
+ uint32_t SendData (const uint8_t * buf, size_t len, uint8_t flags = 0); // returns packet num
void SendQuickAck ();
void SendTermination ();
void SendHolePunch (uint32_t nonce, const boost::asio::ip::udp::endpoint& ep, const uint8_t * introKey, uint64_t token);
- void SendPeerTest (uint8_t msg, const uint8_t * signedData, size_t signedDataLen, const uint8_t * introKey); // PeerTest message
+ void SendPeerTest (uint8_t msg, const uint8_t * signedData, size_t signedDataLen, const uint8_t * introKey); // PeerTest message
void SendPathResponse (const uint8_t * data, size_t len);
-
+ void SendPathChallenge ();
+
void HandlePayload (const uint8_t * buf, size_t len);
void HandleDateTime (const uint8_t * buf, size_t len);
void HandleAck (const uint8_t * buf, size_t len);
@@ -311,7 +316,7 @@
size_t CreateFirstFragmentBlock (uint8_t * buf, size_t len, std::shared_ptr<I2NPMessage> msg);
size_t CreateFollowOnFragmentBlock (uint8_t * buf, size_t len, std::shared_ptr<I2NPMessage> msg, uint8_t& fragmentNum, uint32_t msgID);
size_t CreateRelayIntroBlock (uint8_t * buf, size_t len, const uint8_t * introData, size_t introDataLen);
- size_t CreateRelayResponseBlock (uint8_t * buf, size_t len, SSU2RelayResponseCode code, uint32_t nonce, uint64_t token, bool v4);
+ size_t CreateRelayResponseBlock (uint8_t * buf, size_t len, SSU2RelayResponseCode code, uint32_t nonce, uint64_t token, bool v4);
size_t CreatePeerTestBlock (uint8_t * buf, size_t len, uint8_t msg, SSU2PeerTestCode code, const uint8_t * routerHash, const uint8_t * signedData, size_t signedDataLen);
size_t CreatePeerTestBlock (uint8_t * buf, size_t len, uint32_t nonce); // Alice
size_t CreateTerminationBlock (uint8_t * buf, size_t len);
@@ -344,6 +349,7 @@
boost::asio::deadline_timer m_ConnectTimer;
SSU2TerminationReason m_TerminationReason;
size_t m_MaxPayloadSize;
+ std::unique_ptr<i2p::data::IdentHash> m_PathChallenge;
};
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/SSUSession.cpp
^
|
@@ -719,8 +719,8 @@
if (i2p::context.GetStatus () == eRouterStatusTesting)
i2p::context.SetError (eRouterErrorSymmetricNAT);
}
- else if (i2p::context.GetStatus () == eRouterStatusError && i2p::context.GetError () == eRouterErrorSymmetricNAT)
- i2p::context.SetStatus (eRouterStatusTesting);
+ else if (i2p::context.GetError () == eRouterErrorSymmetricNAT)
+ i2p::context.SetError (eRouterErrorNone);
}
uint32_t nonce = bufbe32toh (buf);
buf += 4; // nonce
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Streaming.cpp
^
|
@@ -474,6 +474,29 @@
Close (); // check is all outgoing messages have been sent and we can send close
}
+ size_t Stream::Receive (uint8_t * buf, size_t len, int timeout)
+ {
+ if (!len) return 0;
+ size_t ret = 0;
+ std::condition_variable newDataReceived;
+ std::mutex newDataReceivedMutex;
+ std::unique_lock<std::mutex> l(newDataReceivedMutex);
+ AsyncReceive (boost::asio::buffer (buf, len),
+ [&ret, &newDataReceived, &newDataReceivedMutex](const boost::system::error_code& ecode, std::size_t bytes_transferred)
+ {
+ if (ecode == boost::asio::error::timed_out)
+ ret = 0;
+ else
+ ret = bytes_transferred;
+ std::unique_lock<std::mutex> l(newDataReceivedMutex);
+ newDataReceived.notify_all ();
+ },
+ timeout);
+ if (newDataReceived.wait_for (l, std::chrono::seconds (timeout)) == std::cv_status::timeout)
+ ret = 0;
+ return ret;
+ }
+
size_t Stream::Send (const uint8_t * buf, size_t len)
{
AsyncSend (buf, len, nullptr);
@@ -729,7 +752,7 @@
Terminate ();
break;
default:
- LogPrint (eLogWarning, "Streaming: Unexpected stream status ", (int)m_Status, "sSID=", m_SendStreamID);
+ LogPrint (eLogWarning, "Streaming: Unexpected stream status=", (int)m_Status, " for sSID=", m_SendStreamID);
};
}
@@ -855,7 +878,7 @@
for (const auto& it: packets)
{
auto msg = m_RoutingSession->WrapSingleMessage (m_LocalDestination.CreateDataMessage (
- it->GetBuffer (), it->GetLength (), m_Port, !m_RoutingSession->IsRatchets ()));
+ it->GetBuffer (), it->GetLength (), m_Port, !m_RoutingSession->IsRatchets (), it->IsSYN ()));
msgs.push_back (i2p::tunnel::TunnelMessageBlock
{
i2p::tunnel::eDeliveryTypeTunnel,
@@ -1085,8 +1108,6 @@
m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip),
m_PendingIncomingTimer (m_Owner->GetService ())
{
- if (m_Gzip)
- m_Deflator.reset (new i2p::data::GzipDeflator);
}
StreamingDestination::~StreamingDestination ()
@@ -1341,6 +1362,26 @@
acceptor (stream);
}
+ std::shared_ptr<Stream> StreamingDestination::AcceptStream (int timeout)
+ {
+ std::shared_ptr<i2p::stream::Stream> stream;
+ std::condition_variable streamAccept;
+ std::mutex streamAcceptMutex;
+ std::unique_lock<std::mutex> l(streamAcceptMutex);
+ AcceptOnce (
+ [&streamAccept, &streamAcceptMutex, &stream](std::shared_ptr<i2p::stream::Stream> s)
+ {
+ stream = s;
+ std::unique_lock<std::mutex> l(streamAcceptMutex);
+ streamAccept.notify_all ();
+ });
+ if (timeout)
+ streamAccept.wait_for (l, std::chrono::seconds (timeout));
+ else
+ streamAccept.wait (l);
+ return stream;
+ }
+
void StreamingDestination::HandlePendingIncomingTimer (const boost::system::error_code& ecode)
{
if (ecode != boost::asio::error::operation_aborted)
@@ -1365,7 +1406,7 @@
}
std::shared_ptr<I2NPMessage> StreamingDestination::CreateDataMessage (
- const uint8_t * payload, size_t len, uint16_t toPort, bool checksum)
+ const uint8_t * payload, size_t len, uint16_t toPort, bool checksum, bool gzip)
{
size_t size;
auto msg = m_I2NPMsgsPool.AcquireShared ();
@@ -1373,8 +1414,8 @@
buf += 4; // reserve for lengthlength
msg->len += 4;
- if (m_Gzip && m_Deflator)
- size = m_Deflator->Deflate (payload, len, buf, msg->maxLen - msg->len);
+ if (m_Gzip || gzip)
+ size = m_Deflator.Deflate (payload, len, buf, msg->maxLen - msg->len);
else
size = i2p::data::GzipNoCompression (payload, len, buf, msg->maxLen - msg->len);
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Streaming.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
*
@@ -185,7 +185,8 @@
template<typename Buffer, typename ReceiveHandler>
void AsyncReceive (const Buffer& buffer, ReceiveHandler handler, int timeout = 0);
size_t ReadSome (uint8_t * buf, size_t len) { return ConcatenatePackets (buf, len); };
-
+ size_t Receive (uint8_t * buf, size_t len, int timeout);
+
void AsyncClose() { m_Service.post(std::bind(&Stream::Close, shared_from_this())); };
/** only call close from destination thread, use Stream::AsyncClose for other threads */
@@ -278,13 +279,14 @@
bool IsAcceptorSet () const { return m_Acceptor != nullptr; };
void AcceptOnce (const Acceptor& acceptor);
void AcceptOnceAcceptor (std::shared_ptr<Stream> stream, Acceptor acceptor, Acceptor prev);
-
+ std::shared_ptr<Stream> AcceptStream (int timeout = 0); // sync
+
std::shared_ptr<i2p::client::ClientDestination> GetOwner () const { return m_Owner; };
void SetOwner (std::shared_ptr<i2p::client::ClientDestination> owner) { m_Owner = owner; };
uint16_t GetLocalPort () const { return m_LocalPort; };
void HandleDataMessagePayload (const uint8_t * buf, size_t len);
- std::shared_ptr<I2NPMessage> CreateDataMessage (const uint8_t * payload, size_t len, uint16_t toPort, bool checksum = true);
+ std::shared_ptr<I2NPMessage> CreateDataMessage (const uint8_t * payload, size_t len, uint16_t toPort, bool checksum = true, bool gzip = false);
Packet * NewPacket () { return m_PacketsPool.Acquire(); }
void DeletePacket (Packet * p) { return m_PacketsPool.Release(p); }
@@ -315,7 +317,7 @@
public:
i2p::data::GzipInflator m_Inflator;
- std::unique_ptr<i2p::data::GzipDeflator> m_Deflator;
+ i2p::data::GzipDeflator m_Deflator;
// for HTTP only
const decltype(m_Streams)& GetStreams () const { return m_Streams; };
@@ -336,11 +338,10 @@
int t = (timeout > MAX_RECEIVE_TIMEOUT) ? MAX_RECEIVE_TIMEOUT : timeout;
s->m_ReceiveTimer.expires_from_now (boost::posix_time::seconds(t));
int left = timeout - t;
- auto self = s->shared_from_this();
- self->m_ReceiveTimer.async_wait (
- [self, buffer, handler, left](const boost::system::error_code & ec)
+ s->m_ReceiveTimer.async_wait (
+ [s, buffer, handler, left](const boost::system::error_code & ec)
{
- self->HandleReceiveTimer(ec, buffer, handler, left);
+ s->HandleReceiveTimer(ec, buffer, handler, left);
});
}
});
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/TransportSession.h
^
|
@@ -27,7 +27,7 @@
const size_t IPV4_HEADER_SIZE = 20;
const size_t IPV6_HEADER_SIZE = 40;
const size_t UDP_HEADER_SIZE = 8;
-
+
class SignedData
{
public:
@@ -42,7 +42,7 @@
{
m_Stream.str("");
}
-
+
void Insert (const uint8_t * buf, size_t len)
{
m_Stream.write ((char *)buf, len);
@@ -68,7 +68,7 @@
std::stringstream m_Stream;
};
-
+
class TransportSession
{
public:
@@ -79,7 +79,7 @@
{
if (router)
m_RemoteIdentity = router->GetRouterIdentity ();
- m_CreationTime = m_LastActivityTimestamp;
+ m_CreationTime = m_LastActivityTimestamp;
}
virtual ~TransportSession () {};
@@ -109,7 +109,7 @@
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;
@@ -124,6 +124,15 @@
uint64_t m_LastActivityTimestamp;
uint32_t m_CreationTime; // seconds since epoch
};
+
+ // SOCKS5 proxy
+ const uint8_t SOCKS5_VER = 0x05;
+ const uint8_t SOCKS5_CMD_CONNECT = 0x01;
+ const uint8_t SOCKS5_CMD_UDP_ASSOCIATE = 0x03;
+ const uint8_t SOCKS5_ATYP_IPV4 = 0x01;
+ const uint8_t SOCKS5_ATYP_IPV6 = 0x04;
+ const size_t SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE = 10;
+ const size_t SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE = 22;
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Transports.cpp
^
|
@@ -167,6 +167,8 @@
m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service);
}
+ bool ipv4; i2p::config::GetOption("ipv4", ipv4);
+ bool ipv6; i2p::config::GetOption("ipv6", ipv6);
i2p::config::GetOption("nat", m_IsNAT);
m_X25519KeysPairSupplier.Start ();
m_IsRunning = true;
@@ -190,6 +192,8 @@
m_NTCP2Server->UseProxy(proxytype, proxyurl.host, proxyurl.port, proxyurl.user, proxyurl.pass);
i2p::context.SetStatus (eRouterStatusProxy);
+ if (ipv6)
+ i2p::context.SetStatusV6 (eRouterStatusProxy);
}
else
LogPrint(eLogError, "Transports: Unsupported NTCP2 proxy URL ", ntcp2proxy);
@@ -218,10 +222,29 @@
}
}
// create SSU2 server
- if (enableSSU2) m_SSU2Server = new SSU2Server ();
+ if (enableSSU2)
+ {
+ m_SSU2Server = new SSU2Server ();
+ std::string ssu2proxy; i2p::config::GetOption("ssu2.proxy", ssu2proxy);
+ if (!ssu2proxy.empty())
+ {
+ if (proxyurl.parse (ssu2proxy) && proxyurl.schema == "socks")
+ {
+ if (m_SSU2Server->SetProxy (proxyurl.host, proxyurl.port))
+ {
+ i2p::context.SetStatus (eRouterStatusProxy);
+ if (ipv6)
+ i2p::context.SetStatusV6 (eRouterStatusProxy);
+ }
+ else
+ LogPrint(eLogError, "Transports: Can't set SSU2 proxy ", ssu2proxy);
+ }
+ else
+ LogPrint(eLogError, "Transports: Invalid SSU2 proxy URL ", ssu2proxy);
+ }
+ }
// bind to interfaces
- bool ipv4; i2p::config::GetOption("ipv4", ipv4);
if (ipv4)
{
std::string address; i2p::config::GetOption("address4", address);
@@ -236,9 +259,19 @@
if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
}
}
+
+ if (enableSSU2)
+ {
+ uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
+ if (mtu)
+ {
+ 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);
+ }
+ }
}
- bool ipv6; i2p::config::GetOption("ipv6", ipv6);
if (ipv6)
{
std::string address; i2p::config::GetOption("address6", address);
@@ -253,6 +286,17 @@
if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
}
}
+
+ if (enableSSU2)
+ {
+ uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
+ if (mtu)
+ {
+ 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, false);
+ }
+ }
}
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
@@ -417,8 +461,7 @@
{
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, {},
- ts, ts + PEER_ROUTER_INFO_UPDATE_INTERVAL, {} })).first;
+ it = m_Peers.insert (std::pair<i2p::data::IdentHash, Peer>(ident, {r, ts})).first;
}
connected = ConnectToPeer (ident, it->second);
}
@@ -453,127 +496,81 @@
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.priority.empty ())
+ SetPriority (peer);
+ while (peer.numAttempts < (int)peer.priority.size ())
{
- if (m_NTCP2Server) // we support NTCP2
+ auto tr = peer.priority[peer.numAttempts];
+ peer.numAttempts++;
+ switch (tr)
{
- std::shared_ptr<const RouterInfo::Address> address;
- if (!peer.numAttempts) // NTCP2 ipv6
+ case i2p::data::RouterInfo::eNTCP2V4:
+ case i2p::data::RouterInfo::eNTCP2V6:
{
- if (context.GetRouterInfo ().IsNTCP2V6 () && peer.router->IsReachableBy (RouterInfo::eNTCP2V6))
+ if (!m_NTCP2Server) continue;
+ std::shared_ptr<const RouterInfo::Address> address = (tr == i2p::data::RouterInfo::eNTCP2V6) ?
+ peer.router->GetPublishedNTCP2V6Address () : peer.router->GetPublishedNTCP2V4Address ();
+ if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
+ address = nullptr;
+ if (address)
{
- address = peer.router->GetPublishedNTCP2V6Address ();
- if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
- address = nullptr;
+ auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router, address);
+ if( m_NTCP2Server->UsingProxy())
+ m_NTCP2Server->ConnectWithProxy(s);
+ else
+ m_NTCP2Server->Connect (s);
+ return true;
}
- peer.numAttempts++;
+ break;
}
- if (!address && peer.numAttempts == 1) // NTCP2 ipv4
+ case i2p::data::RouterInfo::eSSU2V4:
+ case i2p::data::RouterInfo::eSSU2V6:
{
- if (context.GetRouterInfo ().IsNTCP2 (true) && peer.router->IsReachableBy (RouterInfo::eNTCP2V4))
+ if (!m_SSU2Server) continue;
+ std::shared_ptr<const RouterInfo::Address> address = (tr == i2p::data::RouterInfo::eSSU2V6) ?
+ peer.router->GetSSU2V6Address () : peer.router->GetSSU2V4Address ();
+ if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
+ address = nullptr;
+ if (address && address->IsReachableSSU ())
{
- address = peer.router->GetPublishedNTCP2V4Address ();
- if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
- address = nullptr;
+ if (m_SSU2Server->CreateSession (peer.router, address))
+ return true;
}
- peer.numAttempts++;
- }
- if (address)
- {
- auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router, address);
- if( m_NTCP2Server->UsingProxy())
- m_NTCP2Server->ConnectWithProxy(s);
- else
- m_NTCP2Server->Connect (s);
- return true;
+ break;
}
- }
- else
- peer.numAttempts = 2; // switch to SSU
- }
- if (peer.numAttempts == 2 || peer.numAttempts == 3) // SSU2, 2 - ipv6, 3 - ipv4
- {
- if (m_SSU2Server)
- {
- std::shared_ptr<const RouterInfo::Address> address;
- if (peer.numAttempts == 2) // SSU2 ipv6
+ case i2p::data::RouterInfo::eSSUV4:
+ case i2p::data::RouterInfo::eSSUV6:
{
- if (context.GetRouterInfo ().IsSSU2V6 () && peer.router->IsReachableBy (RouterInfo::eSSU2V6))
+ if (!m_SSUServer) continue;
+ std::shared_ptr<const RouterInfo::Address> address = (tr == i2p::data::RouterInfo::eSSUV6) ?
+ peer.router->GetSSUV6Address () : peer.router->GetSSUAddress (true);
+ if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
+ address = nullptr;
+ if (address && address->IsReachableSSU ())
{
- address = peer.router->GetSSU2V6Address ();
- if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
- address = nullptr;
+ if (m_SSUServer->CreateSession (peer.router, address))
+ return true;
}
- peer.numAttempts++;
+ break;
}
- if (!address && peer.numAttempts == 3) // SSU2 ipv4
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/Transports.h
^
|
@@ -62,8 +62,8 @@
};
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
+ 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;
@@ -71,6 +71,13 @@
std::list<std::shared_ptr<TransportSession> > sessions;
uint64_t creationTime, nextRouterInfoUpdateTime;
std::vector<std::shared_ptr<i2p::I2NPMessage> > delayedMessages;
+ std::vector<i2p::data::RouterInfo::SupportedTransports> priority;
+
+ Peer (std::shared_ptr<const i2p::data::RouterInfo> r, uint64_t ts):
+ numAttempts (0), router (r), creationTime (ts),
+ nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL)
+ {
+ }
void Done ()
{
@@ -147,6 +154,7 @@
void HandleRequestComplete (std::shared_ptr<const i2p::data::RouterInfo> r, i2p::data::IdentHash ident);
void PostMessages (i2p::data::IdentHash ident, std::vector<std::shared_ptr<i2p::I2NPMessage> > msgs);
bool ConnectToPeer (const i2p::data::IdentHash& ident, Peer& peer);
+ void SetPriority (Peer& peer) const;
void HandlePeerCleanupTimer (const boost::system::error_code& ecode);
void HandlePeerTestTimer (const boost::system::error_code& ecode);
@@ -195,6 +203,9 @@
};
extern Transports transports;
+
+ void InitAddressFromIface ();
+ void InitTransports ();
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/api.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,6 +60,7 @@
else
i2p::log::Logger().SendTo (i2p::fs::DataDirPath (i2p::fs::GetAppName () + ".log"));
i2p::log::Logger().Start ();
+ i2p::transport::InitTransports ();
LogPrint(eLogInfo, "API: Starting NetDB");
i2p::data::netdb.Start();
LogPrint(eLogInfo, "API: Starting Transports");
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd/util.cpp
^
|
@@ -22,6 +22,9 @@
#include <pthread_np.h>
#endif
+#if defined(__APPLE__)
+# include <AvailabilityMacros.h>
+#endif
#ifdef _WIN32
#include <stdlib.h>
@@ -143,8 +146,15 @@
}
void SetThreadName (const char *name) {
-#if defined(__APPLE__) && !defined(__powerpc__)
+#if defined(__APPLE__)
+# if (!defined(MAC_OS_X_VERSION_10_6) || \
+ (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || \
+ defined(__POWERPC__))
+ /* pthread_setname_np is not there on <10.6 and all PPC.
+ So do nothing. */
+# else
pthread_setname_np((char*)name);
+# endif
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(pthread_self(), name);
#elif defined(__NetBSD__)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.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 43
+#define I2PD_VERSION_MINOR 44
#define I2PD_VERSION_MICRO 0
#define I2PD_VERSION_PATCH 0
#ifdef GITVER
@@ -31,7 +31,7 @@
#define I2P_VERSION_MAJOR 0
#define I2P_VERSION_MINOR 9
-#define I2P_VERSION_MICRO 55
+#define I2P_VERSION_MICRO 56
#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.44.0+git1.tar.gz/upstream/libi2pd_client/AddressBook.cpp
^
|
@@ -313,14 +313,14 @@
{
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 ()
@@ -397,6 +397,19 @@
return nullptr;
}
+ bool AddressBook::RecordExists (const std::string& address, const std::string& jump)
+ {
+ auto addr = FindAddress(address);
+ if (!addr)
+ return false;
+
+ i2p::data::IdentityEx ident;
+ if (ident.FromBase64 (jump) && ident.GetIdentHash () == addr->identHash)
+ return true;
+
+ return false;
+ }
+
void AddressBook::InsertAddress (const std::string& address, const std::string& jump)
{
auto pos = jump.find(".b32.i2p");
@@ -567,6 +580,7 @@
void AddressBook::LoadLocal ()
{
+ if (!m_Storage) return;
std::map<std::string, std::shared_ptr<Address>> localAddresses;
m_Storage->LoadLocal (localAddresses);
for (const auto& it: localAddresses)
@@ -819,40 +833,22 @@
}
else
m_Ident = addr->identHash;
- /* this code block still needs some love */
- std::condition_variable newDataReceived;
- std::mutex newDataReceivedMutex;
- auto leaseSet = i2p::client::context.GetSharedLocalDestination ()->FindLeaseSet (m_Ident);
- if (!leaseSet)
- {
- std::unique_lock<std::mutex> l(newDataReceivedMutex);
- i2p::client::context.GetSharedLocalDestination ()->RequestDestination (m_Ident,
- [&newDataReceived, &leaseSet, &newDataReceivedMutex](std::shared_ptr<i2p::data::LeaseSet> ls)
- {
- leaseSet = ls;
- std::unique_lock<std::mutex> l1(newDataReceivedMutex);
- newDataReceived.notify_all ();
- });
- if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT)) == std::cv_status::timeout)
- {
- LogPrint (eLogError, "Addressbook: Subscription LeaseSet request timeout expired");
- i2p::client::context.GetSharedLocalDestination ()->CancelDestinationRequest (m_Ident, false); // don't notify, because we know it already
- return false;
- }
- }
- if (!leaseSet) {
- /* still no leaseset found */
+ // save url parts for later use
+ std::string dest_host = url.host;
+ int dest_port = url.port ? url.port : 80;
+ // try to create stream to addressbook site
+ auto stream = i2p::client::context.GetSharedLocalDestination ()->CreateStream (m_Ident, dest_port);
+ if (!stream)
+ {
LogPrint (eLogError, "Addressbook: LeaseSet for address ", url.host, " not found");
return false;
- }
- if (m_Etag.empty() && m_LastModified.empty()) {
+ }
+ if (m_Etag.empty() && m_LastModified.empty())
+ {
m_Book.GetEtag (m_Ident, m_Etag, m_LastModified);
LogPrint (eLogDebug, "Addressbook: Loaded for ", url.host, ": ETag: ", m_Etag, ", Last-Modified: ", m_LastModified);
}
- /* save url parts for later use */
- std::string dest_host = url.host;
- int dest_port = url.port ? url.port : 80;
- /* create http request & send it */
+ // create http request & send it
i2p::http::HTTPReq req;
req.AddHeader("Host", dest_host);
req.AddHeader("User-Agent", "Wget/1.11.4");
@@ -863,44 +859,39 @@
req.AddHeader("If-None-Match", m_Etag);
if (!m_LastModified.empty())
req.AddHeader("If-Modified-Since", m_LastModified);
- /* convert url to relative */
+ // convert url to relative
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();
stream->Send ((const uint8_t *) request.data(), request.length());
- /* read response */
+ // read response
std::string response;
uint8_t recv_buf[4096];
bool end = false;
int numAttempts = 0;
while (!end)
{
- stream->AsyncReceive (boost::asio::buffer (recv_buf, 4096),
- [&](const boost::system::error_code& ecode, std::size_t bytes_transferred)
- {
- if (bytes_transferred)
- response.append ((char *)recv_buf, bytes_transferred);
- if (ecode == boost::asio::error::timed_out || !stream->IsOpen ())
- end = true;
- newDataReceived.notify_all ();
- },
- SUBSCRIPTION_REQUEST_TIMEOUT);
- std::unique_lock<std::mutex> l(newDataReceivedMutex);
- // wait 1 more second
- if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT + 1)) == std::cv_status::timeout)
+ size_t received = stream->Receive (recv_buf, 4096, SUBSCRIPTION_REQUEST_TIMEOUT);
+ if (received)
+ {
+ response.append ((char *)recv_buf, received);
+ if (!stream->IsOpen ()) end = true;
+ }
+ else if (!stream->IsOpen ())
+ end = true;
+ else
{
LogPrint (eLogError, "Addressbook: Subscriptions request timeout expired");
numAttempts++;
if (numAttempts > 5) end = true;
- }
+ }
}
// process remaining buffer
while (size_t len = stream->ReadSome (recv_buf, sizeof(recv_buf)))
response.append ((char *)recv_buf, len);
- /* parse response */
+ // parse response
i2p::http::HTTPRes res;
int res_head_len = res.parse(response);
if (res_head_len < 0)
@@ -913,7 +904,7 @@
LogPrint(eLogError, "Addressbook: Incomplete http response from ", dest_host, ", interrupted by timeout");
return false;
}
- /* assert: res_head_len > 0 */
+ // assert: res_head_len > 0
response.erase(0, res_head_len);
if (res.code == 304)
{
@@ -936,7 +927,7 @@
LogPrint(eLogError, "Addressbook: Response size mismatch, expected: ", len, ", got: ", response.length(), "bytes");
return false;
}
- /* assert: res.code == 200 */
+ // assert: res.code == 200
auto it = res.headers.find("ETag");
if (it != res.headers.end()) m_Etag = it->second;
it = res.headers.find("Last-Modified");
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/AddressBook.h
^
|
@@ -90,6 +90,8 @@
void InsertAddress (const std::string& address, const std::string& jump); // for jump links
void InsertFullAddress (std::shared_ptr<const i2p::data::IdentityEx> address);
+ bool RecordExists (const std::string& address, const std::string& jump);
+
bool LoadHostsFromStream (std::istream& f, bool is_update);
void DownloadComplete (bool success, const i2p::data::IdentHash& subscription, const std::string& etag, const std::string& lastModified);
//This method returns the ".b32.i2p" address
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/BOB.cpp
^
|
@@ -156,7 +156,7 @@
{
if (stream)
{
- auto conn = std::make_shared<I2PTunnelConnection> (this, stream, std::make_shared<boost::asio::ip::tcp::socket> (GetService ()), m_Endpoint, m_IsQuiet);
+ auto conn = std::make_shared<I2PTunnelConnection> (this, stream, m_Endpoint, m_IsQuiet);
AddHandler (conn);
conn->Connect ();
}
@@ -547,7 +547,7 @@
}
- m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType);
+ m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType, true);
SendReplyOK (m_Keys.GetPublic ()->ToBase64 ().c_str ());
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/ClientContext.cpp
^
|
@@ -261,7 +261,7 @@
static const std::string transient("transient");
if (!filename.compare (0, transient.length (), transient)) // starts with transient
{
- keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
+ keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType, true);
LogPrint (eLogInfo, "Clients: New transient keys address ", m_AddressBook.ToAddress(keys.GetPublic ()->GetIdentHash ()), " created");
return true;
}
@@ -288,7 +288,7 @@
else
{
LogPrint (eLogError, "Clients: Can't open file ", fullPath, " Creating new one with signature type ", sigType, " crypto type ", cryptoType);
- keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
+ keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType, true);
std::ofstream f (fullPath, std::ofstream::binary | std::ofstream::out);
size_t len = keys.GetFullLen ();
uint8_t * buf = new uint8_t[len];
@@ -328,7 +328,7 @@
i2p::data::SigningKeyType sigType, i2p::data::CryptoKeyType cryptoType,
const std::map<std::string, std::string> * params)
{
- i2p::data::PrivateKeys keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
+ i2p::data::PrivateKeys keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType, true);
auto localDestination = std::make_shared<RunnableClientDestination> (keys, isPublic, params);
AddLocalDestination (localDestination);
return localDestination;
@@ -339,7 +339,7 @@
i2p::data::SigningKeyType sigType, i2p::data::CryptoKeyType cryptoType,
const std::map<std::string, std::string> * params)
{
- i2p::data::PrivateKeys keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType);
+ i2p::data::PrivateKeys keys = i2p::data::PrivateKeys::CreateRandomKeys (sigType, cryptoType, true);
auto localDestination = std::make_shared<ClientDestination> (service, keys, isPublic, params);
AddLocalDestination (localDestination);
return localDestination;
@@ -726,6 +726,7 @@
std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, "");
bool isUniqueLocal = section.second.get(I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
+ bool ssl = section.second.get(I2P_SERVER_TUNNEL_SSL, false);
// I2CP
std::map<std::string, std::string> options;
@@ -799,11 +800,13 @@
if (!address.empty ())
serverTunnel->SetLocalAddress (address);
- if(!isUniqueLocal)
+ if (!isUniqueLocal)
{
LogPrint(eLogInfo, "Clients: Disabling loopback address mapping");
serverTunnel->SetUniqueLocal(isUniqueLocal);
}
+ if (ssl)
+ serverTunnel->SetSSL (true);
if (accessList.length () > 0)
{
std::set<i2p::data::IdentHash> idents;
@@ -865,7 +868,7 @@
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::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)
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/ClientContext.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
*
@@ -18,6 +18,7 @@
#include "HTTPProxy.h"
#include "SOCKS.h"
#include "I2PTunnel.h"
+#include "UDPTunnel.h"
#include "SAM.h"
#include "BOB.h"
#include "I2CP.h"
@@ -61,7 +62,7 @@
const char I2P_SERVER_TUNNEL_WEBIRC_PASSWORD[] = "webircpassword";
const char I2P_SERVER_TUNNEL_ADDRESS[] = "address";
const char I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL[] = "enableuniquelocal";
-
+ const char I2P_SERVER_TUNNEL_SSL[] = "ssl";
class ClientContext
{
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/HTTPProxy.cpp
^
|
@@ -36,12 +36,14 @@
"reg.i2p",
"stats.i2p",
"identiguy.i2p",
+ "notbob.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=" },
+ { "notbob.i2p", "http://nytzrhrjjfsutowojvxi7hphesskpqqr65wpistz6wa7cpajhp7a.b32.i2p/cgi-bin/jump.cgi?q=" }
};
static const char *pageHead =
@@ -80,8 +82,9 @@
/* error helpers */
void GenericProxyError(const std::string& title, const std::string& description);
void GenericProxyInfo(const std::string& title, const std::string& description);
- void HostNotFound(std::string & host);
- void SendProxyError(std::string & content);
+ void HostNotFound(std::string& host);
+ void SendProxyError(std::string& content);
+ void SendRedirect(std::string& address);
void ForwardToUpstreamProxy();
void HandleUpstreamHTTPProxyConnect(const boost::system::error_code & ec);
@@ -174,7 +177,7 @@
SendProxyError(content);
}
- void HTTPReqHandler::HostNotFound(std::string & host) {
+ void HTTPReqHandler::HostNotFound(std::string& host) {
std::stringstream ss;
ss << "<h1>" << tr("Proxy error: Host not found") << "</h1>\r\n"
<< "<p>" << tr("Remote host not found in router's addressbook") << "</p>\r\n"
@@ -191,7 +194,7 @@
SendProxyError(content);
}
- void HTTPReqHandler::SendProxyError(std::string & content)
+ void HTTPReqHandler::SendProxyError(std::string& content)
{
i2p::http::HTTPRes res;
res.code = 500;
@@ -207,6 +210,17 @@
std::bind(&HTTPReqHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
}
+ void HTTPReqHandler::SendRedirect(std::string& address)
+ {
+ i2p::http::HTTPRes res;
+ res.code = 302;
+ res.add_header("Location", address);
+ res.add_header("Connection", "close");
+ std::string response = res.to_string();
+ boost::asio::async_write(*m_sock, boost::asio::buffer(response), boost::asio::transfer_all(),
+ std::bind(&HTTPReqHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
+ }
+
bool HTTPReqHandler::ExtractAddressHelper(i2p::http::URL & url, std::string & b64, bool & confirm)
{
confirm = false;
@@ -237,6 +251,7 @@
req.RemoveHeader("Via");
req.RemoveHeader("From");
req.RemoveHeader("Forwarded");
+ req.RemoveHeader("DNT"); // Useless DoNotTrack flag
req.RemoveHeader("Accept", "Accept-Encoding"); // Accept*, but Accept-Encoding
/* drop proxy-disclosing headers */
req.RemoveHeader("X-Forwarded");
@@ -297,7 +312,14 @@
GenericProxyError(tr("Invalid request"), tr("addresshelper is not supported"));
return true;
}
- if (!i2p::client::context.GetAddressBook ().FindAddress (m_RequestURL.host) || m_Confirm)
+
+ if (i2p::client::context.GetAddressBook ().RecordExists (m_RequestURL.host, jump))
+ {
+ std::string full_url = m_RequestURL.to_string();
+ SendRedirect(full_url);
+ return true;
+ }
+ else if (!i2p::client::context.GetAddressBook ().FindAddress (m_RequestURL.host) || m_Confirm)
{
i2p::client::context.GetAddressBook ().InsertAddress (m_RequestURL.host, jump);
LogPrint (eLogInfo, "HTTPProxy: Added address from addresshelper for ", m_RequestURL.host);
@@ -313,7 +335,8 @@
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(/* 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 << 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:" );
+ ss << " <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 */
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/I2PTunnel.cpp
^
|
@@ -21,7 +21,7 @@
{
/** set standard socket options */
- static void I2PTunnelSetSocketOptions(std::shared_ptr<boost::asio::ip::tcp::socket> socket)
+ static void I2PTunnelSetSocketOptions (std::shared_ptr<boost::asio::ip::tcp::socket> socket)
{
if (socket && socket->is_open())
{
@@ -46,10 +46,13 @@
}
I2PTunnelConnection::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):
- I2PServiceHandler(owner), m_Socket (socket), m_Stream (stream),
- m_RemoteEndpoint (target), m_IsQuiet (quiet)
- {
+ const boost::asio::ip::tcp::endpoint& target, bool quiet,
+ std::shared_ptr<boost::asio::ssl::context> sslCtx):
+ I2PServiceHandler(owner), m_Stream (stream), m_RemoteEndpoint (target), m_IsQuiet (quiet)
+ {
+ m_Socket = std::make_shared<boost::asio::ip::tcp::socket> (owner->GetService ());
+ if (sslCtx)
+ m_SSL = std::make_shared<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > (*m_Socket, *sslCtx);
}
I2PTunnelConnection::~I2PTunnelConnection ()
@@ -69,7 +72,7 @@
Receive ();
}
- static boost::asio::ip::address GetLoopbackAddressFor(const i2p::data::IdentHash & addr)
+ boost::asio::ip::address GetLoopbackAddressFor(const i2p::data::IdentHash & addr)
{
boost::asio::ip::address_v4::bytes_type bytes;
const uint8_t * ident = addr;
@@ -80,24 +83,26 @@
}
#ifdef __linux__
- static void MapToLoopback(const std::shared_ptr<boost::asio::ip::tcp::socket> & sock, const i2p::data::IdentHash & addr)
+ static void MapToLoopback(std::shared_ptr<boost::asio::ip::tcp::socket> sock, const i2p::data::IdentHash & addr)
{
- // bind to 127.x.x.x address
- // where x.x.x are first three bytes from ident
- auto ourIP = GetLoopbackAddressFor(addr);
- boost::system::error_code ec;
- sock->bind (boost::asio::ip::tcp::endpoint (ourIP, 0), ec);
- if (ec)
- LogPrint (eLogError, "I2PTunnel: Can't bind ourIP to ", ourIP.to_string (), ": ", ec.message ());
-
+ if (sock)
+ {
+ // bind to 127.x.x.x address
+ // where x.x.x are first three bytes from ident
+ auto ourIP = GetLoopbackAddressFor(addr);
+ boost::system::error_code ec;
+ sock->bind (boost::asio::ip::tcp::endpoint (ourIP, 0), ec);
+ if (ec)
+ LogPrint (eLogError, "I2PTunnel: Can't bind ourIP to ", ourIP.to_string (), ": ", ec.message ());
+ }
}
#endif
void I2PTunnelConnection::Connect (bool isUniqueLocal)
{
- I2PTunnelSetSocketOptions(m_Socket);
if (m_Socket)
{
+ I2PTunnelSetSocketOptions (m_Socket);
#ifdef __linux__
if (isUniqueLocal && m_RemoteEndpoint.address ().is_v4 () &&
m_RemoteEndpoint.address ().to_v4 ().to_bytes ()[0] == 127)
@@ -131,6 +136,7 @@
void I2PTunnelConnection::Terminate ()
{
if (Kill()) return;
+ if (m_SSL) m_SSL = nullptr;
if (m_Stream)
{
m_Stream->Close ();
@@ -145,12 +151,17 @@
void I2PTunnelConnection::Receive ()
{
- m_Socket->async_read_some (boost::asio::buffer(m_Buffer, I2P_TUNNEL_CONNECTION_BUFFER_SIZE),
- std::bind(&I2PTunnelConnection::HandleReceived, shared_from_this (),
- std::placeholders::_1, std::placeholders::_2));
+ if (m_SSL)
+ m_SSL->async_read_some (boost::asio::buffer(m_Buffer, I2P_TUNNEL_CONNECTION_BUFFER_SIZE),
+ std::bind(&I2PTunnelConnection::HandleReceive, shared_from_this (),
+ std::placeholders::_1, std::placeholders::_2));
+ else
+ m_Socket->async_read_some (boost::asio::buffer(m_Buffer, I2P_TUNNEL_CONNECTION_BUFFER_SIZE),
+ std::bind(&I2PTunnelConnection::HandleReceive, shared_from_this (),
+ std::placeholders::_1, std::placeholders::_2));
}
- void I2PTunnelConnection::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
+ void I2PTunnelConnection::HandleReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred)
{
if (ecode)
{
@@ -239,8 +250,12 @@
void I2PTunnelConnection::Write (const uint8_t * buf, size_t len)
{
- boost::asio::async_write (*m_Socket, boost::asio::buffer (buf, len), boost::asio::transfer_all (),
- std::bind (&I2PTunnelConnection::HandleWrite, shared_from_this (), std::placeholders::_1));
+ if (m_SSL)
+ boost::asio::async_write (*m_SSL, boost::asio::buffer (buf, len), boost::asio::transfer_all (),
+ std::bind (&I2PTunnelConnection::HandleWrite, shared_from_this (), std::placeholders::_1));
+ else
+ boost::asio::async_write (*m_Socket, boost::asio::buffer (buf, len), boost::asio::transfer_all (),
+ std::bind (&I2PTunnelConnection::HandleWrite, shared_from_this (), std::placeholders::_1));
}
void I2PTunnelConnection::HandleConnect (const boost::system::error_code& ecode)
@@ -253,20 +268,43 @@
else
{
LogPrint (eLogDebug, "I2PTunnel: Connected");
- if (m_IsQuiet)
- StreamReceive ();
+ if (m_SSL)
+ m_SSL->async_handshake (boost::asio::ssl::stream_base::client,
+ std::bind (&I2PTunnelConnection::HandleHandshake, shared_from_this (), std::placeholders::_1));
else
- {
- // send destination first like received from I2P
- std::string dest = m_Stream->GetRemoteIdentity ()->ToBase64 ();
- dest += "\n";
- if(sizeof(m_StreamBuffer) >= dest.size()) {
- memcpy (m_StreamBuffer, dest.c_str (), dest.size ());
- }
- HandleStreamReceive (boost::system::error_code (), dest.size ());
+ Established ();
+ }
+ }
+
+ void I2PTunnelConnection::HandleHandshake (const boost::system::error_code& ecode)
+ {
+ if (ecode)
+ {
+ LogPrint (eLogError, "I2PTunnel: Handshake error: ", ecode.message ());
+ Terminate ();
+ }
+ else
+ {
+ LogPrint (eLogDebug, "I2PTunnel: SSL connected");
+ Established ();
+ }
+ }
+
+ void I2PTunnelConnection::Established ()
+ {
+ if (m_IsQuiet)
+ StreamReceive ();
+ else
+ {
+ // send destination first like received from I2P
+ std::string dest = m_Stream->GetRemoteIdentity ()->ToBase64 ();
+ dest += "\n";
+ if(sizeof(m_StreamBuffer) >= dest.size()) {
+ memcpy (m_StreamBuffer, dest.c_str (), dest.size ());
}
- Receive ();
+ HandleStreamReceive (boost::system::error_code (), dest.size ());
}
+ Receive ();
}
void I2PClientTunnelConnectionHTTP::Write (const uint8_t * buf, size_t len)
@@ -321,15 +359,24 @@
m_HeaderSent = true;
I2PTunnelConnection::Write ((uint8_t *)m_OutHeader.str ().c_str (), m_OutHeader.str ().length ());
}
+ else if (m_OutHeader.tellp () < I2P_TUNNEL_HTTP_MAX_HEADER_SIZE)
+ StreamReceive (); // read more header
+ else
+ {
+ LogPrint (eLogError, "I2PTunnel: HTTP header exceeds max size ", I2P_TUNNEL_HTTP_MAX_HEADER_SIZE);
+ Terminate ();
+ }
}
}
I2PServerTunnelConnectionHTTP::I2PServerTunnelConnectionHTTP (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, const std::string& host):
- I2PTunnelConnection (owner, stream, socket, target), m_Host (host),
+ const boost::asio::ip::tcp::endpoint& target, const std::string& host,
+ std::shared_ptr<boost::asio::ssl::context> sslCtx):
+ I2PTunnelConnection (owner, stream, target, true, sslCtx), m_Host (host),
m_HeaderSent (false), m_ResponseHeaderSent (false), m_From (stream->GetRemoteIdentity ())
{
+ if (sslCtx)
+ SSL_set_tlsext_host_name(GetSSL ()->native_handle(), host.c_str ());
}
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/I2PTunnel.h
^
|
@@ -16,9 +16,9 @@
#include <memory>
#include <sstream>
#include <boost/asio.hpp>
+#include <boost/asio/ssl.hpp>
#include "Identity.h"
#include "Destination.h"
-#include "Datagram.h"
#include "Streaming.h"
#include "I2PService.h"
#include "AddressBook.h"
@@ -34,6 +34,7 @@
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
+ const int I2P_TUNNEL_HTTP_MAX_HEADER_SIZE = 8192;
class I2PTunnelConnection: public I2PServiceHandler, public std::enable_shared_from_this<I2PTunnelConnection>
{
@@ -43,8 +44,9 @@
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,
- const boost::asio::ip::tcp::endpoint& target, bool quiet = true); // from I2P
+ I2PTunnelConnection (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
+ const boost::asio::ip::tcp::endpoint& target, bool quiet = true,
+ std::shared_ptr<boost::asio::ssl::context> sslCtx = nullptr); // from I2P
~I2PTunnelConnection ();
void I2PConnect (const uint8_t * msg = nullptr, size_t len = 0);
void Connect (bool isUniqueLocal = true);
@@ -55,21 +57,27 @@
void Terminate ();
void Receive ();
- void HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred);
+ void StreamReceive ();
virtual void Write (const uint8_t * buf, size_t len); // can be overloaded
- void HandleWrite (const boost::system::error_code& ecode);
virtual void WriteToStream (const uint8_t * buf, size_t len); // can be overloaded
- void StreamReceive ();
- void HandleStreamReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred);
- void HandleConnect (const boost::system::error_code& ecode);
+ std::shared_ptr<boost::asio::ip::tcp::socket> GetSocket () const { return m_Socket; };
+ std::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > GetSSL () const { return m_SSL; };
+
+ private:
- std::shared_ptr<const boost::asio::ip::tcp::socket> GetSocket () const { return m_Socket; };
+ void HandleConnect (const boost::system::error_code& ecode);
+ void HandleHandshake (const boost::system::error_code& ecode);
+ void Established ();
+ void HandleReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred);
+ void HandleWrite (const boost::system::error_code& ecode);
+ void HandleStreamReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred);
private:
uint8_t m_Buffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE], m_StreamBuffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE];
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
+ std::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > m_SSL;
std::shared_ptr<i2p::stream::Stream> m_Stream;
boost::asio::ip::tcp::endpoint m_RemoteEndpoint;
bool m_IsQuiet; // don't send destination
@@ -99,8 +107,8 @@
public:
I2PServerTunnelConnectionHTTP (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, const std::string& host);
+ const boost::asio::ip::tcp::endpoint& target, const std::string& host,
+ std::shared_ptr<boost::asio::ssl::context> sslCtx = nullptr);
protected:
@@ -120,8 +128,8 @@
public:
I2PTunnelConnectionIRC (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, const std::string& m_WebircPass);
+ const boost::asio::ip::tcp::endpoint& target, const std::string& m_WebircPass,
+ std::shared_ptr<boost::asio::ssl::context> sslCtx = nullptr);
protected:
@@ -171,162 +179,6 @@
std::unique_ptr<boost::asio::deadline_timer> m_KeepAliveTimer;
};
-
- /** 2 minute timeout for udp sessions */
- const uint64_t I2P_UDP_SESSION_TIMEOUT = 1000 * 60 * 2;
- const uint64_t I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL = 100; // in milliseconds
-
- /** max size for i2p udp */
- const size_t I2P_UDP_MAX_MTU = 64*1024;
-
- struct UDPSession
- {
- i2p::datagram::DatagramDestination * m_Destination;
- boost::asio::ip::udp::socket IPSocket;
- i2p::data::IdentHash Identity;
- boost::asio::ip::udp::endpoint FromEndpoint;
- boost::asio::ip::udp::endpoint SendEndpoint;
- uint64_t LastActivity;
-
- uint16_t LocalPort;
- uint16_t RemotePort;
-
- uint8_t m_Buffer[I2P_UDP_MAX_MTU];
-
- UDPSession(boost::asio::ip::udp::endpoint localEndpoint,
- const std::shared_ptr<i2p::client::ClientDestination> & localDestination,
- boost::asio::ip::udp::endpoint remote, const i2p::data::IdentHash * ident,
- uint16_t ourPort, uint16_t theirPort);
- void HandleReceived(const boost::system::error_code & ecode, std::size_t len);
- void Receive();
- };
-
-
- /** read only info about a datagram session */
- struct DatagramSessionInfo
- {
- /** the name of this forward */
- std::string Name;
- /** ident hash of local destination */
- std::shared_ptr<const i2p::data::IdentHash> LocalIdent;
- /** ident hash of remote destination */
- std::shared_ptr<const i2p::data::IdentHash> RemoteIdent;
- /** ident hash of IBGW in use currently in this session or nullptr if none is set */
- std::shared_ptr<const i2p::data::IdentHash> CurrentIBGW;
- /** ident hash of OBEP in use for this session or nullptr if none is set */
- std::shared_ptr<const i2p::data::IdentHash> CurrentOBEP;
- /** i2p router's udp endpoint */
- boost::asio::ip::udp::endpoint LocalEndpoint;
- /** client's udp endpoint */
- boost::asio::ip::udp::endpoint RemoteEndpoint;
- /** how long has this converstation been idle in ms */
- uint64_t idle;
- };
-
- typedef std::shared_ptr<UDPSession> UDPSessionPtr;
-
- /** server side udp tunnel, many i2p inbound to 1 ip outbound */
- class I2PUDPServerTunnel
- {
- public:
-
- 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 ();
-
- /** expire stale udp conversations */
- 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; }
-
- private:
-
- 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);
-
- private:
-
- bool m_IsUniqueLocal;
- const std::string m_Name;
- boost::asio::ip::address m_LocalAddress;
- boost::asio::ip::udp::endpoint m_RemoteEndpoint;
- std::mutex m_SessionsMutex;
- std::vector<UDPSessionPtr> m_Sessions;
- std::shared_ptr<i2p::client::ClientDestination> m_LocalDest;
- UDPSessionPtr m_LastSession;
- bool m_Gzip;
-
- public:
-
- bool isUpdated; // transient, used during reload only
- };
-
- class I2PUDPClientTunnel
- {
- public:
-
- 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 ();
- void Stop ();
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/SAM.cpp
^
|
@@ -709,7 +709,7 @@
LogPrint (eLogWarning, "SAM: ", SAM_PARAM_CRYPTO_TYPE, "error: ", ex.what ());
}
}
- auto keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType);
+ auto keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType, true);
#ifdef _MSC_VER
size_t l = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_DEST_REPLY,
keys.GetPublic ()->ToBase64 ().c_str (), keys.ToBase64 ().c_str ());
@@ -1481,7 +1481,7 @@
auto localDest = session->GetLocalDestination ();
auto datagramDest = localDest ? localDest->GetDatagramDestination () : nullptr;
if (datagramDest)
- {
+ {
i2p::data::IdentityEx dest;
dest.FromBase64 (destination);
if (session->Type == eSAMSessionTypeDatagram)
@@ -1490,7 +1490,7 @@
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);
}
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/UDPTunnel.cpp
^
|
@@ -0,0 +1,377 @@
+/*
+* 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 "Log.h"
+#include "util.h"
+#include "ClientContext.h"
+#include "I2PTunnel.h" // for GetLoopbackAddressFor
+#include "UDPTunnel.h"
+
+namespace i2p
+{
+namespace client
+{
+ void I2PUDPServerTunnel::HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)
+ {
+ if (!m_LastSession || m_LastSession->Identity.GetLL()[0] != from.GetIdentHash ().GetLL()[0] || fromPort != m_LastSession->RemotePort)
+ {
+ std::lock_guard<std::mutex> lock(m_SessionsMutex);
+ m_LastSession = ObtainUDPSession(from, toPort, fromPort);
+ }
+ m_LastSession->IPSocket.send_to(boost::asio::buffer(buf, len), m_RemoteEndpoint);
+ m_LastSession->LastActivity = i2p::util::GetMillisecondsSinceEpoch();
+ }
+
+ void I2PUDPServerTunnel::HandleRecvFromI2PRaw (uint16_t, uint16_t, const uint8_t * buf, size_t len)
+ {
+ if (m_LastSession)
+ {
+ m_LastSession->IPSocket.send_to(boost::asio::buffer(buf, len), m_RemoteEndpoint);
+ m_LastSession->LastActivity = i2p::util::GetMillisecondsSinceEpoch();
+ }
+ }
+
+ 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();
+ while(itr != m_Sessions.end()) {
+ if(now - (*itr)->LastActivity >= delta )
+ itr = m_Sessions.erase(itr);
+ else
+ ++itr;
+ }
+ }
+
+ 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;
+ for (const auto & s : m_Sessions) {
+ if (now - s.second->second >= delta)
+ removePorts.push_back(s.first);
+ }
+ for(auto port : removePorts) {
+ m_Sessions.erase(port);
+ }
+ }
+
+ UDPSessionPtr I2PUDPServerTunnel::ObtainUDPSession(const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort)
+ {
+ auto ih = from.GetIdentHash();
+ for (auto & s : m_Sessions )
+ {
+ if (s->Identity.GetLL()[0] == ih.GetLL()[0] && remotePort == s->RemotePort)
+ {
+ /** found existing session */
+ LogPrint(eLogDebug, "UDPServer: Found session ", s->IPSocket.local_endpoint(), " ", ih.ToBase32());
+ return s;
+ }
+ }
+ boost::asio::ip::address addr;
+ /** create new udp session */
+ if(m_IsUniqueLocal && m_LocalAddress.is_loopback())
+ {
+ auto ident = from.GetIdentHash();
+ addr = GetLoopbackAddressFor(ident);
+ }
+ else
+ addr = m_LocalAddress;
+ boost::asio::ip::udp::endpoint ep(addr, 0);
+ m_Sessions.push_back(std::make_shared<UDPSession>(ep, m_LocalDest, m_RemoteEndpoint, ih, localPort, remotePort));
+ auto & back = m_Sessions.back();
+ return back;
+ }
+
+ UDPSession::UDPSession(boost::asio::ip::udp::endpoint localEndpoint,
+ const std::shared_ptr<i2p::client::ClientDestination> & localDestination,
+ const boost::asio::ip::udp::endpoint& endpoint, const i2p::data::IdentHash& to,
+ uint16_t ourPort, uint16_t theirPort) :
+ m_Destination(localDestination->GetDatagramDestination()),
+ IPSocket(localDestination->GetService(), localEndpoint),
+ Identity (to), SendEndpoint(endpoint),
+ LastActivity(i2p::util::GetMillisecondsSinceEpoch()),
+ LocalPort(ourPort),
+ RemotePort(theirPort)
+ {
+ IPSocket.set_option (boost::asio::socket_base::receive_buffer_size (I2P_UDP_MAX_MTU ));
+ 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));
+ }
+
+ void UDPSession::HandleReceived(const boost::system::error_code & ecode, std::size_t len)
+ {
+ if(!ecode)
+ {
+ LogPrint(eLogDebug, "UDPSession: Forward ", len, "B from ", FromEndpoint);
+ auto ts = i2p::util::GetMillisecondsSinceEpoch();
+ auto session = m_Destination->GetSession (Identity);
+ if (ts > LastActivity + I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL)
+ m_Destination->SendDatagram(session, m_Buffer, len, LocalPort, RemotePort);
+ else
+ m_Destination->SendRawDatagram(session, m_Buffer, len, LocalPort, RemotePort);
+ size_t numPackets = 0;
+ while (numPackets < i2p::datagram::DATAGRAM_SEND_QUEUE_MAX_SIZE)
+ {
+ boost::system::error_code ec;
+ size_t moreBytes = IPSocket.available(ec);
+ if (ec || !moreBytes) break;
+ len = IPSocket.receive_from (boost::asio::buffer (m_Buffer, I2P_UDP_MAX_MTU), FromEndpoint, 0, ec);
+ m_Destination->SendRawDatagram (session, m_Buffer, len, LocalPort, RemotePort);
+ numPackets++;
+ }
+ if (numPackets > 0)
+ LogPrint(eLogDebug, "UDPSession: Forward more ", numPackets, "packets B from ", FromEndpoint);
+ m_Destination->FlushSendQueue (session);
+ LastActivity = ts;
+ Receive();
+ }
+ else
+ LogPrint(eLogError, "UDPSession: ", ecode.message());
+ }
+
+ I2PUDPServerTunnel::I2PUDPServerTunnel (const std::string & name, std::shared_ptr<i2p::client::ClientDestination> localDestination,
+ const boost::asio::ip::address& localAddress, const boost::asio::ip::udp::endpoint& forwardTo, uint16_t port, bool gzip) :
+ m_IsUniqueLocal (true), m_Name (name), m_LocalAddress (localAddress),
+ m_RemoteEndpoint (forwardTo), m_LocalDest (localDestination), m_Gzip (gzip)
+ {
+ }
+
+ I2PUDPServerTunnel::~I2PUDPServerTunnel ()
+ {
+ Stop ();
+ }
+
+ void I2PUDPServerTunnel::Start ()
+ {
+ m_LocalDest->Start ();
+
+ 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::Stop ()
+ {
+ auto dgram = m_LocalDest->GetDatagramDestination ();
+ if (dgram) dgram->ResetReceiver ();
+ }
+
+ std::vector<std::shared_ptr<DatagramSessionInfo> > I2PUDPServerTunnel::GetSessions ()
+ {
+ std::vector<std::shared_ptr<DatagramSessionInfo> > sessions;
+ std::lock_guard<std::mutex> lock (m_SessionsMutex);
+
+ for (UDPSessionPtr s: m_Sessions)
+ {
+ if (!s->m_Destination) continue;
+ auto info = s->m_Destination->GetInfoForRemote (s->Identity);
+ if (!info) continue;
+
+ 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->CurrentIBGW = info->IBGW;
+ sinfo->CurrentOBEP = info->OBEP;
+ sessions.push_back (sinfo);
+ }
+ return sessions;
+ }
+
+ I2PUDPClientTunnel::I2PUDPClientTunnel (const std::string & name, const std::string &remoteDest,
+ const boost::asio::ip::udp::endpoint& localEndpoint,
+ std::shared_ptr<i2p::client::ClientDestination> localDestination,
+ uint16_t remotePort, bool gzip) :
+ m_Name (name), m_RemoteDest (remoteDest), m_LocalDest (localDestination), m_LocalEndpoint (localEndpoint),
|
[-]
[+]
|
Added |
_service:tar_git:i2pd-2.44.0+git1.tar.gz/upstream/libi2pd_client/UDPTunnel.h
^
|
@@ -0,0 +1,187 @@
+/*
+* 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 UDPTUNNEL_H__
+#define UDPTUNNEL_H__
+
+#include <inttypes.h>
+#include <string>
+#include <memory>
+#include <thread>
+#include <vector>
+#include <unordered_map>
+#include <boost/asio.hpp>
+#include "Identity.h"
+#include "Destination.h"
+#include "Datagram.h"
+#include "AddressBook.h"
+
+namespace i2p
+{
+namespace client
+{
+ /** 2 minute timeout for udp sessions */
+ const uint64_t I2P_UDP_SESSION_TIMEOUT = 1000 * 60 * 2;
+ const uint64_t I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL = 100; // in milliseconds
+
+ /** max size for i2p udp */
+ const size_t I2P_UDP_MAX_MTU = 64*1024;
+
+ struct UDPSession
+ {
+ i2p::datagram::DatagramDestination * m_Destination;
+ boost::asio::ip::udp::socket IPSocket;
+ i2p::data::IdentHash Identity;
+ boost::asio::ip::udp::endpoint FromEndpoint;
+ boost::asio::ip::udp::endpoint SendEndpoint;
+ uint64_t LastActivity;
+
+ uint16_t LocalPort;
+ uint16_t RemotePort;
+
+ uint8_t m_Buffer[I2P_UDP_MAX_MTU];
+
+ UDPSession(boost::asio::ip::udp::endpoint localEndpoint,
+ const std::shared_ptr<i2p::client::ClientDestination> & localDestination,
+ const boost::asio::ip::udp::endpoint& remote, const i2p::data::IdentHash& ident,
+ uint16_t ourPort, uint16_t theirPort);
+ void HandleReceived(const boost::system::error_code & ecode, std::size_t len);
+ void Receive();
+ };
+
+
+ /** read only info about a datagram session */
+ struct DatagramSessionInfo
+ {
+ /** the name of this forward */
+ std::string Name;
+ /** ident hash of local destination */
+ std::shared_ptr<const i2p::data::IdentHash> LocalIdent;
+ /** ident hash of remote destination */
+ std::shared_ptr<const i2p::data::IdentHash> RemoteIdent;
+ /** ident hash of IBGW in use currently in this session or nullptr if none is set */
+ std::shared_ptr<const i2p::data::IdentHash> CurrentIBGW;
+ /** ident hash of OBEP in use for this session or nullptr if none is set */
+ std::shared_ptr<const i2p::data::IdentHash> CurrentOBEP;
+ /** i2p router's udp endpoint */
+ boost::asio::ip::udp::endpoint LocalEndpoint;
+ /** client's udp endpoint */
+ boost::asio::ip::udp::endpoint RemoteEndpoint;
+ /** how long has this converstation been idle in ms */
+ uint64_t idle;
+ };
+
+ typedef std::shared_ptr<UDPSession> UDPSessionPtr;
+
+ /** server side udp tunnel, many i2p inbound to 1 ip outbound */
+ class I2PUDPServerTunnel
+ {
+ public:
+
+ I2PUDPServerTunnel (const std::string & name,
+ std::shared_ptr<i2p::client::ClientDestination> localDestination,
+ const boost::asio::ip::address& localAddress,
+ const boost::asio::ip::udp::endpoint& forwardTo, uint16_t port, bool gzip);
+ ~I2PUDPServerTunnel ();
+
+ /** expire stale udp conversations */
+ 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; }
+
+ private:
+
+ 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);
+
+ private:
+
+ bool m_IsUniqueLocal;
+ const std::string m_Name;
+ boost::asio::ip::address m_LocalAddress;
+ boost::asio::ip::udp::endpoint m_RemoteEndpoint;
+ std::mutex m_SessionsMutex;
+ std::vector<UDPSessionPtr> m_Sessions;
+ std::shared_ptr<i2p::client::ClientDestination> m_LocalDest;
+ UDPSessionPtr m_LastSession;
+ bool m_Gzip;
+
+ public:
+
+ bool isUpdated; // transient, used during reload only
+ };
+
+ class I2PUDPClientTunnel
+ {
+ public:
+
+ I2PUDPClientTunnel (const std::string & name, const std::string &remoteDest,
+ const boost::asio::ip::udp::endpoint& localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination,
+ uint16_t remotePort, bool gzip);
+ ~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(); }
+
+ std::shared_ptr<ClientDestination> GetLocalDestination () const { return m_LocalDest; }
+ 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 ();
+
+ private:
+
+ const std::string m_Name;
+ std::mutex m_SessionsMutex;
+ std::unordered_map<uint16_t, std::shared_ptr<UDPConvo> > m_Sessions; // maps i2p port -> local udp convo
+ const std::string m_RemoteDest;
+ std::shared_ptr<i2p::client::ClientDestination> m_LocalDest;
+ const boost::asio::ip::udp::endpoint m_LocalEndpoint;
+ std::shared_ptr<const Address> m_RemoteAddr;
+ std::thread * m_ResolveThread;
+ 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:
+
+ bool isUpdated; // transient, used during reload only
+ };
+
+
+}
+}
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd.conf
^
|
@@ -4,39 +4,31 @@
## * syslog - use syslog, see man 3 syslog
log = syslog
# log = file
+## Path to logfile (default - autodetect)
+# logfile = /home/.system/var/log/i2pd/i2pd.log
## Log messages above this level (debug, info, *warn, error, none)
loglevel = none
+# logclftime = true
+
+# daemon = true
## Specify a family, router belongs to (default - none)
family = sailfishos
-## Network interface to bind to
# ifname =
# ifname4 =
# ifname6 =
-## External IPv4 or IPv6 address to listen for connections
-# host = 1.2.3.4
-
-## Local address to bind transport sockets to
-## Overrides host option if:
-## For ipv4: if ipv4 = true and nat = false
-## For ipv6: if 'host' is not set or ipv4 = true
# address4 =
# address6 =
-## Port to listen for connections
-## By default i2pd picks random port. You MUST pick a random number too,
-## don't just uncomment this
+# host = 1.2.3.4
# port = 4567
-## Enable communication through ipv4
ipv4 = true
-## Enable communication through ipv6
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, X - unlimited/floodfill
@@ -44,11 +36,21 @@
## Max % of bandwidth limit for transit. 0-100. 100 by default
share = 20
-## Router will not accept transit tunnels, disabling transit traffic completely
-## (default = false)
# notransit = true
+# floodfill = true
+
+[ntcp2]
+enabled = true
+# published = true
+# port = 4567
+
+[ssu2]
+enabled = true
+published = true
+# port = 4567
[http]
+## Web Console settings
enabled = true
address = 127.0.0.1
port = 7070
@@ -56,17 +58,26 @@
auth = true
user = jolla
pass = ahoisailors!
+## Currently supported english (default), afrikaans, armenian, chinese, french,
+## german, russian, turkmen, ukrainian and uzbek languages
# lang = english
[httpproxy]
enabled = true
address = 127.0.0.1
port = 4444
+# keys = http-proxy-keys.dat
+addresshelper = true
+# outproxy = http://false.i2p
[socksproxy]
enabled = true
address = 127.0.0.1
port = 4447
+# keys = socks-proxy-keys.dat
+# outproxy.enabled = false
+# outproxy = 127.0.0.1
+# outproxyport = 9050
[sam]
enabled = false
@@ -101,6 +112,13 @@
verify = true
threshold = 15
+[addressbook]
+## AddressBook subscription URL for initial setup
+## Default: reg.i2p at "mainline" I2P Network
+# defaulturl = http://shx5vqsw7usdaunyzr2qmes2fq37oumybpudrd4jjj4e4vk4uusa.b32.i2p/hosts.txt
+## Optional subscriptions URLs, separated by comma
+# subscriptions = http://reg.i2p/hosts.txt,http://identiguy.i2p/hosts.txt,http://stats.i2p/cgi-bin/newhosts.txt,http://rus.i2p/hosts.txt
+
[limits]
transittunnels = 1250
@@ -110,7 +128,16 @@
# routers =
# hidden = true
+[exploratory]
+# inbound.length = 2
+# inbound.quantity = 3
+# outbound.length = 2
+# outbound.quantity = 3
+
[persist]
profiles = true
addressbook = true
+[cpuext]
+# aesni = true
+# avx = true
|
[-]
[+]
|
Changed |
_service:tar_git:i2pd.yaml
^
|
@@ -1,6 +1,6 @@
Name: i2pd
Summary: End-to-End encrypted and anonymous Internet daemon
-Version: 2.43.0
+Version: 2.44.0
Release: 1
Group: Applications/Internet
License: BSD-3-Clause
@@ -65,7 +65,6 @@
- systemd
PkgBR:
- gcc-c++
- - cmake
- boost-devel >= 1.49
- systemd
# for the "family" stuff, need openssl binary
@@ -76,7 +75,7 @@
PkgConfigBR:
- libssl
- zlib
-Configure: cmake
+Builder: cmake
ConfigOptions:
- -DCMAKE_BUILD_TYPE=Release
# -DWITH_AESNI=%ifarch %ix86
@@ -86,7 +85,6 @@
# -DWITH_UPNP=OFF
# -DWITH_ADDRSANITIZER=ON
# -DWITH_THREADSANITIZER=ON
-Builder: none
NoIconCache: true
SubPackages:
|