mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
Compare commits
147 Commits
static-bui
...
2.47.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b97ef1af49 | ||
|
|
227697c388 | ||
|
|
a6bd8275ca | ||
|
|
6f01ebc0a5 | ||
|
|
98f06e3ba1 | ||
|
|
b6d1d8117b | ||
|
|
7b35c793f3 | ||
|
|
58ef08310d | ||
|
|
ec5c13a95e | ||
|
|
0a564d153a | ||
|
|
0a8da6bc2f | ||
|
|
46e4f4aea5 | ||
|
|
6d7f20961f | ||
|
|
4b7fcdc719 | ||
|
|
716926f0d7 | ||
|
|
24a14e3440 | ||
|
|
5470a3a453 | ||
|
|
c02c9c3c24 | ||
|
|
3154eda6a6 | ||
|
|
d50cf0ad83 | ||
|
|
d6ed9152ee | ||
|
|
a4759694c8 | ||
|
|
6610af08c2 | ||
|
|
4db643aa8e | ||
|
|
75c9f596b2 | ||
|
|
064c013a72 | ||
|
|
75ab385ab7 | ||
|
|
9e0389df1b | ||
|
|
1b921a2eac | ||
|
|
f2729b3efe | ||
|
|
231c02c058 | ||
|
|
a199084c99 | ||
|
|
64f0a545fd | ||
|
|
34617bcb44 | ||
|
|
5f8820d9d6 | ||
|
|
10dfe39f5f | ||
|
|
b7f0d87daf | ||
|
|
3ff1adf597 | ||
|
|
93d89a1fe0 | ||
|
|
3c9a574e90 | ||
|
|
de82b3ae19 | ||
|
|
4b421d3feb | ||
|
|
f84d88ac63 | ||
|
|
2e62f9532f | ||
|
|
5657079355 | ||
|
|
bd63383d7f | ||
|
|
db0f2fab11 | ||
|
|
f33b0cad2e | ||
|
|
e3fbc246f4 | ||
|
|
d602ea1061 | ||
|
|
d40cd00cdb | ||
|
|
692600dfac | ||
|
|
95cc544c92 | ||
|
|
8544283110 | ||
|
|
abf687ff09 | ||
|
|
be2629aa5a | ||
|
|
ebee6c5f13 | ||
|
|
3adff82d4a | ||
|
|
200ad5524d | ||
|
|
82ac0aa492 | ||
|
|
b8a99878b6 | ||
|
|
eaca435a5b | ||
|
|
ce05cce331 | ||
|
|
e190dab7d6 | ||
|
|
289c308600 | ||
|
|
bff12b06f4 | ||
|
|
b8590075e6 | ||
|
|
1da9e2e1c0 | ||
|
|
a1fb97cfad | ||
|
|
e53fe2d988 | ||
|
|
182a721674 | ||
|
|
00c75a7afa | ||
|
|
385e592045 | ||
|
|
359781c698 | ||
|
|
c6c7191682 | ||
|
|
fa286a6fb3 | ||
|
|
02a36a9fa8 | ||
|
|
77142e59ee | ||
|
|
4156900fb5 | ||
|
|
76d39cc7c9 | ||
|
|
9e0c5d67c7 | ||
|
|
03111ad0df | ||
|
|
abb81c353d | ||
|
|
1ad38c0b95 | ||
|
|
532a29b0c4 | ||
|
|
4f3a416e37 | ||
|
|
4d0ad47491 | ||
|
|
7b632bd03d | ||
|
|
c2faa5c614 | ||
|
|
d15581d95e | ||
|
|
7bde4de1f5 | ||
|
|
88f19f551d | ||
|
|
d79bdc9f66 | ||
|
|
48a3c767e5 | ||
|
|
86fc12e395 | ||
|
|
3c65012a63 | ||
|
|
97b7ea0da5 | ||
|
|
1c4cc02c23 | ||
|
|
ac94341203 | ||
|
|
234540f9e7 | ||
|
|
cb44a35fde | ||
|
|
6ac849fe37 | ||
|
|
0829b186b7 | ||
|
|
993900aa77 | ||
|
|
aac9a8d18f | ||
|
|
2baaa8bb8f | ||
|
|
f29ef2c057 | ||
|
|
d1c98c58b9 | ||
|
|
4930157e93 | ||
|
|
d30d1e8a7d | ||
|
|
80a55c5b75 | ||
|
|
3c02cade58 | ||
|
|
21123e2afa | ||
|
|
f1415c2234 | ||
|
|
212a1156a1 | ||
|
|
54fb234424 | ||
|
|
5a6b50ae51 | ||
|
|
21542e8150 | ||
|
|
544fcd147f | ||
|
|
9bc3b11b96 | ||
|
|
02e7f6b0c3 | ||
|
|
f7101cc260 | ||
|
|
e9f0ed6473 | ||
|
|
4960587f46 | ||
|
|
bf8eecf407 | ||
|
|
09a1a78bd6 | ||
|
|
7df2ed6114 | ||
|
|
22b1066b0a | ||
|
|
89695a7040 | ||
|
|
2ed281472f | ||
|
|
fafdb0c590 | ||
|
|
2a6883e305 | ||
|
|
3cee8bfcb2 | ||
|
|
86dbfdb536 | ||
|
|
70fec2bc99 | ||
|
|
8a106eb09e | ||
|
|
f9331897b8 | ||
|
|
126ca0209b | ||
|
|
ad5540c9f3 | ||
|
|
e91d0bbec8 | ||
|
|
8ee461f60a | ||
|
|
4de6201b84 | ||
|
|
273aa31b1e | ||
|
|
b31f52e332 | ||
|
|
4fae7b8d65 | ||
|
|
5479ddd03c | ||
|
|
1f23584c24 |
@@ -30,3 +30,7 @@ indent_size = 4
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
25
.github/workflows/build-deb.yml
vendored
25
.github/workflows/build-deb.yml
vendored
@@ -6,27 +6,34 @@ jobs:
|
||||
build:
|
||||
name: ${{ matrix.dist }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
dist: ['buster', 'bullseye', 'bookworm']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
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
|
||||
|
||||
- name: Build package
|
||||
uses: jtdor/build-deb-action@v1
|
||||
with:
|
||||
docker-image: debian:${{ matrix.dist }}-slim
|
||||
buildpackage-opts: --build=binary --no-sign
|
||||
- uses: actions/upload-artifact@v3
|
||||
before-build-hook: debchange --controlmaint --local "+${{ github.sha }}~${{ matrix.dist }}" -b --distribution ${{ matrix.dist }} "CI build"
|
||||
extra-build-deps: devscripts git
|
||||
|
||||
- name: Upload package
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd_${{ matrix.dist }}
|
||||
path: debian/artifacts/i2pd_*.deb
|
||||
- uses: actions/upload-artifact@v3
|
||||
|
||||
- name: Upload debugging symbols
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd-dbgsym_${{ matrix.dist }}
|
||||
path: debian/artifacts/i2pd-dbgsym_*.deb
|
||||
|
||||
10
.github/workflows/build-freebsd.yml
vendored
10
.github/workflows/build-freebsd.yml
vendored
@@ -6,8 +6,11 @@ jobs:
|
||||
build:
|
||||
runs-on: macos-12
|
||||
name: with UPnP
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Test in FreeBSD
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v0.3.0
|
||||
@@ -21,8 +24,9 @@ jobs:
|
||||
cd build
|
||||
cmake -DWITH_UPNP=ON -DCMAKE_BUILD_TYPE=Release .
|
||||
gmake -j2
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd-freebsd
|
||||
path: build/i2pd
|
||||
path: build/i2pd
|
||||
|
||||
7
.github/workflows/build-osx.yml
vendored
7
.github/workflows/build-osx.yml
vendored
@@ -6,16 +6,21 @@ jobs:
|
||||
build:
|
||||
name: With USE_UPNP=${{ matrix.with_upnp }}
|
||||
runs-on: macOS-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
with_upnp: ['yes', 'no']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install packages
|
||||
run: |
|
||||
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
|
||||
brew update
|
||||
brew install boost miniupnpc openssl@1.1
|
||||
|
||||
- name: build application
|
||||
run: make HOMEBREW=1 USE_UPNP=${{ matrix.with_upnp }} PREFIX=$GITHUB_WORKSPACE/output -j3
|
||||
|
||||
52
.github/workflows/build-windows-msvc.yml
vendored
Normal file
52
.github/workflows/build-windows-msvc.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: Build on Windows with MSVC
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: windows-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Build and install zlib
|
||||
run: |
|
||||
powershell -Command "(Invoke-WebRequest -Uri https://raw.githubusercontent.com/r4sas/zlib.install/master/install.bat -OutFile install_zlib.bat)"
|
||||
powershell -Command "(Get-Content install_zlib.bat) | Set-Content install_zlib.bat" # fixing line endings
|
||||
set BUILD_TYPE=Debug
|
||||
./install_zlib.bat
|
||||
set BUILD_TYPE=Release
|
||||
./install_zlib.bat
|
||||
del install_zlib.bat
|
||||
|
||||
- name: Install Boost
|
||||
uses: crazy-max/ghaction-chocolatey@v2
|
||||
with:
|
||||
args: install boost-msvc-14.3
|
||||
|
||||
- name: Install OpenSSL
|
||||
uses: crazy-max/ghaction-chocolatey@v2
|
||||
with:
|
||||
args: install openssl
|
||||
|
||||
- name: Configure
|
||||
working-directory: build
|
||||
run: cmake -DWITH_STATIC=ON .
|
||||
|
||||
- name: Build
|
||||
working-directory: build
|
||||
run: cmake --build . --config Debug -- -m
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd-msvc
|
||||
path: build/Debug/i2pd.*
|
||||
|
||||
88
.github/workflows/build-windows.yml
vendored
88
.github/workflows/build-windows.yml
vendored
@@ -8,44 +8,106 @@ defaults:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Building using ${{ matrix.arch }} toolchain
|
||||
name: ${{ matrix.arch }}
|
||||
runs-on: windows-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: [
|
||||
{ msystem: UCRT64, arch: ucrt-x86_64, arch_short: x64-ucrt },
|
||||
{ msystem: MINGW64, arch: x86_64, arch_short: x64 },
|
||||
{ msystem: MINGW32, arch: i686, arch_short: x86 }
|
||||
{ msystem: UCRT64, arch: ucrt-x86_64, arch_short: x64-ucrt, compiler: gcc },
|
||||
{ msystem: CLANG64, arch: clang-x86_64, arch_short: x64-clang, compiler: clang },
|
||||
{ msystem: MINGW64, arch: x86_64, arch_short: x64, compiler: gcc },
|
||||
{ msystem: MINGW32, arch: i686, arch_short: x86, compiler: gcc }
|
||||
]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: ${{ matrix.msystem }}
|
||||
install: base-devel mingw-w64-${{ matrix.arch }}-gcc mingw-w64-${{ matrix.arch }}-boost mingw-w64-${{ matrix.arch }}-openssl mingw-w64-${{ matrix.arch }}-miniupnpc
|
||||
install: base-devel git mingw-w64-${{ matrix.arch }}-${{ matrix.compiler }} mingw-w64-${{ matrix.arch }}-boost mingw-w64-${{ matrix.arch }}-openssl mingw-w64-${{ matrix.arch }}-miniupnpc
|
||||
update: true
|
||||
|
||||
- name: Install additional clang packages
|
||||
if: ${{ matrix.msystem == 'CLANG64' }}
|
||||
run: pacman --noconfirm -S mingw-w64-${{ matrix.arch }}-gcc-compat
|
||||
|
||||
- name: Build application
|
||||
run: |
|
||||
mkdir -p obj/Win32 obj/libi2pd obj/libi2pd_client obj/daemon
|
||||
make USE_UPNP=yes DEBUG=no USE_GIT_VERSION=yes -j3
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd-${{ matrix.arch_short }}.exe
|
||||
path: i2pd.exe
|
||||
build-xp:
|
||||
name: Building for Windows XP
|
||||
|
||||
build-cmake:
|
||||
name: CMake ${{ matrix.arch }}
|
||||
runs-on: windows-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: [
|
||||
{ msystem: UCRT64, arch: ucrt-x86_64, arch_short: x64-ucrt, compiler: gcc },
|
||||
{ msystem: CLANG64, arch: clang-x86_64, arch_short: x64-clang, compiler: clang },
|
||||
{ msystem: MINGW64, arch: x86_64, arch_short: x64, compiler: gcc },
|
||||
{ msystem: MINGW32, arch: i686, arch_short: x86, compiler: gcc }
|
||||
]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: ${{ matrix.msystem }}
|
||||
install: base-devel git mingw-w64-${{ matrix.arch }}-cmake mingw-w64-${{ matrix.arch }}-ninja mingw-w64-${{ matrix.arch }}-${{ matrix.compiler }} mingw-w64-${{ matrix.arch }}-boost mingw-w64-${{ matrix.arch }}-openssl mingw-w64-${{ matrix.arch }}-miniupnpc
|
||||
update: true
|
||||
|
||||
- name: Build application
|
||||
run: |
|
||||
cd build
|
||||
cmake -DWITH_GIT_VERSION=ON -DWITH_STATIC=ON -DWITH_UPNP=ON -DCMAKE_BUILD_TYPE=Release .
|
||||
cmake --build . -- -j3
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd-cmake-${{ matrix.arch_short }}.exe
|
||||
path: build/i2pd.exe
|
||||
|
||||
build-xp:
|
||||
name: XP
|
||||
runs-on: windows-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MINGW32
|
||||
install: base-devel git mingw-w64-i686-gcc mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-miniupnpc
|
||||
update: true
|
||||
|
||||
- name: Build WinXP-capable CRT packages
|
||||
run: |
|
||||
git clone https://github.com/msys2/MINGW-packages
|
||||
@@ -64,12 +126,14 @@ jobs:
|
||||
pacman --noconfirm -U mingw-w64-i686-libwinpthread-git-*-any.pkg.tar.zst mingw-w64-i686-winpthreads-git-*-any.pkg.tar.zst
|
||||
popd
|
||||
popd
|
||||
|
||||
- name: Build application
|
||||
run: |
|
||||
mkdir -p obj/Win32 obj/libi2pd obj/libi2pd_client obj/daemon
|
||||
make USE_UPNP=yes DEBUG=no USE_GIT_VERSION=yes USE_WINXP_FLAGS=yes -j3
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: i2pd-xp.exe
|
||||
path: i2pd.exe
|
||||
|
||||
35
.github/workflows/build.yml
vendored
35
.github/workflows/build.yml
vendored
@@ -5,50 +5,45 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
build-make:
|
||||
name: Make with USE_UPNP=${{ matrix.with_upnp }}
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
with_upnp: ['yes', 'no']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential libboost-all-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
||||
|
||||
- name: build application
|
||||
run: make USE_UPNP=${{ matrix.with_upnp }} -j3
|
||||
|
||||
build-cmake:
|
||||
name: CMake with -DWITH_UPNP=${{ matrix.with_upnp }}
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
with_upnp: ['ON', 'OFF']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential cmake libboost-all-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
||||
|
||||
- name: build application
|
||||
run: |
|
||||
cd build
|
||||
cmake -DWITH_UPNP=${{ matrix.with_upnp }} .
|
||||
make -j3
|
||||
build-static:
|
||||
name: Static build with UPnP
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential libboost-all-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
||||
- name: build application
|
||||
run: make DEBUG=no USE_STATIC=yes USE_UPNP=yes -j`nproc`
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: i2pd-amd64-static
|
||||
path: i2pd
|
||||
|
||||
168
.github/workflows/docker.yml
vendored
168
.github/workflows/docker.yml
vendored
@@ -10,6 +10,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Building container for ${{ matrix.platform }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
@@ -25,41 +26,44 @@ jobs:
|
||||
]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-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 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: Login to GitHub Container registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build container for ${{ matrix.archname }}
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./contrib/docker
|
||||
file: ./contrib/docker/Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
push: true
|
||||
tags: |
|
||||
purplei2p/i2pd:latest-${{ matrix.archname }}
|
||||
ghcr.io/purplei2p/i2pd:latest-${{ matrix.archname }}
|
||||
- name: Build container for ${{ matrix.archname }}
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./contrib/docker
|
||||
file: ./contrib/docker/Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
push: true
|
||||
tags: |
|
||||
purplei2p/i2pd:latest-${{ matrix.archname }}
|
||||
ghcr.io/purplei2p/i2pd:latest-${{ matrix.archname }}
|
||||
provenance: false
|
||||
|
||||
push:
|
||||
name: Pushing merged manifest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
@@ -67,74 +71,60 @@ jobs:
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-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 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: 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: Create and push latest manifest image to Docker Hub
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
inputs: purplei2p/i2pd:latest
|
||||
images: purplei2p/i2pd:latest-amd64,purplei2p/i2pd:latest-i386,purplei2p/i2pd:latest-arm64,purplei2p/i2pd:latest-armv7
|
||||
push: true
|
||||
|
||||
- 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: Create and push latest manifest image to GHCR
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
inputs: ghcr.io/purplei2p/i2pd:latest
|
||||
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: Store release version to env
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
|
||||
|
||||
- name: Create and push release manifest image to Docker Hub
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
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 to Docker Hub
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
inputs: purplei2p/i2pd:latest,purplei2p/i2pd:latest-release,purplei2p/i2pd:release-${{ env.RELEASE_VERSION }}
|
||||
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
|
||||
- name: Create and push release manifest to GHCR
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
inputs: ghcr.io/purplei2p/i2pd:latest,ghcr.io/purplei2p/i2pd:latest-release,ghcr.io/purplei2p/i2pd:release-${{ env.RELEASE_VERSION }}
|
||||
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
|
||||
|
||||
55
ChangeLog
55
ChangeLog
@@ -1,6 +1,59 @@
|
||||
# for this file format description,
|
||||
# see https://github.com/olivierlacan/keep-a-changelog
|
||||
|
||||
## [2.47.0] - 2023-03-11
|
||||
### Added
|
||||
- Congestion caps
|
||||
- SAM UDP port parameter
|
||||
- Support domain addresses for yggdrasil reseeds
|
||||
### Changed
|
||||
- DHT for floodfills instead plain list
|
||||
- Process router's messages in separate thread
|
||||
- Don't publish non-reachable router
|
||||
- Send and check target destination in first streaming SYN packet
|
||||
- Reseeds list
|
||||
### Fixed
|
||||
- Memory leak in windows network state detection
|
||||
- Reseed attempts from invalid address
|
||||
|
||||
## [2.46.1] - 2023-02-20
|
||||
### Fixed
|
||||
- Race condition while getting router's peer profile
|
||||
- Creation of new router.info
|
||||
- Displaying LeaseSets in the webconsole
|
||||
- Crash when processing ACK request
|
||||
|
||||
## [2.46.0] - 2023-02-15
|
||||
### Added
|
||||
- Limit number of acked SSU2 packets to 511
|
||||
- Localization to Swedish, Portuguese, Turkish, Polish
|
||||
- Periodically send Datetime block in NTCP2 and SSU2
|
||||
- Don't select random port from reserved
|
||||
- In memory table for peer profiles
|
||||
- Store if router was unreachable in it's peer profile
|
||||
- Show IPv6 addresses in square brackets in webconsole
|
||||
- Check referer when processing Addresshelper
|
||||
### Changed
|
||||
- Algorithm for tunnel creation success rate calculation
|
||||
- Drop incoming NTCP2 and SSU2 connection if published IP doesn't match actual endpoint
|
||||
- Exclude actually unreachable router from netdb for 2 hours
|
||||
- Select first hop from high bandwidth peers for client tunnels
|
||||
- Drop too long or too short LeaseSet
|
||||
- Delete router from netdb if became invalid after update
|
||||
- Terminate existing session if clock skew detected
|
||||
- Close previous UDP socket if open before reopening
|
||||
- Minimal version for floodfill is 0.9.51
|
||||
- Sort transports by endpoints in webconsole
|
||||
### Fixed
|
||||
- Deadlock during processing I2NP block with Garlic in ECIES encrypted message to router
|
||||
- Race condition with encrypted LeaseSets
|
||||
- HTTP query detection
|
||||
- Connection attempts to IPs from invalid ranges
|
||||
- Publish "0.0.0.0" in RouterInfo
|
||||
- Crash upon receiving PeerTest 7
|
||||
- Tunnels for closed SAM session socket
|
||||
- Missing NTCP2 address in RouterInfo if enabled back
|
||||
|
||||
## [2.45.1] - 2023-01-11
|
||||
### Added
|
||||
- Full Cone NAT status error
|
||||
@@ -9,7 +62,7 @@
|
||||
- Set rejection code 30 if tunnel with id already exists
|
||||
- Network status is always OK if peer test msg 5 received
|
||||
### Fixed
|
||||
- UPnP crash if SSU2 or NTCP2 is disabled
|
||||
- UPnP crash if SSU2 or NTCP2 is disabled
|
||||
- Crash on termination for some platforms
|
||||
|
||||
## [2.45.0] - 2023-01-03
|
||||
|
||||
16
Makefile
16
Makefile
@@ -71,13 +71,15 @@ else # not supported
|
||||
$(error Not supported platform)
|
||||
endif
|
||||
|
||||
INCFLAGS += -I$(LIB_SRC_DIR) -I$(LIB_CLIENT_SRC_DIR) -I$(LANG_SRC_DIR)
|
||||
DEFINES += -DOPENSSL_SUPPRESS_DEPRECATED
|
||||
NEEDED_CXXFLAGS += -MMD -MP
|
||||
|
||||
ifeq ($(USE_GIT_VERSION),yes)
|
||||
GIT_VERSION := $(shell git describe --tags)
|
||||
NEEDED_CXXFLAGS += -DGITVER=\"$(GIT_VERSION)\"
|
||||
DEFINES += -DGITVER=$(GIT_VERSION)
|
||||
endif
|
||||
|
||||
NEEDED_CXXFLAGS += -MMD -MP -I$(LIB_SRC_DIR) -I$(LIB_CLIENT_SRC_DIR) -I$(LANG_SRC_DIR) -DOPENSSL_SUPPRESS_DEPRECATED
|
||||
|
||||
LIB_OBJS += $(patsubst %.cpp,obj/%.o,$(LIB_SRC))
|
||||
LIB_CLIENT_OBJS += $(patsubst %.cpp,obj/%.o,$(LIB_CLIENT_SRC))
|
||||
LANG_OBJS += $(patsubst %.cpp,obj/%.o,$(LANG_SRC))
|
||||
@@ -110,17 +112,17 @@ wrapper: api_client $(SHLIB_WRAP) $(ARLIB_WRAP)
|
||||
## custom FLAGS to work at build-time.
|
||||
|
||||
obj/%.o: %.cpp | mk_obj_dir
|
||||
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -c -o $@ $<
|
||||
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(DEFINES) $(INCFLAGS) -c -o $@ $<
|
||||
|
||||
# '-' is 'ignore if missing' on first run
|
||||
-include $(DEPS)
|
||||
|
||||
$(I2PD): $(DAEMON_OBJS) $(ARLIB) $(ARLIB_CLIENT) $(ARLIB_LANG)
|
||||
$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)
|
||||
$(CXX) -o $@ $(DEFINES) $(LDFLAGS) $^ $(LDLIBS)
|
||||
|
||||
$(SHLIB): $(LIB_OBJS) $(SHLIB_LANG)
|
||||
$(SHLIB): $(LIB_OBJS)
|
||||
ifneq ($(USE_STATIC),yes)
|
||||
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) $(SHLIB_LANG)
|
||||
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
|
||||
endif
|
||||
|
||||
$(SHLIB_CLIENT): $(LIB_CLIENT_OBJS) $(SHLIB) $(SHLIB_LANG)
|
||||
|
||||
@@ -6,7 +6,8 @@ CXXFLAGS ?= ${CXX_DEBUG} -Wall -Wextra -Wno-unused-parameter -pedantic -Wno-misl
|
||||
## (e.g. -fstack-protector-strong -Wformat -Werror=format-security), we do not want to remove
|
||||
## -std=c++11. If you want to remove this variable please do so in a way that allows setting
|
||||
## custom FLAGS to work at build-time.
|
||||
NEEDED_CXXFLAGS = -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1
|
||||
NEEDED_CXXFLAGS = -std=c++11
|
||||
DEFINES = -D_GLIBCXX_USE_NANOSLEEP=1
|
||||
INCFLAGS = -I/usr/include/ -I/usr/local/include/
|
||||
LDFLAGS = ${LD_DEBUG} -Wl,-rpath,/usr/local/lib -L/usr/local/lib
|
||||
LDLIBS = -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread
|
||||
|
||||
@@ -33,26 +33,38 @@ endif
|
||||
|
||||
NEEDED_CXXFLAGS += -fPIC
|
||||
|
||||
LDLIBS += -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lssl -lcrypto -lz
|
||||
|
||||
# UPNP Support (miniupnpc 1.5 and higher)
|
||||
ifeq ($(USE_UPNP),yes)
|
||||
LDLIBS += -lminiupnpc
|
||||
NEEDED_CXXFLAGS += -DUSE_UPNP
|
||||
endif
|
||||
|
||||
ifeq ($(USE_STATIC),yes)
|
||||
# NOTE: on glibc you will get this warning:
|
||||
# Using 'getaddrinfo' in statically linked applications requires at runtime
|
||||
# the shared libraries from the glibc version used for linking
|
||||
ifeq ($(USE_STATIC),yes)
|
||||
LDLIBS += -static -ldl -lpthread -static-libgcc -static-libstdc++
|
||||
LIBDIR := /usr/lib/$(SYS)
|
||||
LDLIBS += $(LIBDIR)/libboost_system.a
|
||||
LDLIBS += $(LIBDIR)/libboost_date_time.a
|
||||
LDLIBS += $(LIBDIR)/libboost_filesystem.a
|
||||
LDLIBS += $(LIBDIR)/libboost_program_options.a
|
||||
LDLIBS += $(LIBDIR)/libssl.a
|
||||
LDLIBS += $(LIBDIR)/libcrypto.a
|
||||
LDLIBS += $(LIBDIR)/libz.a
|
||||
ifeq ($(USE_UPNP),yes)
|
||||
LDLIBS += $(LIBDIR)/libminiupnpc.a
|
||||
endif
|
||||
LDLIBS += -lpthread -ldl
|
||||
else
|
||||
LDLIBS += -lpthread
|
||||
LDLIBS += -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread
|
||||
ifeq ($(USE_UPNP),yes)
|
||||
LDLIBS += -lminiupnpc
|
||||
endif
|
||||
endif
|
||||
|
||||
# UPNP Support (miniupnpc 1.5 and higher)
|
||||
ifeq ($(USE_UPNP),yes)
|
||||
DEFINES += -DUSE_UPNP
|
||||
endif
|
||||
|
||||
ifeq ($(USE_AESNI),yes)
|
||||
ifneq (, $(findstring i386, $(SYS))$(findstring i686, $(SYS))$(findstring x86_64, $(SYS))) # only x86-based CPU supports that
|
||||
NEEDED_CXXFLAGS += -D__AES__ -maes
|
||||
NEEDED_CXXFLAGS += -maes
|
||||
DEFINES += -D__AES__
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -4,17 +4,18 @@ USE_WIN32_APP := yes
|
||||
WINDRES = windres
|
||||
|
||||
CXXFLAGS := $(CXX_DEBUG) -fPIC -msse
|
||||
INCFLAGS = -I$(DAEMON_SRC_DIR) -IWin32
|
||||
INCFLAGS := -I$(DAEMON_SRC_DIR) -IWin32
|
||||
LDFLAGS := ${LD_DEBUG} -static
|
||||
|
||||
NEEDED_CXXFLAGS += -std=c++17 -DWIN32_LEAN_AND_MEAN
|
||||
NEEDED_CXXFLAGS += -std=c++17
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
# Boost libraries suffix
|
||||
BOOST_SUFFIX = -mt
|
||||
|
||||
# UPNP Support
|
||||
ifeq ($(USE_UPNP),yes)
|
||||
CXXFLAGS += -DUSE_UPNP -DMINIUPNP_STATICLIB
|
||||
DEFINES += -DUSE_UPNP -DMINIUPNP_STATICLIB
|
||||
LDLIBS = -lminiupnpc
|
||||
endif
|
||||
|
||||
@@ -35,18 +36,19 @@ LDLIBS += \
|
||||
-lpthread
|
||||
|
||||
ifeq ($(USE_WIN32_APP), yes)
|
||||
NEEDED_CXXFLAGS += -DWIN32_APP
|
||||
DEFINES += -DWIN32_APP
|
||||
LDFLAGS += -mwindows
|
||||
DAEMON_RC += Win32/Resource.rc
|
||||
DAEMON_OBJS += $(patsubst %.rc,obj/%.o,$(DAEMON_RC))
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WINXP_FLAGS), yes)
|
||||
NEEDED_CXXFLAGS += -DWINVER=0x0501 -D_WIN32_WINNT=0x0501
|
||||
DEFINES += -DWINVER=0x0501 -D_WIN32_WINNT=0x0501
|
||||
endif
|
||||
|
||||
ifeq ($(USE_AESNI),yes)
|
||||
NEEDED_CXXFLAGS += -D__AES__ -maes
|
||||
NEEDED_CXXFLAGS += -maes
|
||||
DEFINES += -D__AES__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_ASLR),yes)
|
||||
@@ -54,4 +56,4 @@ ifeq ($(USE_ASLR),yes)
|
||||
endif
|
||||
|
||||
obj/%.o : %.rc | mk_obj_dir
|
||||
$(WINDRES) -i $< -o $@
|
||||
$(WINDRES) $(DEFINES) $(INCFLAGS) --preprocessor-arg=-MMD --preprocessor-arg=-MP --preprocessor-arg=-MF$@.d -i $< -o $@
|
||||
|
||||
17
Makefile.osx
17
Makefile.osx
@@ -1,6 +1,7 @@
|
||||
CXX = clang++
|
||||
CXXFLAGS := ${CXX_DEBUG} -Wall -std=c++11 -DMAC_OSX
|
||||
CXXFLAGS := ${CXX_DEBUG} -Wall -std=c++11
|
||||
INCFLAGS = -I/usr/local/include
|
||||
DEFINES := -DMAC_OSX
|
||||
LDFLAGS := -Wl,-rpath,/usr/local/lib -L/usr/local/lib
|
||||
LDFLAGS += -Wl,-dead_strip
|
||||
LDFLAGS += -Wl,-dead_strip_dylibs
|
||||
@@ -14,7 +15,7 @@ endif
|
||||
|
||||
ifeq ($(USE_UPNP),yes)
|
||||
LDFLAGS += -ldl
|
||||
CXXFLAGS += -DUSE_UPNP
|
||||
DEFINES += -DUSE_UPNP
|
||||
ifeq ($(USE_STATIC),yes)
|
||||
LDLIBS += /usr/local/lib/libminiupnpc.a
|
||||
else
|
||||
@@ -22,8 +23,12 @@ ifeq ($(USE_UPNP),yes)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(USE_AESNI),yes)
|
||||
CXXFLAGS += -D__AES__ -maes
|
||||
else
|
||||
CXXFLAGS += -msse
|
||||
OSARCH = $(shell uname -p)
|
||||
|
||||
ifneq ($(OSARCH),powerpc)
|
||||
ifeq ($(USE_AESNI),yes)
|
||||
CXXFLAGS += -D__AES__ -maes
|
||||
else
|
||||
CXXFLAGS += -msse
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace util
|
||||
//setlocale(LC_ALL, "Russian");
|
||||
setlocale(LC_TIME, "C");
|
||||
#ifdef WIN32_APP
|
||||
if (!i2p::win32::StartWin32App ()) return false;
|
||||
if (!i2p::win32::StartWin32App (isDaemon)) return false;
|
||||
#endif
|
||||
bool ret = Daemon_Singleton::start();
|
||||
if (ret && i2p::log::Logger().GetLogType() == eLogFile)
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#include "winres.h"
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
MAINICON ICON "mask.ico"
|
||||
#endif // English (United States) resources
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
#include "Resource.rc2"
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#include "winres.h"
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
MAINICON ICON "mask.ico"
|
||||
#endif // English (United States) resources
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
#include "Resource.rc2"
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
#include "../libi2pd/version.h"
|
||||
#include "version.h"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION I2PD_VERSION_MAJOR,I2PD_VERSION_MINOR,I2PD_VERSION_MICRO,I2PD_VERSION_PATCH
|
||||
@@ -25,7 +25,7 @@ BEGIN
|
||||
VALUE "FileDescription", "C++ I2P daemon"
|
||||
VALUE "FileVersion", I2PD_VERSION
|
||||
VALUE "InternalName", CODENAME
|
||||
VALUE "LegalCopyright", "Copyright (C) 2013-2022, The PurpleI2P Project"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2013-2023, The PurpleI2P Project"
|
||||
VALUE "OriginalFilename", "i2pd"
|
||||
VALUE "ProductName", "Purple I2P"
|
||||
VALUE "ProductVersion", I2P_VERSION
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace i2p
|
||||
namespace win32
|
||||
{
|
||||
DWORD g_GracefulShutdownEndtime = 0;
|
||||
bool g_isWinService;
|
||||
|
||||
static void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem)
|
||||
{
|
||||
@@ -416,8 +417,9 @@ namespace win32
|
||||
return DefWindowProc( hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
bool StartWin32App ()
|
||||
bool StartWin32App (bool isWinService)
|
||||
{
|
||||
g_isWinService = isWinService;
|
||||
if (FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd")))
|
||||
{
|
||||
MessageBox(NULL, TEXT("I2Pd is running already"), TEXT("Warning"), MB_OK);
|
||||
@@ -446,7 +448,9 @@ namespace win32
|
||||
MessageBox(NULL, "Failed to create main window", TEXT("Warning!"), MB_ICONERROR | MB_OK | MB_TOPMOST);
|
||||
return false;
|
||||
}
|
||||
SubscribeToEvents();
|
||||
// COM requires message loop to work, which is not implemented in service mode
|
||||
if (!g_isWinService)
|
||||
SubscribeToEvents();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -466,7 +470,8 @@ namespace win32
|
||||
HWND hWnd = FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd"));
|
||||
if (hWnd)
|
||||
PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_EXIT, 0), 0);
|
||||
// UnSubscribeFromEvents(); // TODO: understand why unsubscribing crashes app
|
||||
else if(!g_isWinService)
|
||||
UnSubscribeFromEvents();
|
||||
UnregisterClass (I2PD_WIN32_CLASSNAME, GetModuleHandle(NULL));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace win32
|
||||
{
|
||||
extern DWORD g_GracefulShutdownEndtime;
|
||||
|
||||
bool StartWin32App ();
|
||||
bool StartWin32App (bool isWinService);
|
||||
void StopWin32App ();
|
||||
int RunWin32App ();
|
||||
bool GracefulShutdown ();
|
||||
|
||||
@@ -15,6 +15,7 @@ IUnknown *pUnknown = nullptr;
|
||||
INetworkListManager *pNetworkListManager = nullptr;
|
||||
IConnectionPointContainer *pCPContainer = nullptr;
|
||||
IConnectionPoint *pConnectPoint = nullptr;
|
||||
CNetworkListManagerEvent *pNetEvent = nullptr;
|
||||
DWORD Cookie = 0;
|
||||
|
||||
void SubscribeToEvents()
|
||||
@@ -29,7 +30,11 @@ void SubscribeToEvents()
|
||||
if (SUCCEEDED(Result))
|
||||
{
|
||||
VARIANT_BOOL IsConnect = VARIANT_FALSE;
|
||||
#if defined(_MSC_VER)
|
||||
Result = pNetworkListManager->get_IsConnectedToInternet(&IsConnect);
|
||||
#else
|
||||
Result = pNetworkListManager->IsConnectedToInternet(&IsConnect);
|
||||
#endif
|
||||
if (SUCCEEDED(Result)) {
|
||||
i2p::transport::transports.SetOnline (true);
|
||||
LogPrint(eLogInfo, "NetState: Current state: ", IsConnect == VARIANT_TRUE ? "connected" : "disconnected");
|
||||
@@ -41,8 +46,8 @@ void SubscribeToEvents()
|
||||
Result = pCPContainer->FindConnectionPoint(IID_INetworkListManagerEvents, &pConnectPoint);
|
||||
if(SUCCEEDED(Result))
|
||||
{
|
||||
CNetworkListManagerEvent *NetEvent = new CNetworkListManagerEvent;
|
||||
Result = pConnectPoint->Advise((IUnknown *)NetEvent, &Cookie);
|
||||
pNetEvent = new CNetworkListManagerEvent;
|
||||
Result = pConnectPoint->Advise((IUnknown *)pNetEvent, &Cookie);
|
||||
if (SUCCEEDED(Result))
|
||||
LogPrint(eLogInfo, "NetState: Successfully subscribed to NetworkListManagerEvent messages");
|
||||
else
|
||||
@@ -59,6 +64,7 @@ void SubscribeToEvents()
|
||||
|
||||
void UnSubscribeFromEvents()
|
||||
{
|
||||
LogPrint(eLogInfo, "NetState: Unsubscribing from NetworkListManagerEvents");
|
||||
try
|
||||
{
|
||||
if (pConnectPoint) {
|
||||
@@ -66,6 +72,9 @@ void UnSubscribeFromEvents()
|
||||
pConnectPoint->Release();
|
||||
}
|
||||
|
||||
if (pNetEvent)
|
||||
pNetEvent->Release();
|
||||
|
||||
if (pCPContainer)
|
||||
pCPContainer->Release();
|
||||
|
||||
|
||||
@@ -19,21 +19,18 @@ class CNetworkListManagerEvent : public INetworkListManagerEvents
|
||||
{
|
||||
public:
|
||||
CNetworkListManagerEvent() : m_ref(1) { }
|
||||
~CNetworkListManagerEvent() { }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject)
|
||||
{
|
||||
HRESULT Result = S_OK;
|
||||
if (IsEqualIID(riid, IID_IUnknown)) {
|
||||
*ppvObject = (IUnknown *)this;
|
||||
} else if (IsEqualIID(riid ,IID_INetworkListManagerEvents)) {
|
||||
*ppvObject = (INetworkListManagerEvents *)this;
|
||||
} else {
|
||||
Result = E_NOINTERFACE;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
AddRef();
|
||||
|
||||
return Result;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef()
|
||||
|
||||
@@ -21,7 +21,7 @@ BOOL I2PService::isService()
|
||||
HWINSTA hWinStation = GetProcessWindowStation();
|
||||
if (hWinStation != NULL)
|
||||
{
|
||||
USEROBJECTFLAGS uof = { 0 };
|
||||
USEROBJECTFLAGS uof = { FALSE, FALSE, 0 };
|
||||
if (GetUserObjectInformation(hWinStation, UOI_FLAGS, &uof, sizeof(USEROBJECTFLAGS), NULL) && ((uof.dwFlags & WSF_VISIBLE) == 0))
|
||||
{
|
||||
bIsService = TRUE;
|
||||
|
||||
14
build/.gitignore
vendored
14
build/.gitignore
vendored
@@ -1,6 +1,13 @@
|
||||
# Various generated files
|
||||
/CMakeFiles/
|
||||
/Testing/
|
||||
/tests/
|
||||
/.ninja_*
|
||||
/arch.c
|
||||
/build.ninja
|
||||
/i2pd
|
||||
/i2pd.exe
|
||||
/i2pd.exe.debug
|
||||
/libi2pd.a
|
||||
/libi2pdclient.a
|
||||
/libi2pdlang.a
|
||||
@@ -8,8 +15,13 @@
|
||||
/CMakeCache.txt
|
||||
/CPackConfig.cmake
|
||||
/CPackSourceConfig.cmake
|
||||
/CTestTestfile.cmake
|
||||
/install_manifest.txt
|
||||
/arch.c
|
||||
/Makefile
|
||||
# windows build script
|
||||
i2pd*.zip
|
||||
build*.log
|
||||
# MVS project files
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
*.sln
|
||||
|
||||
@@ -1,14 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
cmake_policy(VERSION 3.7)
|
||||
project("i2pd")
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.22)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
else()
|
||||
cmake_policy(VERSION 3.22)
|
||||
endif()
|
||||
|
||||
# for debugging
|
||||
#set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
# Win32 build with cmake is not supported
|
||||
if(WIN32 OR MSVC OR MSYS OR MINGW)
|
||||
message(SEND_ERROR "cmake build for windows is not supported. Please use MSYS2 with makefiles in project root.")
|
||||
endif()
|
||||
# paths
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
|
||||
set(CMAKE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
set(LIBI2PD_SRC_DIR ${CMAKE_SOURCE_DIR}/libi2pd)
|
||||
set(LIBI2PD_CLIENT_SRC_DIR ${CMAKE_SOURCE_DIR}/libi2pd_client)
|
||||
set(LANG_SRC_DIR ${CMAKE_SOURCE_DIR}/i18n)
|
||||
set(DAEMON_SRC_DIR ${CMAKE_SOURCE_DIR}/daemon)
|
||||
|
||||
include(Version)
|
||||
set_version("${LIBI2PD_SRC_DIR}/version.h" PROJECT_VERSION)
|
||||
|
||||
project(
|
||||
i2pd
|
||||
VERSION ${PROJECT_VERSION}
|
||||
HOMEPAGE_URL "https://i2pd.website/"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
# configurable options
|
||||
option(WITH_AESNI "Use AES-NI instructions set" ON)
|
||||
@@ -26,27 +44,22 @@ IF(BUILD_TESTING)
|
||||
enable_testing()
|
||||
ENDIF()
|
||||
|
||||
# paths
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
|
||||
set(CMAKE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
# Handle paths nicely
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# architecture
|
||||
# Architecture
|
||||
include(TargetArch)
|
||||
target_architecture(ARCHITECTURE)
|
||||
|
||||
set(LIBI2PD_SRC_DIR ../libi2pd)
|
||||
set(LIBI2PD_CLIENT_SRC_DIR ../libi2pd_client)
|
||||
set(LANG_SRC_DIR ../i18n)
|
||||
set(DAEMON_SRC_DIR ../daemon)
|
||||
include(CheckAtomic)
|
||||
|
||||
if(WITH_STATIC)
|
||||
if(MSVC)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(${LIBI2PD_SRC_DIR})
|
||||
include_directories(${LIBI2PD_CLIENT_SRC_DIR})
|
||||
include_directories(${LANG_SRC_DIR})
|
||||
include_directories(${DAEMON_SRC_DIR})
|
||||
|
||||
FILE(GLOB LIBI2PD_SRC ${LIBI2PD_SRC_DIR}/*.cpp)
|
||||
add_library(libi2pd ${LIBI2PD_SRC})
|
||||
set_target_properties(libi2pd PROPERTIES PREFIX "")
|
||||
@@ -57,11 +70,9 @@ if(WITH_LIBRARY)
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT Libraries)
|
||||
# TODO Make libi2pd available to 3rd party projects via CMake as imported target
|
||||
# FIXME This pulls stdafx
|
||||
# install(EXPORT libi2pd DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
include_directories(${LIBI2PD_CLIENT_SRC_DIR})
|
||||
FILE(GLOB CLIENT_SRC ${LIBI2PD_CLIENT_SRC_DIR}/*.cpp)
|
||||
add_library(libi2pdclient ${CLIENT_SRC})
|
||||
set_target_properties(libi2pdclient PROPERTIES PREFIX "")
|
||||
@@ -74,6 +85,7 @@ if(WITH_LIBRARY)
|
||||
COMPONENT Libraries)
|
||||
endif()
|
||||
|
||||
include_directories(${LANG_SRC_DIR})
|
||||
FILE(GLOB LANG_SRC ${LANG_SRC_DIR}/*.cpp)
|
||||
add_library(libi2pdlang ${LANG_SRC})
|
||||
set_target_properties(libi2pdlang PROPERTIES PREFIX "")
|
||||
@@ -86,6 +98,8 @@ if(WITH_LIBRARY)
|
||||
COMPONENT Libraries)
|
||||
endif()
|
||||
|
||||
include_directories(${DAEMON_SRC_DIR})
|
||||
|
||||
set(DAEMON_SRC
|
||||
"${DAEMON_SRC_DIR}/Daemon.cpp"
|
||||
"${DAEMON_SRC_DIR}/HTTPServer.cpp"
|
||||
@@ -95,6 +109,22 @@ set(DAEMON_SRC
|
||||
"${DAEMON_SRC_DIR}/UPnP.cpp"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(WIN32_SRC_DIR ${CMAKE_SOURCE_DIR}/Win32)
|
||||
include_directories(${WIN32_SRC_DIR})
|
||||
|
||||
list(APPEND DAEMON_SRC
|
||||
"${WIN32_SRC_DIR}/DaemonWin32.cpp"
|
||||
"${WIN32_SRC_DIR}/Win32App.cpp"
|
||||
"${WIN32_SRC_DIR}/Win32Service.cpp"
|
||||
"${WIN32_SRC_DIR}/Win32NetState.cpp"
|
||||
)
|
||||
|
||||
file(GLOB WIN32_RC ${WIN32_SRC_DIR}/*.rc)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_APP -DWIN32_LEAN_AND_MEAN")
|
||||
|
||||
endif()
|
||||
|
||||
if(WITH_UPNP)
|
||||
add_definitions(-DUSE_UPNP)
|
||||
endif()
|
||||
@@ -102,30 +132,40 @@ endif()
|
||||
if(WITH_GIT_VERSION)
|
||||
include(GetGitRevisionDescription)
|
||||
git_describe(GIT_VERSION)
|
||||
add_definitions(-DGITVER="${GIT_VERSION}")
|
||||
add_definitions(-DGITVER=${GIT_VERSION})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
add_definitions(-DMAC_OSX)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Winvalid-pch -Wno-unused-parameter")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pedantic")
|
||||
# TODO: The following is incompatible with static build and enabled hardening for OpenWRT.
|
||||
# Multiple definitions of __stack_chk_fail(libssp & libc)
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -flto -s -ffunction-sections -fdata-sections")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-Wl,--gc-sections") # -flto is added from above
|
||||
|
||||
# check for c++17 & c++11 support
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++17" CXX17_SUPPORTED)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11_SUPPORTED)
|
||||
if(CXX17_SUPPORTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
elseif(CXX11_SUPPORTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
if(MSVC)
|
||||
add_definitions(-DWINVER=0x0600)
|
||||
add_definitions(-D_WIN32_WINNT=0x0600)
|
||||
else()
|
||||
message(SEND_ERROR "C++17 nor C++11 standard not seems to be supported by compiler. Too old version?")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Winvalid-pch -Wno-unused-parameter -Wno-uninitialized")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pedantic")
|
||||
# TODO: The following is incompatible with static build and enabled hardening for OpenWRT.
|
||||
# Multiple definitions of __stack_chk_fail(libssp & libc)
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -flto -s")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -ffunction-sections -fdata-sections")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-Wl,--gc-sections") # -flto is added from above
|
||||
|
||||
# check for c++17 & c++11 support
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++17" CXX17_SUPPORTED)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11_SUPPORTED)
|
||||
|
||||
if(CXX17_SUPPORTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
elseif(CXX11_SUPPORTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
else()
|
||||
message(SEND_ERROR "C++17 nor C++11 standard not seems to be supported by compiler. Too old version?")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -157,6 +197,12 @@ endif()
|
||||
|
||||
# Note: AES-NI and AVX is available on x86-based CPU's.
|
||||
# Here also ARM64 implementation, but currently we don't support it.
|
||||
# MSVC is not supported.
|
||||
if(MSVC)
|
||||
message(STATUS "AES-NI is not supported on MSVC, option was disabled")
|
||||
set(WITH_AESNI OFF)
|
||||
endif()
|
||||
|
||||
if(WITH_AESNI AND (ARCHITECTURE MATCHES "x86_64" OR ARCHITECTURE MATCHES "i386"))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
|
||||
add_definitions(-D__AES__)
|
||||
@@ -178,6 +224,7 @@ endif()
|
||||
|
||||
# Use std::atomic instead of GCC builtins on macOS PowerPC:
|
||||
# For more information refer to: https://github.com/PurpleI2P/i2pd/issues/1726#issuecomment-1306335111
|
||||
# This has been fixed in Boost 1.81, nevertheless we retain the setting for the sake of compatibility.
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
|
||||
add_definitions(-DBOOST_SP_USE_STD_ATOMIC)
|
||||
endif()
|
||||
@@ -187,10 +234,36 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(WITH_STATIC)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
endif()
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_STATIC_RUNTIME ON)
|
||||
if(MSVC)
|
||||
set(Boost_USE_STATIC_RUNTIME ON)
|
||||
else()
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(OPENSSL_MSVC_STATIC_RT ON)
|
||||
endif()
|
||||
set(OPENSSL_USE_STATIC_LIBS ON)
|
||||
|
||||
set(ZLIB_USE_STATIC_LIBS ON)
|
||||
if(MSVC)
|
||||
set(ZLIB_NAMES zlibstatic zlibstat)
|
||||
else()
|
||||
set(ZLIB_NAMES libz zlibstatic zlibstat zlib z)
|
||||
endif()
|
||||
|
||||
if(WITH_UPNP)
|
||||
set(MINIUPNPC_USE_STATIC_LIBS ON)
|
||||
add_definitions(-DMINIUPNP_STATICLIB)
|
||||
endif()
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
if(${CMAKE_CXX_COMPILER} MATCHES ".*-openwrt-.*")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
# set(CMAKE_THREAD_LIBS_INIT "gcc_eh -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
|
||||
@@ -200,11 +273,13 @@ else()
|
||||
# TODO: Consider separate compilation for LIBI2PD_SRC for library.
|
||||
# No need in -fPIC overhead for binary if not interested in library
|
||||
# HINT: revert c266cff CMakeLists.txt: compilation speed up
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
add_definitions(-DBOOST_SYSTEM_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_REGEX_DYN_LINK)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
endif()
|
||||
add_definitions(-DBOOST_ATOMIC_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_REGEX_DYN_LINK)
|
||||
endif()
|
||||
|
||||
find_package(Boost COMPONENTS system filesystem program_options date_time REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS system filesystem program_options date_time OPTIONAL_COMPONENTS atomic)
|
||||
if(NOT DEFINED Boost_INCLUDE_DIRS)
|
||||
message(SEND_ERROR "Boost is not found, or your boost version was below 1.46. Please download Boost!")
|
||||
endif()
|
||||
@@ -235,8 +310,6 @@ endif()
|
||||
# load includes
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
include(CheckAtomic)
|
||||
|
||||
# show summary
|
||||
message(STATUS "---------------------------------------")
|
||||
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
|
||||
@@ -258,10 +331,24 @@ message(STATUS " THREADSANITIZER : ${WITH_THREADSANITIZER}")
|
||||
message(STATUS "---------------------------------------")
|
||||
|
||||
if(WITH_BINARY)
|
||||
add_executable("${PROJECT_NAME}" ${DAEMON_SRC})
|
||||
if(WIN32)
|
||||
add_executable("${PROJECT_NAME}" WIN32 ${DAEMON_SRC} ${WIN32_RC})
|
||||
else()
|
||||
add_executable("${PROJECT_NAME}" ${DAEMON_SRC})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND MINGW_EXTRA "wsock32" "ws2_32" "iphlpapi")
|
||||
# OpenSSL may require Crypt32 library on MSVC build, which is not added by CMake lesser than 3.21
|
||||
if(MSVC AND ${CMAKE_VERSION} VERSION_LESS 3.21)
|
||||
list(APPEND MINGW_EXTRA "crypt32")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_STATIC)
|
||||
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-static")
|
||||
if(NOT MSVC)
|
||||
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-static")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -274,11 +361,18 @@ if(WITH_BINARY)
|
||||
list(REMOVE_AT Boost_LIBRARIES -1)
|
||||
endif()
|
||||
|
||||
# synchronization library is incompatible with Windows 7
|
||||
if(WIN32)
|
||||
get_target_property(BOOSTFSLIBS Boost::filesystem INTERFACE_LINK_LIBRARIES)
|
||||
list(REMOVE_ITEM BOOSTFSLIBS synchronization)
|
||||
set_target_properties(Boost::filesystem PROPERTIES INTERFACE_LINK_LIBRARIES "${BOOSTFSLIBS}")
|
||||
endif()
|
||||
|
||||
if(WITH_STATIC)
|
||||
set(DL_LIB ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
target_link_libraries("${PROJECT_NAME}" libi2pd libi2pdclient libi2pdlang ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto ${MINIUPNPC_LIBRARY} ZLIB::ZLIB Threads::Threads ${DL_LIB} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
target_link_libraries("${PROJECT_NAME}" libi2pd libi2pdclient libi2pdlang ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto ${MINIUPNPC_LIBRARY} ZLIB::ZLIB Threads::Threads ${MINGW_EXTRA} ${DL_LIB} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
|
||||
install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime)
|
||||
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2017-2022, The PurpleI2P Project
|
||||
# Copyright (c) 2017-2023, 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
|
||||
|
||||
@@ -18,7 +18,7 @@ set(archdetect_c_code "
|
||||
|| defined(_M_ARM64) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 8)
|
||||
#error cmake_ARCH arm64
|
||||
#if defined(__ARM_ARCH_7__) \\
|
||||
#elif defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|| defined(__ARM_ARCH_7M__) \\
|
||||
@@ -83,13 +83,13 @@ function(target_architecture output_var)
|
||||
# First let's normalize the order of the values
|
||||
|
||||
# Note that it's not possible to compile PowerPC applications if you are using
|
||||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
||||
# disable it by default
|
||||
# the OS X SDK version 10.7 or later - you'll need 10.4/10.5/10.6 for that, so we
|
||||
# disable it by default. Also, ppc64 is not supported in 10.6.
|
||||
# See this page for more information:
|
||||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
||||
|
||||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise; 10.6 also supports ppc.
|
||||
|
||||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
||||
@@ -133,11 +133,11 @@ function(target_architecture output_var)
|
||||
enable_language(C)
|
||||
|
||||
# Detect the architecture in a rather creative way...
|
||||
# This compiles a small C program which is a series of ifdefs that selects a
|
||||
# particular #error preprocessor directive whose message string contains the
|
||||
# target architecture. The program will always fail to compile (both because
|
||||
# file is not a valid C program, and obviously because of the presence of the
|
||||
# #error preprocessor directives... but by exploiting the preprocessor in this
|
||||
# This compiles a small C program which is a series of ifdefs that selects
|
||||
# a particular #error preprocessor directive whose message string contains
|
||||
# the target architecture. The program will always fail to compile (both because
|
||||
# file is not a valid C program, and obviously because of the presence of
|
||||
# the #error preprocessor directives... but by exploiting the preprocessor in this
|
||||
# way, we can detect the correct target architecture even when cross-compiling,
|
||||
# since the program itself never needs to be run (only the compiler/preprocessor)
|
||||
try_run(
|
||||
|
||||
16
build/cmake_modules/Version.cmake
Normal file
16
build/cmake_modules/Version.cmake
Normal file
@@ -0,0 +1,16 @@
|
||||
# read version
|
||||
|
||||
function(set_version version_file output_var)
|
||||
file(READ "${version_file}" version_data)
|
||||
|
||||
string(REGEX MATCH "I2PD_VERSION_MAJOR ([0-9]*)" _ ${version_data})
|
||||
set(version_major ${CMAKE_MATCH_1})
|
||||
|
||||
string(REGEX MATCH "I2PD_VERSION_MINOR ([0-9]*)" _ ${version_data})
|
||||
set(version_minor ${CMAKE_MATCH_1})
|
||||
|
||||
string(REGEX MATCH "I2PD_VERSION_MICRO ([0-9]*)" _ ${version_data})
|
||||
set(version_micro ${CMAKE_MATCH_1})
|
||||
|
||||
set(${output_var} "${version_major}.${version_minor}.${version_micro}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
34
contrib/certificates/reseed/arnavbhatt288_at_mail.i2p.crt
Normal file
34
contrib/certificates/reseed/arnavbhatt288_at_mail.i2p.crt
Normal file
@@ -0,0 +1,34 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF2TCCA8GgAwIBAgIQIHQPtSoFU+cUpYD8PZaWZjANBgkqhkiG9w0BAQsFADB2
|
||||
MQswCQYDVQQGEwJYWDELMAkGA1UEBxMCWFgxCzAJBgNVBAkTAlhYMR4wHAYDVQQK
|
||||
ExVJMlAgQW5vbnltb3VzIE5ldHdvcmsxDDAKBgNVBAsTA0kyUDEfMB0GA1UEAwwW
|
||||
YXJuYXZiaGF0dDI4OEBtYWlsLmkycDAeFw0yMzAxMjUxODUzNDFaFw0zMzAxMjUx
|
||||
ODUzNDFaMHYxCzAJBgNVBAYTAlhYMQswCQYDVQQHEwJYWDELMAkGA1UECRMCWFgx
|
||||
HjAcBgNVBAoTFUkyUCBBbm9ueW1vdXMgTmV0d29yazEMMAoGA1UECxMDSTJQMR8w
|
||||
HQYDVQQDDBZhcm5hdmJoYXR0Mjg4QG1haWwuaTJwMIICIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAg8AMIICCgKCAgEAtwG73sC0jYd3fgEzZh0SveAdUd5yD35nINJRrdPSrSwY
|
||||
n3i1qGe3fNLj877PvUDU+qiHH0fFZfyFkXTaq3TUp1u4YkmvaoPHy6FZlojB08lK
|
||||
FBm+iJ1hifQ7MFmvIKUGv+cjlN6xSoQ0U6B2QOy6iZnBgFZ/7jbRY4iZOIj7VJtY
|
||||
aodeHfy0bWe447VJovbkUi7NJPFZQS65LMcAIWcWTxrC0Gj8SmdxL3a5+hxpmmg0
|
||||
+KCQvWQDdxAQjsc16sgUCdUc6cWYO4yw9H6fgdq9GJX+LnXR9OB58GsAjjlLlFoI
|
||||
CZxdARDpoqcIj6AoKIanALf8yfbIyrqqJE47cuaqV9bht5MWKnXbwHplEkT4ZNkh
|
||||
PnRDia7B5HY3uwbt39CBm264PEWXvWG2sozTWKQqBjmMN2cj/NFDUEqKv6BggMY1
|
||||
HcqxWFKRcgKCtRvrmTmfp5l0/ou+OtUaFUg0a6Qhtb93Hj10vK6wZzidBqj0ggzB
|
||||
eJDI95b89u8JgzRoOBriuMKTc91WTkOvBLkB3dgUbUpx2p8KHjvf/pppBH9u0oxp
|
||||
qJFFK840DbnJydEvjKezeVe5Ax6YRSRxyEdKzRoWdvKVxb3qBBKMdCKTYEPxHPBu
|
||||
JMEQVUCXJMti++1KEiQGhcfWvLyT7OewbcIZNk9XWNrxlKcGrTp9AOwaaNC5m1kC
|
||||
AwEAAaNjMGEwDgYDVR0PAQH/BAQDAgKEMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggr
|
||||
BgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MB8GA1UdDgQYBBZhcm5hdmJoYXR0Mjg4
|
||||
QG1haWwuaTJwMA0GCSqGSIb3DQEBCwUAA4ICAQAHiK0ld/1PF9DIhutD660/bzBg
|
||||
mF2Z76hcBqDZ8tnQai/u/RXYrH9wso9BYyrVsvk3fr6tpGT49Ian0MVpPOxMoTU2
|
||||
oBEmQlYrfclQLFsOLmA0y2r1ggXzIrt69jB710Vhwdnz09oOE8rS4E2T5oDD8Wvy
|
||||
Kony+AarRceqtkOlzyquc42KjzdrbHsosF7G2iGhNI6t+T3BfWJ+Q+d5sj3OIh6e
|
||||
gSfvHL44E4vZt6dtofRN3MAZ60kNLF5YWyaUo3Snv9Lso1IwIz3AVr5ehv+8sFL/
|
||||
KxaXdkZ5Yn2YUX7p1t4VQd+eXVPYjf1befg4PvrwSkylu3Jpee3fllZSKXeSVx9x
|
||||
jpJiq5vIakqk22pnWb1Vn7xzSW1vtEG7QLjobOr1WrcGiwdv+HKiWcXJXDzKoWXs
|
||||
h3VEfr51Kap8cIJv+D6lJIG9IcIhiQ6CXWBmtjWJvbdVwFBy1/3Fhaou9liHi+gK
|
||||
4Yh5a5OGCzc7xjtpGaTmoLEz7NzDNOdd/r840qRDOh70izzmFZd5Gwq4hoVcPJcS
|
||||
EAySwtgqK0/4d0zDd2Wg9ASJV9DnDf8QuSmHZgZ9Efs47XcWz9TvkWUS1E66AJsN
|
||||
mmI1NDQ3mv3dv5+WPq+dqqYFsnx3xWL1g5Z3buk0opeuXMzoHwM7UfN8h7Q1M5+t
|
||||
+XBgkaYA4iEwYKqlCQ==
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,33 +1,33 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFvjCCA6agAwIBAgIQIDtv8tGMh0FyB2w5XjfZxTANBgkqhkiG9w0BAQsFADBt
|
||||
MIIFvjCCA6agAwIBAgIQBnsUOmOu2oZZIwHBmQc1BDANBgkqhkiG9w0BAQsFADBt
|
||||
MQswCQYDVQQGEwJYWDELMAkGA1UEBxMCWFgxCzAJBgNVBAkTAlhYMR4wHAYDVQQK
|
||||
ExVJMlAgQW5vbnltb3VzIE5ldHdvcmsxDDAKBgNVBAsTA0kyUDEWMBQGA1UEAwwN
|
||||
aWdvckBub3ZnLm5ldDAeFw0xNzA3MjQxODI4NThaFw0yNzA3MjQxODI4NThaMG0x
|
||||
aWdvckBub3ZnLm5ldDAeFw0yMzAxMjgxNDM4MzFaFw0zMzAxMjgxNDM4MzFaMG0x
|
||||
CzAJBgNVBAYTAlhYMQswCQYDVQQHEwJYWDELMAkGA1UECRMCWFgxHjAcBgNVBAoT
|
||||
FUkyUCBBbm9ueW1vdXMgTmV0d29yazEMMAoGA1UECxMDSTJQMRYwFAYDVQQDDA1p
|
||||
Z29yQG5vdmcubmV0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxst4
|
||||
cam3YibBtQHGPCPX13uRQti56U3XZytSZntaKrUFmJxjt41Q/mOy3KYo+lBvhfDF
|
||||
x3tWKjgP9LJOJ28zvddFhZVNxqZRjcnAoPuSOVCw88g01D9OAasKF11hCfdxZP6h
|
||||
vGm8WCnjD8KPcYFxJC4HJUiFeProAwuTzEAESTRk4CAQe3Ie91JspuqoLUc5Qxlm
|
||||
w5QpjnjfZY4kaVHmZDKGIZDgNIt5v85bu4pWwZ6O+o90xQqjxvjyz/xccIec3sHw
|
||||
MHJ8h8ZKMokCKEJTaRWBvdeNXki7nf3gUy/3GjYQlzo0Nxk/Hw4svPcA+eL0AYiy
|
||||
Jn83bIB5VToW2zYUdV4u3qHeAhEg8Y7HI0kKcSUGm9AQXzbzP8YCHxi0sbb0GAJy
|
||||
f1Xf3XzoPfT64giD8ReUHhwKpyMB6uvG/NfWSZAzeAO/NT7DAwXpKIVQdkVdqy8b
|
||||
mvHvjf9/kWKOirA2Nygf3r79Vbg2mqbYC/b63XI9hheU689+O7qyhTEhNz+11X0d
|
||||
Zax7UPrLrwOeB9TNfEnztsmrHNdv2n+KcOO2o11Wvz2nHP9g+dgwoZSD1ZEpFzWP
|
||||
0sD5knKLwAL/64qLlAQ1feqW7hMr80IADcKjLSODkIDIIGm0ksXqEzTjz1JzbRDq
|
||||
jUjq7EAlkw3G69rv1gHxIntllJRQidAqecyWHOMCAwEAAaNaMFgwDgYDVR0PAQH/
|
||||
Z29yQG5vdmcubmV0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvLkf
|
||||
bM3uiYfp9m0vgdoftyXtk2/9bHf3u5iaM0WfoJIsw1iizo/mxJl+Iy7SxLC16nV0
|
||||
v5FpncVv+Z8x9dgoAYVuLq9zKfsAbpj6kuxAqw6vJMlD1TiIL3nSODV9BJLk47X5
|
||||
tmvoOSj9BgvemYThTE3nj+DbuJRW5q90KyBV/LdLrQJX3k5R3FFL5tTad2LKFNZ4
|
||||
vEOcYwwx6mvrkJ2lly6bAQUCtfc648Jyq+NO3Rba1fmn7gcP9zXXc5KYsj/ovyY2
|
||||
OaocSF5wMhzBuPxO+M2HqbYLMAkc6/GesGds8Rm8wofuhJoI5YtqJuLKZm6nQXSc
|
||||
fx6PKgbKcTIUWNFMsxyfghz9hpbg0rkvC7PtfAjtV0yaDtUum1eZeNEx1HbRWN2n
|
||||
TQNCVuv0yaKC41qxqzhEybkdjL9JlgUh7VuskaCelB0lz+kgYjGu8ezOa0ua2iKq
|
||||
4FC/1MbPulxN8NOt4pmbGqqoxmCdShp38wdnOBM3DsAS9f0JaQZd4CDyY4DCSfVn
|
||||
xPdWk31+VXVt3Ixh1EUqZWYTRSsZApkCyYzkiZ/qPGG6FR9Hq2SuhC5o4P44k7eo
|
||||
6wwBWD8a5RjsZhvr05E5yBrKXh/PjLwmtG73QC+ouR54/5xtedvdTwNS94FnNctX
|
||||
FT6QGZnRwCkhPaRe1oQMzP+88pGoCfO33GBAuwUCAwEAAaNaMFgwDgYDVR0PAQH/
|
||||
BAQDAgKEMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8E
|
||||
BTADAQH/MBYGA1UdDgQPBA1pZ29yQG5vdmcubmV0MA0GCSqGSIb3DQEBCwUAA4IC
|
||||
AQADyPaec28qc1HQtAV5dscJr47k92RTfvan+GEgIwyQDHZQm38eyTb05xipQCdk
|
||||
5ruUDFXLB5qXXFJKUbQM6IpaktmWDJqk4Zn+1nGbtFEbKgrF55pd63+NQer5QW9o
|
||||
3+dGj0eZJa3HX5EBkd2r7j2LFuB6uxv3r/xiTeHaaflCnsmyDLfb7axvYhyEzHQS
|
||||
AUi1bR+ln+dXewdtuojqc1+YmVGDgzWZK2T0oOz2E21CpZUDiP3wv9QfMaotLEal
|
||||
zECnbhS++q889inN3GB4kIoN6WpPpeYtTV+/r7FLv9+KUOV1s2z6mxIqC5wBFhZs
|
||||
0Sr1kVo8hB/EW/YYhDp99LoAOjIO6nn1h+qttfzBYr6C16j+8lGK2A12REJ4LiUQ
|
||||
cQI/0zTjt2C8Ns6ueNzMLQN1Mvmlg1Z8wIB7Az7jsIbY2zFJ0M5qR5VJveTj33K4
|
||||
4WSbC/zMWOBYHTVBvGmc6JGhu5ZUTZ+mWP7QfimGu+tdhvtrybFjE9ROIE/4yFr6
|
||||
GkxEyt0UY87TeKXJ/3KygvkMwdvqGWiZhItb807iy99+cySujtbGfF2ZXYGjBXVW
|
||||
dJOVRbyGQkHh6lrWHQM4ntBv4x+5QA+OAan5PBF3tcDx1vefPx+asYslbOXpzII5
|
||||
qhvoQxuRs6j5jsVFG6RdsKNeQAt87Mb2u2zK2ZakMdyD1w==
|
||||
AQCteAb5/bqhHr/i5CJbDzlofprXFC826c19GxQ/9Hw0kA52l0J9Q8Vz8Vy7VQyP
|
||||
QNa8MCv6FeNy8a/wXp6cafyFsBtvehVQO8lFlpCgMEl2Bma43+GaCwkrM6bFNXeW
|
||||
iQ9h4e1KjsUZ8cQDNEcamiJ80+xbMhBrj5bAZwKmZs8MoGEMyXKEZmcmwA+/fy1c
|
||||
cx4izsOsmRXmEHXsvB9ydJHZZeKW8+r0DAtgPslwXuXHG6MuBQo7dKCqn+iMxHXV
|
||||
Jxriq3yvNffdGx4maSLJrjQ1ealt/UMzql7huVSItnVFWoYf7GAELXNJ/PmqVyaK
|
||||
q11LQ8W/Aud6s/bblaJrFJnK8PbPpaw4RvHoWVLYaZYmQnV2msWs5EuESBlEADbv
|
||||
UklQXLMc2f9HKWPA5678nvYPrmu8IL5pMkAxgGRqmd+7vCz4lU9M5z3HObU+WRBt
|
||||
qEMYyXywV8o3tbmnlDS5S5Xxf+tLZn1cxz3ZrmcHPHDbLBNdvszF3CTJH/R2sQvD
|
||||
bizvYJM+p5F+GWM5mt6w0HrOut5MRlpOws/NRrkbijuVA/A45nzTtKplIFYE3qe8
|
||||
q5SAbwYLc8cJcZCN3PxtWwbEv81V33abMt5QcjnWGLH5t2+1Z2KLCgKLSCQTxM8s
|
||||
zBPHtUe8qtSQaElnNLILYbtJ1w67dPnGYTphHihC+CXjBg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
`xgettext` command for extracting translation
|
||||
---
|
||||
|
||||
```
|
||||
xgettext --omit-header -ctr: -ktr -ktr:1,2 daemon/HTTPServer.cpp libi2pd_client/HTTPProxy.cpp
|
||||
```
|
||||
|
||||
Regex for transforming gettext translations to our format:
|
||||
---
|
||||
|
||||
```
|
||||
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", "$5", "$7", "$9", "$11"}},\n
|
||||
```
|
||||
|
||||
```
|
||||
in: msgid\ \"(.*)\"\nmsgstr\ \"(.*)\"\n
|
||||
out: {"$1", "$2"},\n
|
||||
```
|
||||
|
||||
```
|
||||
in: ^#[:.](.*)$\n
|
||||
out: <to empty line>
|
||||
```
|
||||
|
||||
```
|
||||
in: \n\n
|
||||
out: \n
|
||||
```
|
||||
`xgettext` command for extracting translation
|
||||
---
|
||||
|
||||
```
|
||||
xgettext --omit-header -ctr: -ktr -ktr:1,2 daemon/HTTPServer.cpp libi2pd_client/HTTPProxy.cpp
|
||||
```
|
||||
|
||||
Regex for transforming gettext translations to our format:
|
||||
---
|
||||
|
||||
```
|
||||
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", "$5", "$7", "$9", "$11"}},\n
|
||||
```
|
||||
|
||||
```
|
||||
in: msgid\ \"(.*)\"\nmsgstr\ \"(.*)\"\n
|
||||
out: {"$1", "$2"},\n
|
||||
```
|
||||
|
||||
```
|
||||
in: ^#[:.,](.*)$\n
|
||||
out: <to empty line>
|
||||
```
|
||||
|
||||
```
|
||||
in: \n\n
|
||||
out: \n
|
||||
```
|
||||
|
||||
@@ -129,7 +129,8 @@ port = 7070
|
||||
# pass = changeme
|
||||
## Select webconsole language
|
||||
## Currently supported english (default), afrikaans, armenian, chinese, czech, french,
|
||||
## german, italian, russian, spanish, turkmen, ukrainian and uzbek languages
|
||||
## german, italian, polish, portuguese, russian, spanish, turkish, turkmen, ukrainian
|
||||
## and uzbek languages
|
||||
# lang = english
|
||||
|
||||
[httpproxy]
|
||||
@@ -167,9 +168,10 @@ port = 4447
|
||||
[sam]
|
||||
## Comment or set to 'false' to disable SAM Bridge
|
||||
enabled = true
|
||||
## Address and port service will listen on
|
||||
## Address and ports service will listen on
|
||||
# address = 127.0.0.1
|
||||
# port = 7656
|
||||
# portudp = 7655
|
||||
|
||||
[bob]
|
||||
## Uncomment and set to 'true' to enable BOB command channel
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%define git_hash %(git rev-parse HEAD | cut -c -7)
|
||||
|
||||
Name: i2pd-git
|
||||
Version: 2.45.1
|
||||
Version: 2.47.0
|
||||
Release: git%{git_hash}%{?dist}
|
||||
Summary: I2P router written in C++
|
||||
Conflicts: i2pd
|
||||
@@ -158,6 +158,15 @@ getent passwd i2pd >/dev/null || \
|
||||
|
||||
|
||||
%changelog
|
||||
* Sat Mar 11 2023 orignal <orignal@i2pmail.org> - 2.47.0
|
||||
- update to 2.47.0
|
||||
|
||||
* Mon Feb 20 2023 r4sas <r4sas@i2pmail.org> - 2.46.1
|
||||
- update to 2.46.1
|
||||
|
||||
* Wed Feb 15 2023 orignal <orignal@i2pmail.org> - 2.46.0
|
||||
- update to 2.46.0
|
||||
|
||||
* Wed Jan 11 2023 orignal <orignal@i2pmail.org> - 2.45.1
|
||||
- update to 2.45.1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: i2pd
|
||||
Version: 2.45.1
|
||||
Version: 2.47.0
|
||||
Release: 1%{?dist}
|
||||
Summary: I2P router written in C++
|
||||
Conflicts: i2pd-git
|
||||
@@ -155,6 +155,15 @@ getent passwd i2pd >/dev/null || \
|
||||
|
||||
|
||||
%changelog
|
||||
* Sat Mar 11 2023 orignal <orignal@i2pmail.org> - 2.47.0
|
||||
- update to 2.47.0
|
||||
|
||||
* Mon Feb 20 2023 r4sas <r4sas@i2pmail.org> - 2.46.1
|
||||
- update to 2.46.1
|
||||
|
||||
* Wed Feb 15 2023 orignal <orignal@i2pmail.org> - 2.46.0
|
||||
- update to 2.46.0
|
||||
|
||||
* Wed Jan 11 2023 orignal <orignal@i2pmail.org> - 2.45.1
|
||||
- update to 2.45.1
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace util
|
||||
uint16_t transitTunnels; i2p::config::GetOption("limits.transittunnels", transitTunnels);
|
||||
if (isFloodfill && i2p::config::IsDefault ("limits.transittunnels"))
|
||||
transitTunnels *= 2; // double default number of transit tunnels for floodfill
|
||||
SetMaxNumTransitTunnels (transitTunnels);
|
||||
i2p::tunnel::tunnels.SetMaxNumTransitTunnels (transitTunnels);
|
||||
|
||||
/* this section also honors 'floodfill' flag, if set above */
|
||||
std::string bandwidth; i2p::config::GetOption("bandwidth", bandwidth);
|
||||
@@ -269,7 +269,7 @@ namespace util
|
||||
if (hidden)
|
||||
{
|
||||
LogPrint(eLogInfo, "Daemon: Hidden mode enabled");
|
||||
i2p::data::netdb.SetHidden(true);
|
||||
i2p::context.SetHidden(true);
|
||||
}
|
||||
|
||||
std::string httpLang; i2p::config::GetOption("http.lang", httpLang);
|
||||
@@ -334,10 +334,12 @@ namespace util
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LogPrint(eLogInfo, "Daemon: Starting Tunnels");
|
||||
i2p::tunnel::tunnels.Start();
|
||||
|
||||
LogPrint(eLogInfo, "Daemon: Starting Router context");
|
||||
i2p::context.Start();
|
||||
|
||||
LogPrint(eLogInfo, "Daemon: Starting Client");
|
||||
i2p::client::context.Start ();
|
||||
|
||||
@@ -366,6 +368,8 @@ namespace util
|
||||
LogPrint(eLogInfo, "Daemon: Shutting down");
|
||||
LogPrint(eLogInfo, "Daemon: Stopping Client");
|
||||
i2p::client::context.Stop();
|
||||
LogPrint(eLogInfo, "Daemon: Stopping Router context");
|
||||
i2p::context.Stop();
|
||||
LogPrint(eLogInfo, "Daemon: Stopping Tunnels");
|
||||
i2p::tunnel::tunnels.Stop();
|
||||
|
||||
|
||||
@@ -289,6 +289,11 @@ namespace http {
|
||||
if (family.length () > 0)
|
||||
s << "<b>"<< tr("Family") << ":</b> " << family << "<br>\r\n";
|
||||
s << "<b>" << tr("Tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
|
||||
bool isTotalTCSR;
|
||||
i2p::config::GetOption("http.showTotalTCSR", isTotalTCSR);
|
||||
if (isTotalTCSR) {
|
||||
s << "<b>" << tr("Total tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTotalTunnelCreationSuccessRate() << "%<br/>\r\n";
|
||||
}
|
||||
s << "<b>" << tr("Received") << ":</b> ";
|
||||
ShowTraffic (s, i2p::transport::transports.GetTotalReceivedBytes ());
|
||||
s << " (" << tr(/* tr: Kibibyte/s */ "%.2f KiB/s", (double) i2p::transport::transports.GetInBandwidth15s () / 1024) << ")<br>\r\n";
|
||||
@@ -329,14 +334,15 @@ namespace http {
|
||||
default:
|
||||
s << tr("Unknown");
|
||||
}
|
||||
if (address->IsV6 ())
|
||||
bool v6 = address->IsV6 ();
|
||||
if (v6)
|
||||
{
|
||||
if (address->IsV4 ()) s << "v4";
|
||||
s << "v6";
|
||||
}
|
||||
s << "</td>\r\n";
|
||||
if (address->published)
|
||||
s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n";
|
||||
s << "<td>" << (v6 ? "[" : "") << address->host.to_string() << (v6 ? "]:" : ":") << address->port << "</td>\r\n";
|
||||
else
|
||||
{
|
||||
s << "<td>" << tr(/* tr: Shown when router doesn't publish itself and have "Firewalled" state */ "supported");
|
||||
@@ -548,7 +554,7 @@ namespace http {
|
||||
<< tr("Streams")
|
||||
<< "</caption>\r\n<thead>\r\n<tr>"
|
||||
<< "<th style=\"width:25px;\">StreamID</th>"
|
||||
<< "<th style=\"width:5px;\" \\>" // Stream closing button column
|
||||
<< "<th style=\"width:5px;\"> </th>" // Stream closing button column
|
||||
<< "<th class=\"streamdest\">Destination</th>"
|
||||
<< "<th>Sent</th>"
|
||||
<< "<th>Received</th>"
|
||||
@@ -619,7 +625,10 @@ namespace http {
|
||||
if (storeType == i2p::data::NETDB_STORE_TYPE_LEASESET)
|
||||
ls.reset (new i2p::data::LeaseSet (leaseSet->GetBuffer(), leaseSet->GetBufferLen()));
|
||||
else
|
||||
ls.reset (new i2p::data::LeaseSet2 (storeType, leaseSet->GetBuffer(), leaseSet->GetBufferLen()));
|
||||
{
|
||||
ls.reset (new i2p::data::LeaseSet2 (storeType));
|
||||
ls->Update (leaseSet->GetBuffer(), leaseSet->GetBufferLen(), false);
|
||||
}
|
||||
if (!ls) return;
|
||||
s << "<div class=\"leaseset listitem";
|
||||
if (ls->IsExpired())
|
||||
@@ -745,7 +754,7 @@ namespace http {
|
||||
s << " <a class=\"button" << (loglevel == eLogInfo ? " selected" : "") << "\" href=\"" << webroot << "?cmd=" << HTTP_COMMAND_LOGLEVEL << "&level=info&token=" << token << "\"> info </a> \r\n";
|
||||
s << " <a class=\"button" << (loglevel == eLogDebug ? " selected" : "") << "\" href=\"" << webroot << "?cmd=" << HTTP_COMMAND_LOGLEVEL << "&level=debug&token=" << token << "\"> debug </a><br>\r\n<br>\r\n";
|
||||
|
||||
uint16_t maxTunnels = GetMaxNumTransitTunnels ();
|
||||
uint16_t maxTunnels = i2p::tunnel::tunnels.GetMaxNumTransitTunnels ();
|
||||
s << "<b>" << tr("Transit tunnels limit") << "</b><br>\r\n";
|
||||
s << "<form method=\"get\" action=\"" << webroot << "\">\r\n";
|
||||
s << " <input type=\"hidden\" name=\"cmd\" value=\"" << HTTP_COMMAND_LIMITTRANSIT << "\">\r\n";
|
||||
@@ -804,37 +813,46 @@ namespace http {
|
||||
template<typename Sessions>
|
||||
static void ShowTransportSessions (std::stringstream& s, const Sessions& sessions, const std::string name)
|
||||
{
|
||||
std::stringstream tmp_s, tmp_s6; uint16_t cnt = 0, cnt6 = 0;
|
||||
for (const auto& it: sessions )
|
||||
auto comp = [](typename Sessions::mapped_type a, typename Sessions::mapped_type b)
|
||||
{ return a->GetRemoteEndpoint() < b->GetRemoteEndpoint(); };
|
||||
std::set<typename Sessions::mapped_type, decltype(comp)> sortedSessions(comp);
|
||||
for (const auto& it : sessions)
|
||||
{
|
||||
auto endpoint = it.second->GetRemoteEndpoint ();
|
||||
if (it.second && it.second->IsEstablished () && endpoint.address ().is_v4 ())
|
||||
auto ret = sortedSessions.insert(it.second);
|
||||
if (!ret.second)
|
||||
LogPrint(eLogError, "HTTPServer: Duplicate remote endpoint detected: ", (*ret.first)->GetRemoteEndpoint());
|
||||
}
|
||||
std::stringstream tmp_s, tmp_s6; uint16_t cnt = 0, cnt6 = 0;
|
||||
for (const auto& it: sortedSessions)
|
||||
{
|
||||
auto endpoint = it->GetRemoteEndpoint ();
|
||||
if (it && it->IsEstablished () && endpoint.address ().is_v4 ())
|
||||
{
|
||||
tmp_s << "<div class=\"listitem\">\r\n";
|
||||
if (it.second->IsOutgoing ()) tmp_s << " ⇒ ";
|
||||
tmp_s << i2p::data::GetIdentHashAbbreviation (it.second->GetRemoteIdentity ()->GetIdentHash ()) << ": "
|
||||
if (it->IsOutgoing ()) tmp_s << " ⇒ ";
|
||||
tmp_s << i2p::data::GetIdentHashAbbreviation (it->GetRemoteIdentity ()->GetIdentHash ()) << ": "
|
||||
<< endpoint.address ().to_string () << ":" << endpoint.port ();
|
||||
if (!it.second->IsOutgoing ()) tmp_s << " ⇒ ";
|
||||
tmp_s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
|
||||
if (it.second->GetRelayTag ())
|
||||
tmp_s << " [itag:" << it.second->GetRelayTag () << "]";
|
||||
if (it.second->GetSendQueueSize () > 0)
|
||||
tmp_s << " [queue:" << it.second->GetSendQueueSize () << "]";
|
||||
if (!it->IsOutgoing ()) tmp_s << " ⇒ ";
|
||||
tmp_s << " [" << it->GetNumSentBytes () << ":" << it->GetNumReceivedBytes () << "]";
|
||||
if (it->GetRelayTag ())
|
||||
tmp_s << " [itag:" << it->GetRelayTag () << "]";
|
||||
if (it->GetSendQueueSize () > 0)
|
||||
tmp_s << " [queue:" << it->GetSendQueueSize () << "]";
|
||||
tmp_s << "</div>\r\n" << std::endl;
|
||||
cnt++;
|
||||
}
|
||||
if (it.second && it.second->IsEstablished () && endpoint.address ().is_v6 ())
|
||||
if (it && it->IsEstablished () && endpoint.address ().is_v6 ())
|
||||
{
|
||||
tmp_s6 << "<div class=\"listitem\">\r\n";
|
||||
if (it.second->IsOutgoing ()) tmp_s6 << " ⇒ ";
|
||||
tmp_s6 << i2p::data::GetIdentHashAbbreviation (it.second->GetRemoteIdentity ()->GetIdentHash ()) << ": "
|
||||
if (it->IsOutgoing ()) tmp_s6 << " ⇒ ";
|
||||
tmp_s6 << i2p::data::GetIdentHashAbbreviation (it->GetRemoteIdentity ()->GetIdentHash ()) << ": "
|
||||
<< "[" << endpoint.address ().to_string () << "]:" << endpoint.port ();
|
||||
if (!it.second->IsOutgoing ()) tmp_s6 << " ⇒ ";
|
||||
tmp_s6 << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
|
||||
if (it.second->GetRelayTag ())
|
||||
tmp_s6 << " [itag:" << it.second->GetRelayTag () << "]";
|
||||
if (it.second->GetSendQueueSize () > 0)
|
||||
tmp_s6 << " [queue:" << it.second->GetSendQueueSize () << "]";
|
||||
if (!it->IsOutgoing ()) tmp_s6 << " ⇒ ";
|
||||
tmp_s6 << " [" << it->GetNumSentBytes () << ":" << it->GetNumReceivedBytes () << "]";
|
||||
if (it->GetRelayTag ())
|
||||
tmp_s6 << " [itag:" << it->GetRelayTag () << "]";
|
||||
if (it->GetSendQueueSize () > 0)
|
||||
tmp_s6 << " [queue:" << it->GetSendQueueSize () << "]";
|
||||
tmp_s6 << "</div>\r\n" << std::endl;
|
||||
cnt6++;
|
||||
}
|
||||
@@ -1296,7 +1314,7 @@ namespace http {
|
||||
{
|
||||
uint32_t limit = std::stoul(params["limit"], nullptr);
|
||||
if (limit > 0 && limit <= TRANSIT_TUNNELS_LIMIT)
|
||||
SetMaxNumTransitTunnels (limit);
|
||||
i2p::tunnel::tunnels.SetMaxNumTransitTunnels (limit);
|
||||
else {
|
||||
s << "<b>" << tr("ERROR") << "</b>: " << tr("Transit tunnels count must not exceed %d", TRANSIT_TUNNELS_LIMIT) << "\r\n<br>\r\n<br>\r\n";
|
||||
s << "<a href=\"" << webroot << "?page=commands\">" << tr("Back to commands list") << "</a>\r\n<br>\r\n";
|
||||
|
||||
26
debian/changelog
vendored
26
debian/changelog
vendored
@@ -1,8 +1,32 @@
|
||||
i2pd (2.47.0-1) unstable; urgency=high
|
||||
|
||||
* updated to version 2.47.0/0.9.58
|
||||
|
||||
-- orignal <orignal@i2pmail.org> Sat, 11 Mar 2023 16:00:00 +0000
|
||||
|
||||
i2pd (2.46.1-2) unstable; urgency=critical
|
||||
|
||||
* re-pushed release due to new critical bug
|
||||
|
||||
-- r4sas <r4sas@i2pmail.org> Mon, 20 Feb 2023 23:40:00 +0000
|
||||
|
||||
i2pd (2.46.1-1) unstable; urgency=high
|
||||
|
||||
* updated to version 2.46.1/0.9.57
|
||||
|
||||
-- r4sas <r4sas@i2pmail.org> Mon, 20 Feb 2023 02:45:00 +0000
|
||||
|
||||
i2pd (2.46.0-1) unstable; urgency=high
|
||||
|
||||
* updated to version 2.46.0/0.9.57
|
||||
|
||||
-- orignal <orignal@i2pmail.org> Wed, 15 Feb 2023 19:00:00 +0000
|
||||
|
||||
i2pd (2.45.1-1) unstable; urgency=medium
|
||||
|
||||
* updated to version 2.45.1/0.9.57
|
||||
|
||||
-- orignal <orignal@i2pmail.org> Wed, 11 Jan 2023 19:00:00 +0000
|
||||
-- orignal <orignal@i2pmail.org> Wed, 11 Jan 2023 19:00:00 +0000
|
||||
|
||||
i2pd (2.45.0-1) unstable; urgency=high
|
||||
|
||||
|
||||
2
debian/conffiles
vendored
2
debian/conffiles
vendored
@@ -1,2 +0,0 @@
|
||||
/etc/i2pd/i2pd.conf
|
||||
/etc/i2pd/tunnels.conf
|
||||
2
debian/rules
vendored
2
debian/rules
vendored
@@ -8,6 +8,6 @@ export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic
|
||||
export DEB_LDFLAGS_MAINT_APPEND =
|
||||
|
||||
%:
|
||||
dh $@ --parallel
|
||||
dh $@
|
||||
|
||||
override_dh_auto_install:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, The PurpleI2P Project
|
||||
* Copyright (c) 2021-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -40,6 +40,7 @@ namespace armenian // language namespace
|
||||
{"established", "կարգավոյված է"},
|
||||
{"unknown", "անհայտ"},
|
||||
{"exploratory", "հետազոտոկան"},
|
||||
{"Purple I2P Webconsole", "Վեբ-կոնսոլ Purple I2P"},
|
||||
{"<b>i2pd</b> webconsole", "Վեբ-կոնսոլ <b>i2pd</b>"},
|
||||
{"Main page", "Գլխավոր էջ"},
|
||||
{"Router commands", "Երթուղիչի հրահանգներ"},
|
||||
@@ -57,10 +58,10 @@ namespace armenian // language namespace
|
||||
{"Unknown", "Անհայտ"},
|
||||
{"Proxy", "Պրոկսի"},
|
||||
{"Mesh", "MESH-ցանց"},
|
||||
{"Error", "Սխալ"},
|
||||
{"Clock skew", "Ոչ ճշգրիտ ժամանակ"},
|
||||
{"Offline", "Օֆլայն"},
|
||||
{"Symmetric NAT", "Սիմետրիկ NAT"},
|
||||
{"Full cone NAT", "Full cone NAT"},
|
||||
{"Uptime", "Առկայություն"},
|
||||
{"Network status", "Ցանցի կարգավիճակ"},
|
||||
{"Network status v6", "Ցանցի կարգավիճակ v6"},
|
||||
@@ -89,7 +90,7 @@ namespace armenian // language namespace
|
||||
{"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> արդյունքի տողը կարող է օգտագործվել միայն 2LD տիրույթներ գրանցելու համար (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> արդյունքի տողը կարող է օգտագործվել միայն 2LD տիրույթներ գրանցելու համար (example.i2p): Ենթատիրույթներ գրանցելու համար խնդրում ենք օգտագործել i2pd-tools գործիքակազմը:"},
|
||||
{"Address", "Հասցե"},
|
||||
{"Type", "Տեսակը"},
|
||||
{"EncType", "Գաղտնագրի տեսակը"},
|
||||
@@ -112,11 +113,10 @@ namespace armenian // language namespace
|
||||
{"Invalid", "Անվավեր"},
|
||||
{"Store type", "Պահեստավորման տեսակը"},
|
||||
{"Expires", "Սպառվում է"},
|
||||
{"Non Expired Leases", "Չսպառված Lease-եր"},
|
||||
{"Non Expired Leases", "Չսպառված Lease-եր"},
|
||||
{"Gateway", "Դարպաս"},
|
||||
{"TunnelID", "Թունելի ID"},
|
||||
{"EndDate", "Ավարտ"},
|
||||
{"not floodfill", "ոչ floodfill-ներ"},
|
||||
{"Queue size", "Հերթի չափսը"},
|
||||
{"Run peer test", "Գործարկել փորձարկումը"},
|
||||
{"Decline transit tunnels", "Մերժել տարանցիկ թունելներ"},
|
||||
@@ -146,10 +146,7 @@ namespace armenian // language namespace
|
||||
{"Destination not found", "Հասցեի վայրը չի գտնվել"},
|
||||
{"StreamID can't be null", "StreamID-ն չի կարող լինել դատարկ"},
|
||||
{"Return to destination page", "Վերադառնալ նախորդ էջի հասցե"},
|
||||
{"You will be redirected in 5 seconds", "Դուք կտեղափոխվեք 5 վայրկյանից"},
|
||||
{"Transit tunnels count must not exceed 65535", "Տարանցիկ թունելների քանակը չպետք է գերազանցի 65535-ը"},
|
||||
{"Back to commands list", "Վերադառնալ հրահանգների ցուցակ"},
|
||||
{"Register at reg.i2p", "Գրանցել reg.i2p-ում"},
|
||||
{"Description", "Նկարագրություն"},
|
||||
{"A bit information about service on domain", "Մի փոքր տեղեկատվություն տիրոիյթում գտնվող ծառայության մասին"},
|
||||
{"Submit", "Ուղարկվել"},
|
||||
@@ -165,34 +162,26 @@ namespace armenian // language namespace
|
||||
{"You may try to find this host on jump services below", "Ստորև Դուք կարող եք գտնել այս հոսթը jump ծառայությունների միջոցով"},
|
||||
{"Invalid request", "Սխալ հարցում"},
|
||||
{"Proxy unable to parse your request", "Պրոկսին չի կարող հասկանալ Ձեր հարցումը"},
|
||||
{"addresshelper is not supported", "addresshelper-ը համատեղելի չէ"},
|
||||
{"Host", "Հոսթ"},
|
||||
{"added to router's addressbook from helper", "Ավելացված է երթուղիչի հասցեագրքում helper-ի միջոցով"},
|
||||
{"Click here to proceed:", "Շարունակելու համար սեղմեք այստեղ"},
|
||||
{"Continue", "Շարունակել"},
|
||||
{"Addresshelper found", "addresshelper-ը գնտված է"},
|
||||
{"already in router's addressbook", "արդեն առկա է երթուղիչի հասցեագրքում"},
|
||||
{"Click here to update record:", "Սեղմեկ այստեղ որպեսզի թարվացնեք գրառումը"},
|
||||
{"invalid request uri", "Սխալ ձևավորված URI հարցում"},
|
||||
{"Invalid request URI", "Սխալ ձևավորված URI հարցում"},
|
||||
{"Can't detect destination host from request", "Չհաջողվեց հայնտաբերեկ վայրի հասցեն նշված հարցմամբ"},
|
||||
{"Outproxy failure", "Սխալ արտաքին պրոքսի"},
|
||||
{"bad outproxy settings", "Սխալ արտաքին պրոկսի կարգավորումներ"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "Հարցումը I2P ցանցից դուրս է, բայց արտաքին պրոքսին միացված չէ"},
|
||||
{"unknown outproxy url", "արտաքին պրոքսիի անհայտ URL"},
|
||||
{"cannot resolve upstream proxy", "Չհաջողվեց որոշել վերադաս պրոկսին"},
|
||||
{"hostname too long", "Հոսթի անունը չափազանց երկար է"},
|
||||
{"cannot connect to upstream socks proxy", "չհաջողվեց միանալ վերադաս socks պրոկսիին"},
|
||||
{"Cannot negotiate with socks proxy", "Չհաջողվեց պայմանավորվել վերադաս socks պրոկսիի հետ"},
|
||||
{"Bad outproxy settings", "Սխալ արտաքին պրոկսի կարգավորումներ"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Հոսթ %s Հարցումը I2P ցանցից դուրս է, բայց արտաքին պրոքսին միացված չէ"},
|
||||
{"Unknown outproxy URL", "Արտաքին պրոքսիի անհայտ URL"},
|
||||
{"Cannot resolve upstream proxy", "Չհաջողվեց որոշել վերադաս պրոկսին"},
|
||||
{"Hostname is too long", "Հոսթի անունը չափազանց երկար է"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Չհաջողվեց միանալ վերադաս SOCKS պրոկսի սերվերին"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Չհաջողվեց պայմանավորվել վերադաս SOCKS պրոկսիի հետ"},
|
||||
{"CONNECT error", "Սխալ CONNECT հարցում"},
|
||||
{"Failed to Connect", "Միանալ չhաջողվեց"},
|
||||
{"socks proxy error", "Սխալ SOCKS պրոկսի"},
|
||||
{"failed to send request to upstream", "Չհաջողվեց հարցումն ուղարկել վերադաս պրոկսիին"},
|
||||
{"No Reply From socks proxy", "Բացակայում է պատասխանը SOCKS պրոկսի սերվերի կողմից"},
|
||||
{"cannot connect", "Հնարավոր չե միանալ"},
|
||||
{"http out proxy not implemented", "Արտաքին http պրոկսին դեռ իրականացված չէ"},
|
||||
{"cannot connect to upstream http proxy", "Չհաջողվեց միանալ վերադաս http պրոկսի սերվերին"},
|
||||
{"Failed to connect", "Միանալ չhաջողվեց"},
|
||||
{"SOCKS proxy error", "Սխալ SOCKS պրոկսի"},
|
||||
{"Failed to send request to upstream", "Չհաջողվեց հարցումն ուղարկել վերադաս պրոկսիին"},
|
||||
{"No reply from SOCKS proxy", "Բացակայում է պատասխանը SOCKS պրոկսի սերվերի կողմից"},
|
||||
{"Cannot connect", "Հնարավոր չե միանալ"},
|
||||
{"HTTP out proxy not implemented", "Արտաքին HTTP պրոկսին դեռ իրականացված չէ"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Չհաջողվեց միանալ վերադաս HTTP պրոկսի սերվերին"},
|
||||
{"Host is down", "Հոսթն անհասանելի է"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Հոսթի հետ կապը հաստատել չհաջողվեց, հնարավոր է այն անջատված է, փորձեք միանալ քիչ ուշ"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Հոսթի հետ կապը հաստատել չհաջողվեց, հնարավոր է այն անջատված է, փորձեք միանալ քիչ ուշ:"},
|
||||
{"", ""},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, The PurpleI2P Project
|
||||
* Copyright (c) 2022-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "I18N.h"
|
||||
|
||||
// Simplified Chinese localization file
|
||||
// This is an example translation file without strings in it.
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
@@ -46,7 +45,7 @@ namespace chinese // language namespace
|
||||
{"Main page", "主页"},
|
||||
{"Router commands", "路由命令"},
|
||||
{"Local Destinations", "本地目标"},
|
||||
{"LeaseSets", "租契集"},
|
||||
{"LeaseSets", "租约集"},
|
||||
{"Tunnels", "隧道"},
|
||||
{"Transit Tunnels", "中转隧道"},
|
||||
{"Transports", "传输"},
|
||||
@@ -58,11 +57,12 @@ namespace chinese // language namespace
|
||||
{"Firewalled", "受到防火墙限制"},
|
||||
{"Unknown", "未知"},
|
||||
{"Proxy", "代理"},
|
||||
{"Mesh", "Mesh组网"},
|
||||
{"Error", "错误"},
|
||||
{"Mesh", "自组网"},
|
||||
{"Clock skew", "时钟偏移"},
|
||||
{"Offline", "离线"},
|
||||
{"Symmetric NAT", "对称 NAT"},
|
||||
{"Full cone NAT", "全锥型NAT"},
|
||||
{"No Descriptors", "无描述符"},
|
||||
{"Uptime", "运行时间"},
|
||||
{"Network status", "IPv4 网络状态"},
|
||||
{"Network status v6", "IPv6 网络状态"},
|
||||
@@ -91,12 +91,12 @@ namespace chinese // language namespace
|
||||
{"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", "加密类型"},
|
||||
{"Inbound tunnels", "入站隧道"},
|
||||
{"%dms", "%d毫秒"},
|
||||
{"%dms", "%dms"},
|
||||
{"Outbound tunnels", "出站隧道"},
|
||||
{"Tags", "标签"},
|
||||
{"Incoming", "传入"},
|
||||
@@ -118,9 +118,10 @@ namespace chinese // language namespace
|
||||
{"Gateway", "网关"},
|
||||
{"TunnelID", "隧道 ID"},
|
||||
{"EndDate", "结束日期"},
|
||||
{"not floodfill", "非洪泛"},
|
||||
{"floodfill mode is disabled", "洪泛已禁用"},
|
||||
{"Queue size", "队列大小"},
|
||||
{"Run peer test", "运行节点测试"},
|
||||
{"Reload tunnels configuration", "重新载入隧道配置"},
|
||||
{"Decline transit tunnels", "拒绝中转隧道"},
|
||||
{"Accept transit tunnels", "允许中转隧道"},
|
||||
{"Cancel graceful shutdown", "取消平滑关闭"},
|
||||
@@ -128,7 +129,7 @@ namespace chinese // language namespace
|
||||
{"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", "更改语言"},
|
||||
@@ -148,8 +149,8 @@ namespace chinese // language namespace
|
||||
{"Destination not found", "找不到目标"},
|
||||
{"StreamID can't be null", "StreamID 不能为空"},
|
||||
{"Return to destination page", "返回目标页面"},
|
||||
{"You will be redirected in 5 seconds", "您将在5秒内被重定向"},
|
||||
{"Transit tunnels count must not exceed 65535", "中转隧道数量不能超过 65535"},
|
||||
{"You will be redirected in %d seconds", "您将在%d秒内被重定向"},
|
||||
{"Transit tunnels count must not exceed %d", "中转隧道数量限制为 %d"},
|
||||
{"Back to commands list", "返回命令列表"},
|
||||
{"Register at reg.i2p", "在 reg.i2p 注册域名"},
|
||||
{"Description", "描述"},
|
||||
@@ -164,35 +165,36 @@ namespace chinese // language namespace
|
||||
{"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", "您可以尝试在下方的跳转服务中找到该主机"},
|
||||
{"You may try to find this host on jump services below", "您可以尝试在下方的跳转服务中找到此主机"},
|
||||
{"Invalid request", "无效请求"},
|
||||
{"Proxy unable to parse your request", "代理无法解析您的请求"},
|
||||
{"addresshelper is not supported", "不支持地址助手"},
|
||||
{"Host", "主机"},
|
||||
{"added to router's addressbook from helper", "将此地址从地址助手添加到路由地址簿"},
|
||||
{"Click here to proceed:", "点击此处继续:"},
|
||||
{"Continue", "继续"},
|
||||
{"Addresshelper found", "已找到地址助手"},
|
||||
{"already in router's addressbook", "已在路由地址簿中"},
|
||||
{"Click here to update record:", "点击此处更新地址簿记录"},
|
||||
{"invalid request uri", "无效的 URL 请求"},
|
||||
{"Addresshelper is not supported", "不支持地址助手"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "主机 %s <font color=red>已在路由地址簿中</font>。<b>请注意:此地址的来源可能是有害的!</b>点击此处更新记录:<a href=\"%s%s%s&update=true\">继续</a>"},
|
||||
{"Addresshelper forced update rejected", "地址助手强制更新被拒绝"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "若要在路由器地址簿中添加主机 <b>%s</b> 请点击这里: <a href=\"%s%s%s\">继续</a>"},
|
||||
{"Addresshelper request", "请求地址助手"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "主机 %s 已通过地址助手添加到路由地址簿中。点击此处继续:<a href=\"%s\">继续</a>"},
|
||||
{"Addresshelper adding", "正在添加地址助手"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "主机 %s <font color=red>已在路由地址簿中</font>。点击此处更新记录:<a href=\"%s%s%s&update=true\">继续</a>"},
|
||||
{"Addresshelper update", "更新地址助手"},
|
||||
{"Invalid request URI", "无效的 URI 请求"},
|
||||
{"Can't detect destination host from request", "无法从请求中检测到目标主机"},
|
||||
{"Outproxy failure", "出口代理故障"},
|
||||
{"bad outproxy settings", "错误的出口代理设置"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "该地址不在 I2P 网络内,但未启用出口代理"},
|
||||
{"unknown outproxy url", "未知的出口代理地址"},
|
||||
{"cannot resolve upstream proxy", "无法解析上游代理"},
|
||||
{"hostname too long", "主机名过长"},
|
||||
{"cannot connect to upstream socks proxy", "无法连接到上游 socks 代理"},
|
||||
{"Cannot negotiate with socks proxy", "无法与 socks 代理协商"},
|
||||
{"Bad outproxy settings", "错误的出口代理设置"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "主机 %s 不在 I2P 网络内,但出口代理未启用"},
|
||||
{"Unknown outproxy URL", "未知的出口代理地址"},
|
||||
{"Cannot resolve upstream proxy", "无法解析上游代理"},
|
||||
{"Hostname is too long", "主机名过长"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "无法连接到上游 SOCKS 代理"},
|
||||
{"Cannot negotiate with SOCKS proxy", "无法与 SOCKS 代理协商"},
|
||||
{"CONNECT error", "连接错误"},
|
||||
{"Failed to Connect", "连接失败"},
|
||||
{"socks proxy error", "socks 代理错误"},
|
||||
{"failed to send request to upstream", "向上游发送请求失败"},
|
||||
{"No Reply From socks proxy", "没有来自 socks 代理的回复"},
|
||||
{"cannot connect", "无法连接"},
|
||||
{"http out proxy not implemented", "http 出口代理未实现"},
|
||||
{"cannot connect to upstream http proxy", "无法连接到上游 http 代理"},
|
||||
{"Failed to connect", "连接失败"},
|
||||
{"SOCKS proxy error", "SOCKS 代理错误"},
|
||||
{"Failed to send request to upstream", "向上游发送请求失败"},
|
||||
{"No reply from SOCKS proxy", "没有来自 SOCKS 代理的回复"},
|
||||
{"Cannot connect", "无法连接"},
|
||||
{"HTTP out proxy not implemented", "HTTP 出口代理未实现"},
|
||||
{"Cannot connect to upstream HTTP proxy", "无法连接到上游 HTTP 代理"},
|
||||
{"Host is down", "主机已关闭"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "无法创建到目标主机的连接。主机可能已下线,请稍后再试。"},
|
||||
{"", ""},
|
||||
@@ -200,9 +202,9 @@ namespace chinese // language namespace
|
||||
|
||||
static std::map<std::string, std::vector<std::string>> plurals
|
||||
{
|
||||
{"%d days", {"%d 日"}},
|
||||
{"%d hours", {"%d 时"}},
|
||||
{"%d minutes", {"%d 分"}},
|
||||
{"%d days", {"%d 天"}},
|
||||
{"%d hours", {"%d 小时"}},
|
||||
{"%d minutes", {"%d 分钟"}},
|
||||
{"%d seconds", {"%d 秒"}},
|
||||
{"", {""}},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, The PurpleI2P Project
|
||||
* Copyright (c) 2022-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -58,7 +58,6 @@ namespace czech // language namespace
|
||||
{"Unknown", "Neznámý"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Síť"},
|
||||
{"Error", "Chyba"},
|
||||
{"Clock skew", "Časová nesrovnalost"},
|
||||
{"Offline", "Offline"},
|
||||
{"Symmetric NAT", "Symetrický NAT"},
|
||||
@@ -117,7 +116,6 @@ namespace czech // language namespace
|
||||
{"Gateway", "Brána"},
|
||||
{"TunnelID", "ID tunelu"},
|
||||
{"EndDate", "Datum ukončení"},
|
||||
{"not floodfill", "není floodfill"},
|
||||
{"Queue size", "Velikost fronty"},
|
||||
{"Run peer test", "Spustit peer test"},
|
||||
{"Decline transit tunnels", "Odmítnout tranzitní tunely"},
|
||||
@@ -147,8 +145,6 @@ namespace czech // language namespace
|
||||
{"Destination not found", "Destinace nenalezena"},
|
||||
{"StreamID can't be null", "StreamID nemůže být null"},
|
||||
{"Return to destination page", "Zpět na stránku destinací"},
|
||||
{"You will be redirected in 5 seconds", "Budete přesměrováni za 5 vteřin"},
|
||||
{"Transit tunnels count must not exceed 65535", "Počet tranzitních tunelů nesmí přesáhnout 65535"},
|
||||
{"Back to commands list", "Zpět na list příkazů"},
|
||||
{"Register at reg.i2p", "Zaregistrovat na reg.i2p"},
|
||||
{"Description", "Popis"},
|
||||
@@ -166,32 +162,24 @@ namespace czech // language namespace
|
||||
{"You may try to find this host on jump services below", "Můžete se pokusit najít tohoto hostitele na startovacích službách níže"},
|
||||
{"Invalid request", "Neplatný požadavek"},
|
||||
{"Proxy unable to parse your request", "Proxy server nemohl zpracovat váš požadavek"},
|
||||
{"addresshelper is not supported", "Adresshelper není podporován"},
|
||||
{"Host", "Hostitel"},
|
||||
{"added to router's addressbook from helper", "přidáno do adresáře routeru od pomocníka"},
|
||||
{"Click here to proceed:", "Pro pokračování, klikněte zde:"},
|
||||
{"Continue", "Pokračovat"},
|
||||
{"Addresshelper found", "Adresář nalezen"},
|
||||
{"already in router's addressbook", "je již v adresáři routeru"},
|
||||
{"Click here to update record:", "Pro aktualizaci záznamu, klikněte zde:"},
|
||||
{"invalid request uri", "neplatný URI požadavek"},
|
||||
{"Invalid request URI", "Neplatný URI požadavek"},
|
||||
{"Can't detect destination host from request", "Nelze zjistit cílového hostitele z požadavku"},
|
||||
{"Outproxy failure", "Outproxy selhání"},
|
||||
{"bad outproxy settings", "špatné outproxy nastavení"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "není uvnitř I2P sítě a outproxy není nastavena"},
|
||||
{"unknown outproxy url", "neznámá outproxy URL"},
|
||||
{"cannot resolve upstream proxy", "nelze rozluštit upstream proxy server"},
|
||||
{"hostname too long", "Název hostitele je příliš dlouhý"},
|
||||
{"cannot connect to upstream socks proxy", "nelze se připojit k upstream socks proxy serveru"},
|
||||
{"Cannot negotiate with socks proxy", "Nelze vyjednávat se socks proxy serverem"},
|
||||
{"Bad outproxy settings", "Špatné outproxy nastavení"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Hostitel %s není uvnitř I2P sítě a outproxy není nastavena"},
|
||||
{"Unknown outproxy URL", "Neznámá outproxy URL"},
|
||||
{"Cannot resolve upstream proxy", "Nelze rozluštit upstream proxy server"},
|
||||
{"Hostname is too long", "Název hostitele je příliš dlouhý"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Nelze se připojit k upstream SOCKS proxy serveru"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Nelze vyjednávat se SOCKS proxy serverem"},
|
||||
{"CONNECT error", "Chyba PŘIPOJENÍ"},
|
||||
{"Failed to Connect", "Připojení se nezdařilo"},
|
||||
{"socks proxy error", "chyba socks proxy serveru"},
|
||||
{"failed to send request to upstream", "odeslání žádosti upstream serveru se nezdařilo"},
|
||||
{"No Reply From socks proxy", "Žádná odpověď od socks proxy serveru"},
|
||||
{"cannot connect", "nelze se připojit"},
|
||||
{"http out proxy not implemented", "http out proxy není implementován"},
|
||||
{"cannot connect to upstream http proxy", "nelze se připojit k upstream socks proxy serveru"},
|
||||
{"Failed to connect", "Připojení se nezdařilo"},
|
||||
{"SOCKS proxy error", "Chyba SOCKS proxy serveru"},
|
||||
{"Failed to send request to upstream", "Odeslání žádosti upstream serveru se nezdařilo"},
|
||||
{"No reply from SOCKS proxy", "Žádná odpověď od SOCKS proxy serveru"},
|
||||
{"Cannot connect", "Nelze se připojit"},
|
||||
{"HTTP out proxy not implemented", "HTTP out proxy není implementován"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Nelze se připojit k upstream HTTP proxy serveru"},
|
||||
{"Host is down", "Hostitel je nedostupný"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Připojení k požadovanému hostiteli nelze vytvořit, může být nedostupný. Zkuste to, prosím, znovu později."},
|
||||
{"", ""},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, The PurpleI2P Project
|
||||
* Copyright (c) 2022-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -58,10 +58,11 @@ namespace french // language namespace
|
||||
{"Unknown", "Inconnu"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Maillé"},
|
||||
{"Error", "Erreur"},
|
||||
{"Clock skew", "Horloge décalée"},
|
||||
{"Offline", "Hors ligne"},
|
||||
{"Symmetric NAT", "NAT symétrique"},
|
||||
{"Full cone NAT", "NAT à cône complet"},
|
||||
{"No Descriptors", "Aucuns Descripteurs"},
|
||||
{"Uptime", "Temps de fonctionnement"},
|
||||
{"Network status", "État du réseau"},
|
||||
{"Network status v6", "État du réseau v6"},
|
||||
@@ -69,7 +70,7 @@ namespace french // language namespace
|
||||
{"Family", "Famille"},
|
||||
{"Tunnel creation success rate", "Taux de succès de création de tunnels"},
|
||||
{"Received", "Reçu"},
|
||||
{"%.2f KiB/s", "%.2f kio/s"},
|
||||
{"%.2f KiB/s", "%.2f Kio/s"},
|
||||
{"Sent", "Envoyé"},
|
||||
{"Transit", "Transité"},
|
||||
{"Data path", "Emplacement des données"},
|
||||
@@ -81,6 +82,7 @@ namespace french // language namespace
|
||||
{"Our external address", "Notre adresse externe"},
|
||||
{"supported", "supporté"},
|
||||
{"Routers", "Routeurs"},
|
||||
{"Floodfills", "Remplisseurs"},
|
||||
{"Client Tunnels", "Tunnels clients"},
|
||||
{"Services", "Services"},
|
||||
{"Enabled", "Activé"},
|
||||
@@ -92,6 +94,7 @@ namespace french // language namespace
|
||||
{"<b>Note:</b> result string can be used only for registering 2LD domains (example.i2p). For registering subdomains please use i2pd-tools.", "<b>Note:</b> La chaîne résultante peut seulement être utilisée pour enregistrer les domaines 2LD (exemple.i2p). Pour enregistrer des sous-domaines, veuillez utiliser i2pd-tools."},
|
||||
{"Address", "Adresse"},
|
||||
{"Type", "Type"},
|
||||
{"EncType", "EncType"},
|
||||
{"Inbound tunnels", "Tunnels entrants"},
|
||||
{"%dms", "%dms"},
|
||||
{"Outbound tunnels", "Tunnels sortants"},
|
||||
@@ -115,8 +118,10 @@ namespace french // language namespace
|
||||
{"Gateway", "Passerelle"},
|
||||
{"TunnelID", "ID du tunnel"},
|
||||
{"EndDate", "Date de fin"},
|
||||
{"floodfill mode is disabled", "le mode de remplissage est désactivé"},
|
||||
{"Queue size", "Longueur de la file"},
|
||||
{"Run peer test", "Lancer test des pairs"},
|
||||
{"Reload tunnels configuration", "Recharger la configuration des tunnels"},
|
||||
{"Decline transit tunnels", "Refuser les tunnels transitoires"},
|
||||
{"Accept transit tunnels", "Accepter les tunnels transitoires"},
|
||||
{"Cancel graceful shutdown", "Annuler l'arrêt gracieux"},
|
||||
@@ -134,6 +139,8 @@ namespace french // language namespace
|
||||
{"SAM session not found", "session SAM introuvable"},
|
||||
{"SAM Session", "Session SAM"},
|
||||
{"Server Tunnels", "Tunnels serveurs"},
|
||||
{"Client Forwards", "Transmission du client"},
|
||||
{"Server Forwards", "Transmission du serveur"},
|
||||
{"Unknown page", "Page inconnue"},
|
||||
{"Invalid token", "Jeton invalide"},
|
||||
{"SUCCESS", "SUCCÈS"},
|
||||
@@ -142,8 +149,8 @@ namespace french // language namespace
|
||||
{"Destination not found", "Destination introuvable"},
|
||||
{"StreamID can't be null", "StreamID ne peut pas être vide"},
|
||||
{"Return to destination page", "Retourner à la page de destination"},
|
||||
{"You will be redirected in 5 seconds", "Vous allez être redirigé dans cinq secondes"},
|
||||
{"Transit tunnels count must not exceed 65535", "Le nombre de tunnels transitoires ne doit pas dépasser 65535"},
|
||||
{"You will be redirected in %d seconds", "Vous serez redirigé dans %d secondes"},
|
||||
{"Transit tunnels count must not exceed %d", "Le nombre de tunnels de transit ne doit pas excéder %d"},
|
||||
{"Back to commands list", "Retour à la liste des commandes"},
|
||||
{"Register at reg.i2p", "Inscription à reg.i2p"},
|
||||
{"Description", "Description"},
|
||||
@@ -161,32 +168,33 @@ namespace french // language namespace
|
||||
{"You may try to find this host on jump services below", "Vous pouvez essayer de trouver cet hôte sur des services de redirection ci-dessous"},
|
||||
{"Invalid request", "Requête invalide"},
|
||||
{"Proxy unable to parse your request", "Proxy incapable de comprendre votre requête"},
|
||||
{"addresshelper is not supported", "Assistant d'adresse non supporté"},
|
||||
{"Host", "Hôte"},
|
||||
{"added to router's addressbook from helper", "Ajouté au carnet d'adresse du routeur par l'assistant"},
|
||||
{"Click here to proceed:", "Cliquez ici pour continuer:"},
|
||||
{"Continue", "Continuer"},
|
||||
{"Addresshelper found", "Assistant d'adresse trouvé"},
|
||||
{"already in router's addressbook", "déjà dans le carnet d'adresses du routeur"},
|
||||
{"Click here to update record:", "Cliquez ici pour mettre à jour le carnet d'adresse:"},
|
||||
{"invalid request uri", "uri de la requête invalide"},
|
||||
{"Addresshelper is not supported", "Assistant d'adresse non supporté"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "L'hôte %s est <font color=red>déjà dans le carnet d'adresses du routeur</font>. <b>Attention : la source de cette URL peut être nuisible !</b> Cliquez ici pour mettre à jour l'enregistrement : <a href=\"%s%s%s&update=true\">Continuer</a>."},
|
||||
{"Addresshelper forced update rejected", "Mise à jour forcée des assistants d'adresses rejetée"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Pour ajouter l'hôte <b>%s</b> au carnet d'adresses du routeur, cliquez ici : <a href=\"%s%s%s\">Continuer</a>."},
|
||||
{"Addresshelper request", "Demande à l'assistant d'adresse"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "L'hôte %s a été ajouté au carnet d'adresses du routeur depuis l'assistant. Cliquez ici pour continuer : <a href=\"%s\">Continuer</a>."},
|
||||
{"Addresshelper adding", "Ajout de l'assistant d'adresse"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "L'hôte %s est <font color=red>déjà dans le carnet d'adresses du routeur</font>. Cliquez ici pour mettre à jour le dossier : <a href=\"%s%s%s&update=true\">Continuer</a>."},
|
||||
{"Addresshelper update", "Mise à jour de l'assistant d'adresse"},
|
||||
{"Invalid request URI", "URI de la requête invalide"},
|
||||
{"Can't detect destination host from request", "Impossible de détecter l'hôte de destination à partir de la requête"},
|
||||
{"Outproxy failure", "Échec de proxy de sortie"},
|
||||
{"bad outproxy settings", "Mauvaise configuration du proxy de sortie"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "pas dans le réseau I2P, mais le proxy de sortie n'est pas activé"},
|
||||
{"unknown outproxy url", "URL du proxy de sortie inconnu"},
|
||||
{"cannot resolve upstream proxy", "impossible de résoudre l'adresse du proxy en amont"},
|
||||
{"hostname too long", "nom d'hôte trop long"},
|
||||
{"cannot connect to upstream socks proxy", "impossible de se connecter au proxy socks en amont"},
|
||||
{"Cannot negotiate with socks proxy", "Impossible de négocier avec le proxy socks"},
|
||||
{"Bad outproxy settings", "Mauvaise configuration du proxy de sortie"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Hôte %s pas dans le réseau I2P, mais le proxy de sortie n'est pas activé"},
|
||||
{"Unknown outproxy URL", "URL du proxy de sortie inconnu"},
|
||||
{"Cannot resolve upstream proxy", "Impossible de résoudre l'adresse du proxy en amont"},
|
||||
{"Hostname is too long", "Nom d'hôte trop long"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Impossible de se connecter au proxy SOCKS en amont"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Impossible de négocier avec le proxy SOCKS"},
|
||||
{"CONNECT error", "Erreur de connexion"},
|
||||
{"Failed to Connect", "Échec de connexion"},
|
||||
{"socks proxy error", "Erreur de proxy socks"},
|
||||
{"failed to send request to upstream", "Erreur lors de l'envoie de la requête en amont"},
|
||||
{"No Reply From socks proxy", "Pas de réponse du proxy socks"},
|
||||
{"cannot connect", "impossible de connecter"},
|
||||
{"http out proxy not implemented", "Proxy de sortie HTTP non implémenté"},
|
||||
{"cannot connect to upstream http proxy", "impossible de se connecter au proxy HTTP en amont"},
|
||||
{"Failed to connect", "Échec de connexion"},
|
||||
{"SOCKS proxy error", "Erreur de proxy SOCKS"},
|
||||
{"Failed to send request to upstream", "Erreur lors de l'envoie de la requête en amont"},
|
||||
{"No reply from SOCKS proxy", "Pas de réponse du proxy SOCKS"},
|
||||
{"Cannot connect", "Impossible de connecter"},
|
||||
{"HTTP out proxy not implemented", "Proxy de sortie HTTP non implémenté"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Impossible de se connecter au proxy HTTP en amont"},
|
||||
{"Host is down", "Hôte hors service"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Impossible d'établir une connexion avec l'hôte, il est peut-être hors service. Veuillez réessayer plus tard."},
|
||||
{"", ""},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, The PurpleI2P Project
|
||||
* Copyright (c) 2022-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -58,10 +58,10 @@ namespace german // language namespace
|
||||
{"Unknown", "Unbekannt"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Mesh"},
|
||||
{"Error", "Fehler"},
|
||||
{"Clock skew", "Zeitabweichung"},
|
||||
{"Offline", "Offline"},
|
||||
{"Symmetric NAT", "Symmetrisches NAT"},
|
||||
{"No Descriptors", "Keine Beschreibungen"},
|
||||
{"Uptime", "Laufzeit"},
|
||||
{"Network status", "Netzwerkstatus"},
|
||||
{"Network status v6", "Netzwerkstatus v6"},
|
||||
@@ -117,9 +117,10 @@ namespace german // language namespace
|
||||
{"Gateway", "Gateway"},
|
||||
{"TunnelID", "TunnelID"},
|
||||
{"EndDate", "Enddatum"},
|
||||
{"not floodfill", "kein Floodfill"},
|
||||
{"floodfill mode is disabled", "Floodfill Modus ist deaktiviert"},
|
||||
{"Queue size", "Größe der Warteschlange"},
|
||||
{"Run peer test", "Peer-Test durchführen"},
|
||||
{"Reload tunnels configuration", "Tunnel Konfiguration neu laden"},
|
||||
{"Decline transit tunnels", "Transittunnel ablehnen"},
|
||||
{"Accept transit tunnels", "Transittunnel akzeptieren"},
|
||||
{"Cancel graceful shutdown", "Beende das kontrollierte Herunterfahren"},
|
||||
@@ -147,8 +148,8 @@ namespace german // language namespace
|
||||
{"Destination not found", "Ziel nicht gefunden"},
|
||||
{"StreamID can't be null", "StreamID kann nicht null sein"},
|
||||
{"Return to destination page", "Zurück zur Ziel-Seite"},
|
||||
{"You will be redirected in 5 seconds", "Du wirst in 5 Sekunden weitergeleitet"},
|
||||
{"Transit tunnels count must not exceed 65535", "Es darf maximal 65535 Transittunnel geben"},
|
||||
{"You will be redirected in %d seconds", "Du wirst umgeleitet in %d Sekunden"},
|
||||
{"Transit tunnels count must not exceed %d", "Die Anzahl der Transittunnel darf nicht über %d gehen"},
|
||||
{"Back to commands list", "Zurück zur Befehlsliste"},
|
||||
{"Register at reg.i2p", "Auf reg.i2p registrieren"},
|
||||
{"Description", "Beschreibung"},
|
||||
@@ -166,32 +167,33 @@ namespace german // language namespace
|
||||
{"You may try to find this host on jump services below", "Vielleicht kannst du diesen Host auf einem der nachfolgenden Jump-Services finden"},
|
||||
{"Invalid request", "Ungültige Anfrage"},
|
||||
{"Proxy unable to parse your request", "Proxy konnte die Anfrage nicht verarbeiten"},
|
||||
{"addresshelper is not supported", "Addresshelfer wird nicht unterstützt"},
|
||||
{"Host", "Host"},
|
||||
{"added to router's addressbook from helper", "vom Helfer zum Router-Adressbuch hinzugefügt"},
|
||||
{"Click here to proceed:", "Klicke hier um fortzufahren:"},
|
||||
{"Continue", "Fortsetzen"},
|
||||
{"Addresshelper found", "Adresshelfer gefunden"},
|
||||
{"already in router's addressbook", "bereits im Adressbuch des Routers"},
|
||||
{"Click here to update record:", "Klicke hier, um den Eintrag zu aktualisieren:"},
|
||||
{"invalid request uri", "ungültige Anfrage-URI"},
|
||||
{"Addresshelper is not supported", "Adresshelfer wird nicht unterstützt"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "Host %s ist <font color=red>bereits im Adressbuch des Routers</font>. <b>Vorsicht: Die Quelle dieser URL kann schädlich sein!</b> Klicken Sie hier, um den Datensatz zu aktualisieren: <a href=\"%s%s%s&update=true\">Weiter</a>."},
|
||||
{"Addresshelper forced update rejected", "Adresshelfer gezwungene Aktualisierung abgelehnt"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Um den Host <b>%s</b> im Adressbuch des Routers hinzuzufügen, klicken Sie hier: <a href=\"%s%s%s\">Weiter</a>."},
|
||||
{"Addresshelper request", "Adresshelfer gefunden"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "Host %s wurde vom Helfer zum Adressbuch des Routers hinzugefügt. Klicken Sie hier, um fortzufahren: <a href=\"%s\">Weiter</a>."},
|
||||
{"Addresshelper adding", "Adresshelfer hinzufügen"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "Host %s ist <font color=red>bereits im Adressbuch des Routers</font>. Klicken Sie hier, um den Eintrag zu aktualisieren: <a href=\"%s%s%s&update=true\">Weiter</a>."},
|
||||
{"Addresshelper update", "Adresshelfer aktualisieren"},
|
||||
{"Invalid request URI", "Ungültige Anfrage-URI"},
|
||||
{"Can't detect destination host from request", "Kann den Ziel-Host von der Anfrage nicht erkennen"},
|
||||
{"Outproxy failure", "Outproxy-Fehler"},
|
||||
{"bad outproxy settings", "ungültige Outproxy-Einstellungen"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "außerhalb des I2P-Netzwerks, aber Outproxy ist nicht aktiviert"},
|
||||
{"unknown outproxy url", "unbekannte Outproxy-URL"},
|
||||
{"cannot resolve upstream proxy", "kann den Upstream-Proxy nicht auflösen"},
|
||||
{"hostname too long", "Hostname zu lang"},
|
||||
{"cannot connect to upstream socks proxy", "Kann keine Verbindung zum Upstream-Socks-Proxy herstellen"},
|
||||
{"Cannot negotiate with socks proxy", "Kann nicht mit Socks-Proxy verhandeln"},
|
||||
{"Bad outproxy settings", "Ungültige Outproxy-Einstellungen"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Host %s außerhalb des I2P-Netzwerks, aber Outproxy ist nicht aktiviert"},
|
||||
{"Unknown outproxy URL", "Unbekannte Outproxy-URL"},
|
||||
{"Cannot resolve upstream proxy", "Kann den Upstream-Proxy nicht auflösen"},
|
||||
{"Hostname is too long", "Hostname zu lang"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Kann keine Verbindung zum Upstream-SOCKS-Proxy herstellen"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Kann nicht mit SOCKS-Proxy verhandeln"},
|
||||
{"CONNECT error", "CONNECT-Fehler"},
|
||||
{"Failed to Connect", "Verbindung konnte nicht hergestellt werden"},
|
||||
{"socks proxy error", "Socks-Proxy-Fehler"},
|
||||
{"failed to send request to upstream", "Anfrage an den Upstream zu senden ist gescheitert"},
|
||||
{"No Reply From socks proxy", "Keine Antwort vom Socks-Proxy"},
|
||||
{"cannot connect", "kann nicht verbinden"},
|
||||
{"http out proxy not implemented", "HTTP-Outproxy nicht implementiert"},
|
||||
{"cannot connect to upstream http proxy", "Kann nicht zu Upstream-HTTP-Proxy verbinden"},
|
||||
{"Failed to connect", "Verbindung konnte nicht hergestellt werden"},
|
||||
{"SOCKS proxy error", "SOCKS-Proxy-Fehler"},
|
||||
{"Failed to send request to upstream", "Anfrage an den Upstream zu senden ist gescheitert"},
|
||||
{"No reply from SOCKS proxy", "Keine Antwort vom SOCKS-Proxy"},
|
||||
{"Cannot connect", "Kann nicht verbinden"},
|
||||
{"HTTP out proxy not implemented", "HTTP-Outproxy nicht implementiert"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Kann nicht zu Upstream-HTTP-Proxy verbinden"},
|
||||
{"Host is down", "Host ist offline"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Konnte keine Verbindung zum angefragten Host aufbauen, vielleicht ist er offline. Versuche es später noch mal."},
|
||||
{"", ""},
|
||||
|
||||
@@ -95,9 +95,8 @@ std::string tr (TValue&& arg, TArgs&&... args)
|
||||
std::string tr_str = i2p::i18n::translate(std::forward<TValue>(arg));
|
||||
|
||||
size_t size = std::snprintf(NULL, 0, tr_str.c_str(), std::forward<TArgs>(args)...);
|
||||
size = size + 1;
|
||||
std::string str(size, 0);
|
||||
std::snprintf(&str.front(), size, tr_str.c_str(), std::forward<TArgs>(args)...);
|
||||
std::snprintf(&str.front(), size + 1, tr_str.c_str(), std::forward<TArgs>(args)...);
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -127,9 +126,8 @@ std::string ntr (TValue&& arg, TValue2&& arg2, int& n, TArgs&&... args)
|
||||
std::string tr_str = i2p::i18n::translate(std::forward<TValue>(arg), std::forward<TValue2>(arg2), std::forward<int>(n));
|
||||
|
||||
size_t size = std::snprintf(NULL, 0, tr_str.c_str(), std::forward<TArgs>(args)...);
|
||||
size = size + 1;
|
||||
std::string str(size, 0);
|
||||
std::snprintf(&str.front(), size, tr_str.c_str(), std::forward<TArgs>(args)...);
|
||||
std::snprintf(&str.front(), size + 1, tr_str.c_str(), std::forward<TArgs>(args)...);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2021-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -23,20 +23,23 @@ namespace i18n
|
||||
};
|
||||
|
||||
// Add localization here with language name as namespace
|
||||
namespace afrikaans { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace armenian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace chinese { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace czech { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace english { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace french { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace german { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace 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 swedish { 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 (); }
|
||||
namespace afrikaans { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace armenian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace chinese { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace czech { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace english { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace french { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace german { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace italian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace polish { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace portuguese { 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 swedish { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
|
||||
namespace turkish { 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 (); }
|
||||
|
||||
/**
|
||||
* That map contains international language name lower-case, name in it's language and it's code
|
||||
@@ -51,9 +54,12 @@ namespace i18n
|
||||
{ "french", {"Français", "fr", i2p::i18n::french::GetLocale} },
|
||||
{ "german", {"Deutsch", "de", i2p::i18n::german::GetLocale} },
|
||||
{ "italian", {"Italiano", "it", i2p::i18n::italian::GetLocale} },
|
||||
{ "polish", {"Polski", "pl", i2p::i18n::polish::GetLocale} },
|
||||
{ "portuguese", {"Português", "pt", i2p::i18n::portuguese::GetLocale} },
|
||||
{ "russian", {"Русский язык", "ru", i2p::i18n::russian::GetLocale} },
|
||||
{ "spanish", {"Español", "es", i2p::i18n::spanish::GetLocale} },
|
||||
{ "swedish", {"Svenska", "sv", i2p::i18n::swedish::GetLocale} },
|
||||
{ "turkish", {"Türk dili", "tr", i2p::i18n::turkish::GetLocale} },
|
||||
{ "turkmen", {"Türkmen dili", "tk", i2p::i18n::turkmen::GetLocale} },
|
||||
{ "ukrainian", {"Украї́нська мо́ва", "uk", i2p::i18n::ukrainian::GetLocale} },
|
||||
{ "uzbek", {"Oʻzbek", "uz", i2p::i18n::uzbek::GetLocale} },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, The PurpleI2P Project
|
||||
* Copyright (c) 2022-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -58,10 +58,11 @@ namespace italian // language namespace
|
||||
{"Unknown", "Sconosciuto"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Mesh"},
|
||||
{"Error", "Errore"},
|
||||
{"Clock skew", "Orologio disallineato"},
|
||||
{"Offline", "Disconnesso"},
|
||||
{"Symmetric NAT", "NAT simmetrico"},
|
||||
{"Full cone NAT", "Cono completo NAT"},
|
||||
{"No Descriptors", "Nessun descrittore"},
|
||||
{"Uptime", "In funzione da"},
|
||||
{"Network status", "Stato della rete"},
|
||||
{"Network status v6", "Stato della rete v6"},
|
||||
@@ -117,9 +118,10 @@ namespace italian // language namespace
|
||||
{"Gateway", "Gateway"},
|
||||
{"TunnelID", "TunnelID"},
|
||||
{"EndDate", "Data di fine"},
|
||||
{"not floodfill", "no floodfill"},
|
||||
{"floodfill mode is disabled", "la modalità floodfill è disabilitata"},
|
||||
{"Queue size", "Dimensione della coda"},
|
||||
{"Run peer test", "Esegui il test dei peer"},
|
||||
{"Reload tunnels configuration", "Ricarica la configurazione dei tunnel"},
|
||||
{"Decline transit tunnels", "Rifiuta tunnel di transito"},
|
||||
{"Accept transit tunnels", "Accetta tunnel di transito"},
|
||||
{"Cancel graceful shutdown", "Annulla l'interruzione controllata"},
|
||||
@@ -147,8 +149,8 @@ namespace italian // language namespace
|
||||
{"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"},
|
||||
{"You will be redirected in %d seconds", "Sarai reindirizzato tra %d secondi"},
|
||||
{"Transit tunnels count must not exceed %d", "Il conteggio dei tunnel di transito non deve superare %d"},
|
||||
{"Back to commands list", "Ritorna alla lista dei comandi"},
|
||||
{"Register at reg.i2p", "Registra a reg.i2p"},
|
||||
{"Description", "Descrizione"},
|
||||
@@ -166,32 +168,33 @@ namespace italian // language namespace
|
||||
{"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"},
|
||||
{"Addresshelper is not supported", "Addresshelper non è supportato"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "L'host %s è <font color=red>già nella rubrica del router</font>. <b>Attenzione: la fonte di questo URL potrebbe essere dannosa!</b> Fai clic qui per aggiornare il record: <a href=\"%s%s%s&update=true\">Continua</a>."},
|
||||
{"Addresshelper forced update rejected", "Aggiornamento forzato dell'helper degli indirizzi rifiutato"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Per aggiungere host <b>%s</b> nella rubrica del router, clicca qui: <a href=\"%s%s%s\">Continua</a>."},
|
||||
{"Addresshelper request", "Richiesta di indirizzo helper"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "L'host %s viene aggiunto alla rubrica del router dall'helper. Fai clic qui per procedere: <a href=\"%s\">Continua</a>."},
|
||||
{"Addresshelper adding", "Aggiunta di Addresshelper"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "L'host %s è <font color=red>già nella rubrica del router</font>. Clicca qui per aggiornare il record: <a href=\"%s%s%s&update=true\">Continua</a>."},
|
||||
{"Addresshelper update", "Aggiornamento dell'helper degli indirizzi"},
|
||||
{"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"},
|
||||
{"Bad outproxy settings", "Impostazioni errate del proxy di uscita"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Host %s 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 is 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"},
|
||||
{"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 flusso a monte del proxy HTTP"},
|
||||
{"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."},
|
||||
{"", ""},
|
||||
|
||||
59
i18n/Polish.cpp
Normal file
59
i18n/Polish.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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"
|
||||
|
||||
// Polish localization file
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace i18n
|
||||
{
|
||||
namespace polish // language namespace
|
||||
{
|
||||
// language name in lowercase
|
||||
static std::string language = "polish";
|
||||
|
||||
// See for language plural forms here:
|
||||
// https://localization-guide.readthedocs.io/en/latest/l10n/pluralforms.html
|
||||
static int plural (int n) {
|
||||
return (n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
||||
}
|
||||
|
||||
static std::map<std::string, std::string> strings
|
||||
{
|
||||
{"building", "Kompilowanie"},
|
||||
{"failed", "nieudane"},
|
||||
{"expiring", "wygasający"},
|
||||
{"established", "ustanowiony"},
|
||||
{"Main page", "Strona główna"},
|
||||
{"Router commands", "Komendy routera"},
|
||||
{"Tunnels", "Tunele"},
|
||||
{"OK", "Ok"},
|
||||
{"Uptime", "Czas pracy"},
|
||||
{"Sent", "Wysłane"},
|
||||
{"", ""},
|
||||
};
|
||||
|
||||
static std::map<std::string, std::vector<std::string>> plurals
|
||||
{
|
||||
{"", {"", "", ""}},
|
||||
};
|
||||
|
||||
std::shared_ptr<const i2p::i18n::Locale> GetLocale()
|
||||
{
|
||||
return std::make_shared<i2p::i18n::Locale>(language, strings, plurals, [] (int n)->int { return plural(n); });
|
||||
}
|
||||
|
||||
} // language
|
||||
} // i18n
|
||||
} // i2p
|
||||
219
i18n/Portuguese.cpp
Normal file
219
i18n/Portuguese.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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"
|
||||
|
||||
// Portuguese localization file
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace i18n
|
||||
{
|
||||
namespace portuguese // language namespace
|
||||
{
|
||||
// language name in lowercase
|
||||
static std::string language = "portuguese";
|
||||
|
||||
// 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
|
||||
{
|
||||
{"%.2f KiB", "%.2f KiB"},
|
||||
{"%.2f MiB", "%.2f MiB"},
|
||||
{"%.2f GiB", "%.2f GiB"},
|
||||
{"building", "construindo"},
|
||||
{"failed", "falhou"},
|
||||
{"expiring", "expirando"},
|
||||
{"established", "estabelecido"},
|
||||
{"unknown", "desconhecido"},
|
||||
{"exploratory", "exploratório"},
|
||||
{"Purple I2P Webconsole", "Webconsole Purple I2P"},
|
||||
{"<b>i2pd</b> webconsole", "webconsole <b>i2pd</b>"},
|
||||
{"Main page", "Página Principal"},
|
||||
{"Router commands", "Comandos do Roteador"},
|
||||
{"Local Destinations", "Destinos Locais"},
|
||||
{"LeaseSets", "LeaseSets"},
|
||||
{"Tunnels", "Túneis"},
|
||||
{"Transit Tunnels", "Túneis de Trânsito"},
|
||||
{"Transports", "Transportes"},
|
||||
{"I2P tunnels", "Túneis I2P"},
|
||||
{"SAM sessions", "Sessões do SAM"},
|
||||
{"ERROR", "ERRO"},
|
||||
{"OK", "OK"},
|
||||
{"Testing", "Testando"},
|
||||
{"Firewalled", "Sob Firewall"},
|
||||
{"Unknown", "Desconhecido"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Malha"},
|
||||
{"Clock skew", "Defasagem do Relógio"},
|
||||
{"Offline", "Desligado"},
|
||||
{"Symmetric NAT", "NAT Simétrico"},
|
||||
{"Full cone NAT", "Full cone NAT"},
|
||||
{"No Descriptors", "Sem Descritores"},
|
||||
{"Uptime", "Tempo Ativo"},
|
||||
{"Network status", "Estado da rede"},
|
||||
{"Network status v6", "Estado da rede v6"},
|
||||
{"Stopping in", "Parando em"},
|
||||
{"Family", "Família"},
|
||||
{"Tunnel creation success rate", "Taxa de sucesso na criação de túneis"},
|
||||
{"Received", "Recebido"},
|
||||
{"%.2f KiB/s", "%.2f KiB/s"},
|
||||
{"Sent", "Enviado"},
|
||||
{"Transit", "Trânsito"},
|
||||
{"Data path", "Diretório dos dados"},
|
||||
{"Hidden content. Press on text to see.", "Conteúdo oculto. Clique no texto para revelar."},
|
||||
{"Router Ident", "Identidade do Roteador"},
|
||||
{"Router Family", "Família do Roteador"},
|
||||
{"Router Caps", "Limites do Roteador"},
|
||||
{"Version", "Versão"},
|
||||
{"Our external address", "Nosso endereço externo"},
|
||||
{"supported", "suportado"},
|
||||
{"Routers", "Roteadores"},
|
||||
{"Floodfills", "Modo Inundação"},
|
||||
{"Client Tunnels", "Túneis de Clientes"},
|
||||
{"Services", "Serviços"},
|
||||
{"Enabled", "Ativado"},
|
||||
{"Disabled", "Desativado"},
|
||||
{"Encrypted B33 address", "Endereço B33 criptografado"},
|
||||
{"Address registration line", "Linha de cadastro de endereço"},
|
||||
{"Domain", "Domínio"},
|
||||
{"Generate", "Gerar"},
|
||||
{"<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>A string resultante só pode ser usada para registrar domínios 2LD (exemplo.i2p). Para registrar subdomínios por favor utilize o i2pd-tools."},
|
||||
{"Address", "Endereço"},
|
||||
{"Type", "Tipo"},
|
||||
{"EncType", "Tipo de Criptografia"},
|
||||
{"Inbound tunnels", "Túneis de Entrada"},
|
||||
{"%dms", "%dms"},
|
||||
{"Outbound tunnels", "Túneis de Saída"},
|
||||
{"Tags", "Etiquetas"},
|
||||
{"Incoming", "Entradas"},
|
||||
{"Outgoing", "Saídas"},
|
||||
{"Destination", "Destinos"},
|
||||
{"Amount", "Quantidade"},
|
||||
{"Incoming Tags", "Etiquetas de Entrada"},
|
||||
{"Tags sessions", "Sessões de etiquetas"},
|
||||
{"Status", "Estado"},
|
||||
{"Local Destination", "Destinos Locais"},
|
||||
{"Streams", "Fluxos"},
|
||||
{"Close stream", "Fechar fluxo"},
|
||||
{"I2CP session not found", "Sessão do I2CP não encontrada"},
|
||||
{"I2CP is not enabled", "I2CP não está ativado"},
|
||||
{"Invalid", "Inválido"},
|
||||
{"Store type", "Tipo de armazenamento"},
|
||||
{"Expires", "Expira em"},
|
||||
{"Non Expired Leases", "Sessões não expiradas"},
|
||||
{"Gateway", "Gateway"},
|
||||
{"TunnelID", "TunnelID"},
|
||||
{"EndDate", "Data final"},
|
||||
{"floodfill mode is disabled", "Mode de inundação está desativado"},
|
||||
{"Queue size", "Tamanho da fila"},
|
||||
{"Run peer test", "Executar teste de peers"},
|
||||
{"Reload tunnels configuration", "Recarregar a configuração dos túneis"},
|
||||
{"Decline transit tunnels", "Negar túneis de trânsito"},
|
||||
{"Accept transit tunnels", "Aceitar túneis de trânsito"},
|
||||
{"Cancel graceful shutdown", "Cancelar desligamento gracioso"},
|
||||
{"Start graceful shutdown", "Iniciar desligamento gracioso"},
|
||||
{"Force shutdown", "Forçar desligamento"},
|
||||
{"Reload external CSS styles", "Recarregar estilos CSS externos"},
|
||||
{"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b> Nota: </b> Qualquer ação feita aqui não será permanente e não altera os seus arquivos de configuração."},
|
||||
{"Logging level", "Nível de registro"},
|
||||
{"Transit tunnels limit", "Limite de túneis de trânsito"},
|
||||
{"Change", "Mudar"},
|
||||
{"Change language", "Trocar idioma"},
|
||||
{"no transit tunnels currently built", "Nenhum túnel de trânsito construido no momento"},
|
||||
{"SAM disabled", "SAM desativado"},
|
||||
{"no sessions currently running", "Nenhuma sessão funcionando no momento"},
|
||||
{"SAM session not found", "Nenhuma sessão do SAM encontrada"},
|
||||
{"SAM Session", "Sessão do SAM"},
|
||||
{"Server Tunnels", "Túneis de Servidor"},
|
||||
{"Client Forwards", "Túneis de Cliente"},
|
||||
{"Server Forwards", "Encaminhamentos de Servidor"},
|
||||
{"Unknown page", "Página desconhecida"},
|
||||
{"Invalid token", "Token Inválido"},
|
||||
{"SUCCESS", "SUCESSO"},
|
||||
{"Stream closed", "Fluxo fechado"},
|
||||
{"Stream not found or already was closed", "Fluxo não encontrado ou já encerrado"},
|
||||
{"Destination not found", "Destino não encontrado"},
|
||||
{"StreamID can't be null", "StreamID não pode ser nulo"},
|
||||
{"Return to destination page", "Retornar para à página de destino"},
|
||||
{"You will be redirected in %d seconds", "Você será redirecionado em %d segundos"},
|
||||
{"Transit tunnels count must not exceed %d", "A contagem de túneis de trânsito não deve exceder %d"},
|
||||
{"Back to commands list", "Voltar para a lista de comandos"},
|
||||
{"Register at reg.i2p", "Registrar na reg.i2p"},
|
||||
{"Description", "Descrição"},
|
||||
{"A bit information about service on domain", "Algumas informações sobre o serviço no domínio"},
|
||||
{"Submit", "Enviar"},
|
||||
{"Domain can't end with .b32.i2p", "O domínio não pode terminar com .b32.i2p"},
|
||||
{"Domain must end with .i2p", "O domínio não pode terminar com .i2p"},
|
||||
{"Such destination is not found", "Tal destino não foi encontrado"},
|
||||
{"Unknown command", "Comando desconhecido"},
|
||||
{"Command accepted", "Comando aceito"},
|
||||
{"Proxy error", "Erro no proxy"},
|
||||
{"Proxy info", "Informações do proxy"},
|
||||
{"Proxy error: Host not found", "Erro no proxy: Host não encontrado"},
|
||||
{"Remote host not found in router's addressbook", "O host remoto não foi encontrado no livro de endereços do roteador"},
|
||||
{"You may try to find this host on jump services below", "Você pode tentar encontrar este host nos jump services abaixo"},
|
||||
{"Invalid request", "Requisição inválida"},
|
||||
{"Proxy unable to parse your request", "O proxy foi incapaz de processar a sua requisição"},
|
||||
{"Addresshelper is not supported", "O Auxiliar de Endereços não é suportado"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "O host %s já <font color=red>está no catálogo de endereços do roteador</font>. <b>Cuidado: a fonte desta URL pode ser perigosa!</b> Clique aqui para atualizar o registro: <a href=\"%s%s%s&update=true\">Continuar</a>."},
|
||||
{"Addresshelper forced update rejected", "A atualização forçada do Auxiliar de Endereços foi rejeitada"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Para adicionar o host <b> %s </b> ao catálogo de endereços do roteador, clique aqui: <a href='%s%s%s'>Continuar </a>."},
|
||||
{"Addresshelper request", "Requisição do Auxiliar de Endereços"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "O host %s foi adicionado ao catálogo de endereços do roteador por um auxiliar. Clique aqui para proceder: <a href='%s'> Continuar </a>."},
|
||||
{"Addresshelper adding", "Auxiliar de Endereço adicionando"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "O host %s já <font color=red>está no catálogo de endereços do roteador </font>. Clique aqui para atualizar o registro: <a href=\"%s%s%s&update=true\">Continuar</a>."},
|
||||
{"Addresshelper update", "Atualização do Auxiliar de Endereços"},
|
||||
{"Invalid request URI", "A URI de requisição é inválida"},
|
||||
{"Can't detect destination host from request", "Incapaz de detectar o host de destino da requisição"},
|
||||
{"Outproxy failure", "Falha no outproxy"},
|
||||
{"Bad outproxy settings", "Configurações ruins de outproxy"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "O host %s não está dentro da rede I2P, mas o outproxy não está ativado"},
|
||||
{"Unknown outproxy URL", "URL de outproxy desconhecida"},
|
||||
{"Cannot resolve upstream proxy", "Não é possível resolver o proxy de entrada"},
|
||||
{"Hostname is too long", "O hostname é muito longo"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Não é possível se conectar ao proxy SOCKS de entrada"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Não é possível negociar com o proxy SOCKS"},
|
||||
{"CONNECT error", "Erro de CONEXÃO"},
|
||||
{"Failed to connect", "Falha ao conectar"},
|
||||
{"SOCKS proxy error", "Erro no proxy SOCKS"},
|
||||
{"Failed to send request to upstream", "Falha ao enviar requisição para o fluxo de entrada"},
|
||||
{"No reply from SOCKS proxy", "Sem resposta do proxy SOCKS"},
|
||||
{"Cannot connect", "Impossível conectar"},
|
||||
{"HTTP out proxy not implemented", "proxy de saída HTTP não implementado"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Não é possível conectar ao proxy HTTP de entrada"},
|
||||
{"Host is down", "Host está desligado"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Não é possível se conectar ao host requisitado, talvez ele esteja for do ar. Por favor, tente novamente mais tarde."},
|
||||
{"", ""},
|
||||
};
|
||||
|
||||
static std::map<std::string, std::vector<std::string>> plurals
|
||||
{
|
||||
{"%d days", {"%d Dia", "%d Dias"}},
|
||||
{"%d hours", {"%d hora", "%d horas"}},
|
||||
{"%d minutes", {"%d minuto", "%d minutos"}},
|
||||
{"%d seconds", {"%d Segundo", "%d segundos"}},
|
||||
{"", {"", ""}},
|
||||
};
|
||||
|
||||
std::shared_ptr<const i2p::i18n::Locale> GetLocale()
|
||||
{
|
||||
return std::make_shared<i2p::i18n::Locale>(language, strings, plurals, [] (int n)->int { return plural(n); });
|
||||
}
|
||||
|
||||
} // language
|
||||
} // i18n
|
||||
} // i2p
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, The PurpleI2P Project
|
||||
* Copyright (c) 2021-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -40,6 +40,7 @@ namespace russian // language namespace
|
||||
{"established", "работает"},
|
||||
{"unknown", "неизвестно"},
|
||||
{"exploratory", "исследовательский"},
|
||||
{"Purple I2P Webconsole", "Веб-консоль Purple I2P"},
|
||||
{"<b>i2pd</b> webconsole", "Веб-консоль <b>i2pd</b>"},
|
||||
{"Main page", "Главная"},
|
||||
{"Router commands", "Команды роутера"},
|
||||
@@ -57,10 +58,11 @@ namespace russian // language namespace
|
||||
{"Unknown", "Неизвестно"},
|
||||
{"Proxy", "Прокси"},
|
||||
{"Mesh", "MESH-сеть"},
|
||||
{"Error", "Ошибка"},
|
||||
{"Clock skew", "Не точное время"},
|
||||
{"Offline", "Оффлайн"},
|
||||
{"Symmetric NAT", "Симметричный NAT"},
|
||||
{"Full cone NAT", "Full cone NAT"},
|
||||
{"No Descriptors", "Нет дескрипторов"},
|
||||
{"Uptime", "В сети"},
|
||||
{"Network status", "Сетевой статус"},
|
||||
{"Network status v6", "Сетевой статус v6"},
|
||||
@@ -116,9 +118,10 @@ namespace russian // language namespace
|
||||
{"Gateway", "Шлюз"},
|
||||
{"TunnelID", "ID туннеля"},
|
||||
{"EndDate", "Заканчивается"},
|
||||
{"not floodfill", "не флудфил"},
|
||||
{"floodfill mode is disabled", "режим флудфила отключен"},
|
||||
{"Queue size", "Размер очереди"},
|
||||
{"Run peer test", "Запустить тестирование"},
|
||||
{"Reload tunnels configuration", "Перезагрузить конфигурацию туннелей"},
|
||||
{"Decline transit tunnels", "Отклонять транзитные туннели"},
|
||||
{"Accept transit tunnels", "Принимать транзитные туннели"},
|
||||
{"Cancel graceful shutdown", "Отменить плавную остановку"},
|
||||
@@ -146,8 +149,8 @@ namespace russian // language namespace
|
||||
{"Destination not found", "Точка назначения не найдена"},
|
||||
{"StreamID can't be null", "StreamID не может быть пустым"},
|
||||
{"Return to destination page", "Вернуться на страницу точки назначения"},
|
||||
{"You will be redirected in 5 seconds", "Вы будете переадресованы через 5 секунд"},
|
||||
{"Transit tunnels count must not exceed 65535", "Число транзитных туннелей не должно превышать 65535"},
|
||||
{"You will be redirected in %d seconds", "Вы будете переадресованы через %d секунд"},
|
||||
{"Transit tunnels count must not exceed %d", "Число транзитных туннелей не должно превышать %d"},
|
||||
{"Back to commands list", "Вернуться к списку команд"},
|
||||
{"Register at reg.i2p", "Зарегистрировать на reg.i2p"},
|
||||
{"Description", "Описание"},
|
||||
@@ -165,32 +168,33 @@ namespace russian // language namespace
|
||||
{"You may try to find this host on jump services below", "Вы можете попробовать найти узел через джамп сервисы ниже"},
|
||||
{"Invalid request", "Некорректный запрос"},
|
||||
{"Proxy unable to parse your request", "Прокси не может разобрать ваш запрос"},
|
||||
{"addresshelper is not supported", "addresshelper не поддерживается"},
|
||||
{"Host", "Узел"},
|
||||
{"added to router's addressbook from helper", "добавлен в адресную книгу роутера через хелпер"},
|
||||
{"Click here to proceed:", "Нажмите здесь, чтобы продолжить:"},
|
||||
{"Continue", "Продолжить"},
|
||||
{"Addresshelper found", "Найден addresshelper"},
|
||||
{"already in router's addressbook", "уже в адресной книге роутера"},
|
||||
{"Click here to update record:", "Нажмите здесь, чтобы обновить запись:"},
|
||||
{"invalid request uri", "некорректный URI запроса"},
|
||||
{"Addresshelper is not supported", "Addresshelper не поддерживается"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "Узел %s <font color=red>уже в адресной книге роутера</font>. <b>Будьте осторожны: источник данной ссылки может быть вредоносным!</b> Нажмите здесь, чтобы обновить запись: <a href=\"%s%s%s&update=true\">Продолжить</a>."},
|
||||
{"Addresshelper forced update rejected", "Принудительное обновление через Addresshelper отклонено"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Чтобы добавить узел <b>%s</b> в адресную книгу роутера, нажмите здесь: <a href=\"%s%s%s\">Продолжить</a>."},
|
||||
{"Addresshelper request", "Запрос добавления Addresshelper"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "Узел %s добавлен в адресную книгу роутера через хелпер. Нажмите здесь, чтобы продолжить: <a href=\"%s\">Продолжить</a>."},
|
||||
{"Addresshelper adding", "Добавление Addresshelper"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "Узел %s <font color=red>уже в адресной книге роутера</font>. Нажмите здесь, чтобы обновить запись: <a href=\"%s%s%s&update=true\">Продолжить</a>."},
|
||||
{"Addresshelper update", "Обновление записи через Addresshelper"},
|
||||
{"Invalid request URI", "Некорректный URI запроса"},
|
||||
{"Can't detect destination host from request", "Не удалось определить адрес назначения из запроса"},
|
||||
{"Outproxy failure", "Ошибка внешнего прокси"},
|
||||
{"bad outproxy settings", "некорректные настройки внешнего прокси"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "не в I2P сети, но внешний прокси не включен"},
|
||||
{"unknown outproxy url", "неизвестный URL внешнего прокси"},
|
||||
{"cannot resolve upstream proxy", "не удается определить вышестоящий прокси"},
|
||||
{"hostname too long", "имя хоста слишком длинное"},
|
||||
{"cannot connect to upstream socks proxy", "не удается подключиться к вышестоящему SOCKS прокси"},
|
||||
{"Cannot negotiate with socks proxy", "Не удается договориться с вышестоящим SOCKS прокси"},
|
||||
{"Bad outproxy settings", "Некорректные настройки внешнего прокси"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Узел %s не в I2P сети, но внешний прокси не включен"},
|
||||
{"Unknown outproxy URL", "Неизвестный URL внешнего прокси"},
|
||||
{"Cannot resolve upstream proxy", "Не удается определить вышестоящий прокси"},
|
||||
{"Hostname is too long", "Имя хоста слишком длинное"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Не удалось подключиться к вышестоящему SOCKS прокси серверу"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Не удается договориться с вышестоящим SOCKS прокси"},
|
||||
{"CONNECT error", "Ошибка CONNECT запроса"},
|
||||
{"Failed to Connect", "Не удалось подключиться"},
|
||||
{"socks proxy error", "ошибка SOCKS прокси"},
|
||||
{"failed to send request to upstream", "не удалось отправить запрос вышестоящему прокси"},
|
||||
{"No Reply From socks proxy", "Нет ответа от SOCKS прокси сервера"},
|
||||
{"cannot connect", "не удалось подключиться"},
|
||||
{"http out proxy not implemented", "поддержка внешнего HTTP прокси сервера не реализована"},
|
||||
{"cannot connect to upstream http proxy", "не удалось подключиться к вышестоящему HTTP прокси серверу"},
|
||||
{"Failed to connect", "Не удалось соединиться"},
|
||||
{"SOCKS proxy error", "Ошибка SOCKS прокси"},
|
||||
{"Failed to send request to upstream", "Не удалось отправить запрос вышестоящему прокси серверу"},
|
||||
{"No reply from SOCKS proxy", "Нет ответа от SOCKS прокси сервера"},
|
||||
{"Cannot connect", "Не удалось подключиться"},
|
||||
{"HTTP out proxy not implemented", "Поддержка внешнего HTTP прокси сервера не реализована"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Не удалось подключиться к вышестоящему HTTP прокси серверу"},
|
||||
{"Host is down", "Узел недоступен"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Не удалось установить соединение к запрошенному узлу, возможно он не в сети. Попробуйте повторить запрос позже."},
|
||||
{"", ""},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, The PurpleI2P Project
|
||||
* Copyright (c) 2022-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -58,7 +58,6 @@ namespace spanish // language namespace
|
||||
{"Unknown", "Desconocido"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Malla"},
|
||||
{"Error", "Error"},
|
||||
{"Clock skew", "Reloj desfasado"},
|
||||
{"Offline", "Desconectado"},
|
||||
{"Symmetric NAT", "NAT simétrico"},
|
||||
@@ -117,7 +116,6 @@ namespace spanish // language namespace
|
||||
{"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"},
|
||||
@@ -147,8 +145,6 @@ namespace spanish // language namespace
|
||||
{"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"},
|
||||
@@ -166,32 +162,24 @@ namespace spanish // language namespace
|
||||
{"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"},
|
||||
{"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"},
|
||||
{"Bad outproxy settings", "Configuración de outproxy incorrecta"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Dominio %s 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 is 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"},
|
||||
{"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."},
|
||||
{"", ""},
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace swedish // language namespace
|
||||
{"unknown", "okänt"},
|
||||
{"exploratory", "utforskande"},
|
||||
{"Purple I2P Webconsole", "Purple I2P Webbkonsoll"},
|
||||
{"<b>i2pd</b> webbkonsoll", "<b>i2pd</b>-Webbkonsoll"},
|
||||
{"<b>i2pd</b> webconsole", "<b>i2pd</b>-Webbkonsoll"},
|
||||
{"Main page", "Huvudsida"},
|
||||
{"Router commands", "Routerkommandon"},
|
||||
{"Local Destinations", "Lokala Platser"},
|
||||
@@ -58,7 +58,6 @@ namespace swedish // language namespace
|
||||
{"Unknown", "Okänt"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Mesh", "Mesh"},
|
||||
{"Error", "Fel"},
|
||||
{"Clock skew", "Tidsförskjutning"},
|
||||
{"Offline", "Nedkopplad"},
|
||||
{"Symmetric NAT", "Symmetrisk NAT"},
|
||||
@@ -117,7 +116,6 @@ namespace swedish // language namespace
|
||||
{"Gateway", "Gateway"},
|
||||
{"TunnelID", "TunnelID"},
|
||||
{"EndDate", "EndDate"},
|
||||
{"not floodfill", "inte Översvämningsfyllare"},
|
||||
{"Queue size", "Köstorlek"},
|
||||
{"Run peer test", "Utför utsiktstest"},
|
||||
{"Decline transit tunnels", "Avvisa förmedlande tunnlar"},
|
||||
@@ -147,8 +145,8 @@ namespace swedish // language namespace
|
||||
{"Destination not found", "Plats hittades ej"},
|
||||
{"StreamID can't be null", "Ström-ID kan inte vara null"},
|
||||
{"Return to destination page", "Återvänd till platssidan"},
|
||||
{"You will be redirected in 5 seconds", "Du omdirigeras inom fem sekunder"},
|
||||
{"Transit tunnels count must not exceed 65535", "Förmedlande tunnlar får inte överstiga 65535"},
|
||||
{"You will be redirected in %d seconds", "Du omdirigeras inom %d sekunder"},
|
||||
{"Transit tunnels count must not exceed %d", "Förmedlande tunnlar får inte överstiga %d"},
|
||||
{"Back to commands list", "Tillbaka till kommandolistan"},
|
||||
{"Register at reg.i2p", "Registrera vid reg.i2p"},
|
||||
{"Description", "Beskrivning"},
|
||||
@@ -166,32 +164,25 @@ namespace swedish // language namespace
|
||||
{"You may try to find this host on jump services below", "Du kan försöka att hitta värden genom hopptjänsterna nedan"},
|
||||
{"Invalid request", "Ogiltig förfrågan"},
|
||||
{"Proxy unable to parse your request", "Proxyt kan inte behandla din förfrågan"},
|
||||
{"addresshelper is not supported", "adresshjälparen stöds ej"},
|
||||
{"Host", "Värd"},
|
||||
{"added to router's addressbook from helper", "tillagd i routerns adressbok från adresshjälparen"},
|
||||
{"Click here to proceed:", "Tryck här för att fortsätta:"},
|
||||
{"Continue", "Fortsätt"},
|
||||
{"Addresshelper found", "Adresshjälpare hittad"},
|
||||
{"already in router's addressbook", "finns redan i routerns adressbok"},
|
||||
{"Click here to update record:", "Tryck här för att uppdatera:"},
|
||||
{"invalid request uri", "ogiltig förfrågnings-URI"},
|
||||
{"Addresshelper is not supported", "Adresshjälparen stöds ej"},
|
||||
{"Invalid request URI", "Ogiltig förfrågnings-URI"},
|
||||
{"Can't detect destination host from request", "Kan inte upptäcka platsvärden från förfrågan"},
|
||||
{"Outproxy failure", "Utproxyfel"},
|
||||
{"bad outproxy settings", "ogiltig utproxyinställning"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "adressen är inte inom I2P-näverket, men utproxy är inte påslaget"},
|
||||
{"unknown outproxy url", "okänt Utproxy-URL"},
|
||||
{"cannot resolve upstream proxy", "hittar inte uppströmsproxyt"},
|
||||
{"hostname too long", "värdnamnet är för långt"},
|
||||
{"cannot connect to upstream socks proxy", "kan inte ansluta till uppströmsproxyt"},
|
||||
{"Cannot negotiate with socks proxy", "Kan inte förhandla med socksproxyt"},
|
||||
{"Bad outproxy settings", "Ogiltig utproxyinställning"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Värd %s är inte inom I2P-näverket, men utproxy är inte påslaget"},
|
||||
{"Unknown outproxy URL", "okänt Utproxy-URL"},
|
||||
{"Cannot resolve upstream proxy", "Hittar inte uppströmsproxyt"},
|
||||
{"Hostname is too long", "Värdnamnet är för långt"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Kan inte ansluta till uppström SOCKS-proxy"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Kan inte förhandla med SOCKSproxyt"},
|
||||
{"CONNECT error", "CONNECT-fel"},
|
||||
{"Failed to Connect", "Anslutningen misslyckades"},
|
||||
{"socks proxy error", "Socksproxyfel"},
|
||||
{"failed to send request to upstream", "förfrågan uppströms kunde ej skickas"},
|
||||
{"No Reply From socks proxy", "Fick inget svar från socksproxyt"},
|
||||
{"cannot connect", "kan inte ansluta"},
|
||||
{"http out proxy not implemented", "HTTP-Utproxy ej implementerat"},
|
||||
{"cannot connect to upstream http proxy", "Kan inte ansluta till uppströms HTTP-proxy"},
|
||||
{"Failed to connect", "Anslutningen misslyckades"},
|
||||
{"SOCKS proxy error", "SOCKSproxyfel"},
|
||||
{"Failed to send request to upstream", "Förfrågan uppströms kunde ej skickas"},
|
||||
{"No reply from SOCKS proxy", "Fick inget svar från SOCKSproxyt"},
|
||||
{"Cannot connect", "Kan inte ansluta"},
|
||||
{"HTTP out proxy not implemented", "HTTP-Utproxy ej implementerat"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Kan inte ansluta till uppströms HTTP-proxy"},
|
||||
{"Host is down", "Värden är nere"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Kan inte ansluta till värden, den kan vara nere. Vänligen försök senare."},
|
||||
{"", ""},
|
||||
@@ -199,10 +190,10 @@ namespace swedish // language namespace
|
||||
|
||||
static std::map<std::string, std::vector<std::string>> plurals
|
||||
{
|
||||
{"%d days", {"%d Dag", "%d Dagar"}},
|
||||
{"%d hours", {"%d Timme", "%d Timmar"}},
|
||||
{"%d minutes", {"%d Minut", "%d Minuter"}},
|
||||
{"%d seconds", {"%d Sekund", "%d Sekunder"}},
|
||||
{"%d days", {"%d dag", "%d dagar"}},
|
||||
{"%d hours", {"%d timme", "%d timmar"}},
|
||||
{"%d minutes", {"%d minut", "%d minuter"}},
|
||||
{"%d seconds", {"%d sekund", "%d sekunder"}},
|
||||
{"", {"", ""}},
|
||||
};
|
||||
|
||||
|
||||
114
i18n/Turkish.cpp
Normal file
114
i18n/Turkish.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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"
|
||||
|
||||
// Turkish localization file
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace i18n
|
||||
{
|
||||
namespace turkish // language namespace
|
||||
{
|
||||
// language name in lowercase
|
||||
static std::string language = "turkish";
|
||||
|
||||
// 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
|
||||
{
|
||||
{"%.2f KiB", "%.2f KiB"},
|
||||
{"%.2f MiB", "%.2f MiB"},
|
||||
{"%.2f GiB", "%.2f GiB"},
|
||||
{"building", "kuruluyor"},
|
||||
{"failed", "başarısız"},
|
||||
{"expiring", "süresi geçiyor"},
|
||||
{"established", "kurulmuş"},
|
||||
{"unknown", "bilinmeyen"},
|
||||
{"Purple I2P Webconsole", "Mor I2P Webkonsolu"},
|
||||
{"<b>i2pd</b> webconsole", "<b>i2pd</b> webkonsolu"},
|
||||
{"Main page", "Ana sayfa"},
|
||||
{"Router commands", "Router komutları"},
|
||||
{"Local Destinations", "Yerel Hedefler"},
|
||||
{"Tunnels", "Tüneller"},
|
||||
{"Transit Tunnels", "Transit Tünelleri"},
|
||||
{"Transports", "Taşıma"},
|
||||
{"I2P tunnels", "I2P tünelleri"},
|
||||
{"SAM sessions", "SAM oturumları"},
|
||||
{"ERROR", "HATA"},
|
||||
{"OK", "TAMAM"},
|
||||
{"Testing", "Test ediliyor"},
|
||||
{"Firewalled", "Güvenlik Duvarı Kısıtlaması"},
|
||||
{"Unknown", "Bilinmeyen"},
|
||||
{"Proxy", "Proxy"},
|
||||
{"Clock skew", "Saat sorunu"},
|
||||
{"Offline", "Çevrimdışı"},
|
||||
{"Symmetric NAT", "Simetrik NAT"},
|
||||
{"Full cone NAT", "Full cone NAT"},
|
||||
{"No Descriptors", "Tanımlayıcı Yok"},
|
||||
{"Uptime", "Bağlantı süresi"},
|
||||
{"Network status", "Ağ durumu"},
|
||||
{"Network status v6", "Ağ durumu v6"},
|
||||
{"Family", "Aile"},
|
||||
{"Tunnel creation success rate", "Tünel oluşturma başarı oranı"},
|
||||
{"Received", "Alındı"},
|
||||
{"%.2f KiB/s", "%.2f KiB/s"},
|
||||
{"Sent", "Gönderildi"},
|
||||
{"Transit", "Transit"},
|
||||
{"Data path", "Veri yolu"},
|
||||
{"Hidden content. Press on text to see.", "Gizlenmiş içerik. Görmek için yazıya tıklayınız."},
|
||||
{"Router Family", "Router Familyası"},
|
||||
{"Decline transit tunnels", "Transit tünellerini reddet"},
|
||||
{"Accept transit tunnels", "Transit tünellerini kabul et"},
|
||||
{"Cancel graceful shutdown", "Düzgün durdurmayı iptal Et"},
|
||||
{"Start graceful shutdown", "Düzgün durdurmayı başlat"},
|
||||
{"Force shutdown", "Durdurmaya zorla"},
|
||||
{"Reload external CSS styles", "Harici CSS stilini yeniden yükle"},
|
||||
{"<b>Note:</b> any action done here are not persistent and not changes your config files.", "<b>Not:</b> burada yapılan ayarların hiçbiri kalıcı değildir ve ayar dosyalarınızı değiştirmez."},
|
||||
{"Logging level", "Kayıt tutma seviyesi"},
|
||||
{"Transit tunnels limit", "Transit tünel limiti"},
|
||||
{"Change", "Değiştir"},
|
||||
{"Change language", "Dil değiştir"},
|
||||
{"no transit tunnels currently built", "kurulmuş bir transit tüneli bulunmamakta"},
|
||||
{"SAM disabled", "SAM devre dışı"},
|
||||
{"no sessions currently running", "hiçbir oturum şu anda çalışmıyor"},
|
||||
{"SAM session not found", "SAM oturumu bulunamadı"},
|
||||
{"SAM Session", "SAM oturumu"},
|
||||
{"Server Tunnels", "Sunucu Tünelleri"},
|
||||
{"Unknown page", "Bilinmeyen sayfa"},
|
||||
{"Invalid token", "Geçersiz token"},
|
||||
{"SUCCESS", "BAŞARILI"},
|
||||
{"", ""},
|
||||
};
|
||||
|
||||
static std::map<std::string, std::vector<std::string>> plurals
|
||||
{
|
||||
{"%d days", {"%d gün", "%d gün"}},
|
||||
{"%d hours", {"%d saat", "%d saat"}},
|
||||
{"%d minutes", {"%d dakika", "%d dakika"}},
|
||||
{"%d seconds", {"%d saniye", "%d saniye"}},
|
||||
{"", {"", ""}},
|
||||
};
|
||||
|
||||
std::shared_ptr<const i2p::i18n::Locale> GetLocale()
|
||||
{
|
||||
return std::make_shared<i2p::i18n::Locale>(language, strings, plurals, [] (int n)->int { return plural(n); });
|
||||
}
|
||||
|
||||
} // language
|
||||
} // i18n
|
||||
} // i2p
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2021-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -40,6 +40,7 @@ namespace turkmen // language namespace
|
||||
{"established", "işleýär"},
|
||||
{"unknown", "näbelli"},
|
||||
{"exploratory", "gözleg"},
|
||||
{"Purple I2P Webconsole", "Web konsoly Purple I2P"},
|
||||
{"<b>i2pd</b> webconsole", "Web konsoly <b>i2pd</b>"},
|
||||
{"Main page", "Esasy sahypa"},
|
||||
{"Router commands", "Marşrutizator buýruklary"},
|
||||
@@ -57,7 +58,6 @@ namespace turkmen // language namespace
|
||||
{"Unknown", "Näbelli"},
|
||||
{"Proxy", "Proksi"},
|
||||
{"Mesh", "MESH-tor"},
|
||||
{"Error", "Ýalňyşlyk"},
|
||||
{"Clock skew", "Takyk wagt däl"},
|
||||
{"Offline", "Awtonom"},
|
||||
{"Symmetric NAT", "Simmetriklik NAT"},
|
||||
@@ -116,7 +116,6 @@ namespace turkmen // language namespace
|
||||
{"Gateway", "Derweze"},
|
||||
{"TunnelID", "Tuneliň ID"},
|
||||
{"EndDate", "Gutarýar"},
|
||||
{"not floodfill", "fludfil däl"},
|
||||
{"Queue size", "Nobatyň ululygy"},
|
||||
{"Run peer test", "Synag başlaň"},
|
||||
{"Decline transit tunnels", "Tranzit tunellerini ret ediň"},
|
||||
@@ -146,8 +145,6 @@ namespace turkmen // language namespace
|
||||
{"Destination not found", "Niýetlenen ýeri tapylmady"},
|
||||
{"StreamID can't be null", "StreamID boş bolup bilmez"},
|
||||
{"Return to destination page", "Barmaly nokadynyň nokadyna gaýdyp geliň"},
|
||||
{"You will be redirected in 5 seconds", "5 sekuntdan soň täzeden ugrukdyrylarsyňyz"},
|
||||
{"Transit tunnels count must not exceed 65535", "Tranzit tagtalaryň sany 65535-den geçmeli däldir"},
|
||||
{"Back to commands list", "Topar sanawyna dolan"},
|
||||
{"Register at reg.i2p", "Reg.i2P-de hasaba duruň"},
|
||||
{"Description", "Beýany"},
|
||||
@@ -165,32 +162,24 @@ namespace turkmen // language namespace
|
||||
{"You may try to find this host on jump services below", "Aşakdaky böküş hyzmatlarynda bu öý eýesini tapmaga synanyşyp bilersiňiz"},
|
||||
{"Invalid request", "Nädogry haýyş"},
|
||||
{"Proxy unable to parse your request", "Proksi haýyşyňyzy derňäp bilmeýär"},
|
||||
{"addresshelper is not supported", "Salgylandyryjy goldanok"},
|
||||
{"Host", "Adres"},
|
||||
{"added to router's addressbook from helper", "marşruteriň adresini kömekçiden goşdy"},
|
||||
{"Click here to proceed:", "Dowam etmek bu ýerde basyň:"},
|
||||
{"Continue", "Dowam et"},
|
||||
{"Addresshelper found", "Forgelper tapyldy"},
|
||||
{"already in router's addressbook", "marşruteriň adres kitaby"},
|
||||
{"Click here to update record:", "Recordazgyny täzelemek üçin bu ýerde basyň:"},
|
||||
{"invalid request uri", "nädogry haýyş URI"},
|
||||
{"Invalid request URI", "Nädogry haýyş URI"},
|
||||
{"Can't detect destination host from request", "Haýyşdan barmaly ýerini tapyp bilemok"},
|
||||
{"Outproxy failure", "Daşarky proksi ýalňyşlyk"},
|
||||
{"bad outproxy settings", "daşarky daşarky proksi sazlamalary nädogry"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "I2P torunda däl, ýöne daşarky proksi goşulmaýar"},
|
||||
{"unknown outproxy url", "näbelli daşarky proksi URL"},
|
||||
{"cannot resolve upstream proxy", "has ýokary proksi kesgitläp bilmeýär"},
|
||||
{"hostname too long", "hoster eýesi ady gaty uzyn"},
|
||||
{"cannot connect to upstream socks proxy", "ýokary jorap SOCKS proksi bilen birigip bolmaýar"},
|
||||
{"Cannot negotiate with socks proxy", "Iň ýokary jorap SOCKS proksi bilen ylalaşyp bilmeýärler"},
|
||||
{"Bad outproxy settings", "Daşarky Daşarky proksi sazlamalary nädogry"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Adres %s I2P torunda däl, ýöne daşarky proksi goşulmaýar"},
|
||||
{"Unknown outproxy URL", "Näbelli daşarky proksi URL"},
|
||||
{"Cannot resolve upstream proxy", "Has ýokary proksi kesgitläp bilmeýär"},
|
||||
{"Hostname is too long", "Hoster eýesi ady gaty uzyn"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Ýokary jorap SOCKS proksi bilen birigip bolmaýar"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Iň ýokary jorap SOCKS proksi bilen ylalaşyp bilmeýärler"},
|
||||
{"CONNECT error", "Bagyr haýyşy säwligi"},
|
||||
{"Failed to Connect", "Birikdirip bilmedi"},
|
||||
{"socks proxy error", "socks proksi ýalňyşlygy"},
|
||||
{"failed to send request to upstream", "öý eýesi proksi üçin haýyş iberip bilmedi"},
|
||||
{"No Reply From socks proxy", "Jorap proksi serwerinden hiç hili jogap ýok"},
|
||||
{"cannot connect", "birikdirip bilmedi"},
|
||||
{"http out proxy not implemented", "daşarky HTTP proksi serwerini goldamak amala aşyrylmaýar"},
|
||||
{"cannot connect to upstream http proxy", "ýokary akym HTTP proksi serwerine birigip bilmedi"},
|
||||
{"Failed to connect", "Birikdirip bilmedi"},
|
||||
{"SOCKS proxy error", "SOCKS proksi ýalňyşlygy"},
|
||||
{"Failed to send request to upstream", "Öý eýesi proksi üçin haýyş iberip bilmedi"},
|
||||
{"No reply from SOCKS proxy", "Jorap SOCKS proksi serwerinden hiç hili jogap ýok"},
|
||||
{"Cannot connect", "Birikdirip bilmedi"},
|
||||
{"HTTP out proxy not implemented", "Daşarky HTTP proksi serwerini goldamak amala aşyrylmaýar"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Ýokary jorap HTTP proksi bilen birigip bolmaýar"},
|
||||
{"Host is down", "Salgy elýeterli däl"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Talap edilýän salgyda birikmäni gurup bilmedim, onlaýn bolup bilmez. Soňra haýyşy soň gaýtalamaga synanyşyň."},
|
||||
{"", ""},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, The PurpleI2P Project
|
||||
* Copyright (c) 2021-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -40,6 +40,7 @@ namespace ukrainian // language namespace
|
||||
{"established", "працює"},
|
||||
{"unknown", "невідомо"},
|
||||
{"exploratory", "дослідницький"},
|
||||
{"Purple I2P Webconsole", "Веб-консоль Purple I2P"},
|
||||
{"<b>i2pd</b> webconsole", "Веб-консоль <b>i2pd</b>"},
|
||||
{"Main page", "Головна"},
|
||||
{"Router commands", "Команди маршрутизатора"},
|
||||
@@ -57,10 +58,11 @@ namespace ukrainian // language namespace
|
||||
{"Unknown", "Невідомо"},
|
||||
{"Proxy", "Проксі"},
|
||||
{"Mesh", "MESH-мережа"},
|
||||
{"Error", "Помилка"},
|
||||
{"Clock skew", "Неточний час"},
|
||||
{"Offline", "Офлайн"},
|
||||
{"Symmetric NAT", "Симетричний NAT"},
|
||||
{"Full cone NAT", "Повний NAT"},
|
||||
{"No Descriptors", "Немає Описів"},
|
||||
{"Uptime", "У мережі"},
|
||||
{"Network status", "Мережевий статус"},
|
||||
{"Network status v6", "Мережевий статус v6"},
|
||||
@@ -116,9 +118,10 @@ namespace ukrainian // language namespace
|
||||
{"Gateway", "Шлюз"},
|
||||
{"TunnelID", "ID тунеля"},
|
||||
{"EndDate", "Закінчується"},
|
||||
{"not floodfill", "не флудфіл"},
|
||||
{"floodfill mode is disabled", "режим floodfill вимкнено"},
|
||||
{"Queue size", "Розмір черги"},
|
||||
{"Run peer test", "Запустити тестування"},
|
||||
{"Reload tunnels configuration", "Перезавантажити налаштування тунелів"},
|
||||
{"Decline transit tunnels", "Відхиляти транзитні тунелі"},
|
||||
{"Accept transit tunnels", "Ухвалювати транзитні тунелі"},
|
||||
{"Cancel graceful shutdown", "Скасувати плавну зупинку"},
|
||||
@@ -146,8 +149,8 @@ namespace ukrainian // language namespace
|
||||
{"Destination not found", "Точка призначення не знайдена"},
|
||||
{"StreamID can't be null", "Ідентифікатор потоку не може бути порожнім"},
|
||||
{"Return to destination page", "Повернутися на сторінку точки призначення"},
|
||||
{"You will be redirected in 5 seconds", "Ви будете переадресовані через 5 секунд"},
|
||||
{"Transit tunnels count must not exceed 65535", "Кількість транзитних тунелів не повинна перевищувати 65535"},
|
||||
{"You will be redirected in %d seconds", "Ви будете переадресовані через %d секунд"},
|
||||
{"Transit tunnels count must not exceed %d", "Кількість транзитних тунелів не повинна перевищувати %d"},
|
||||
{"Back to commands list", "Повернутися до списку команд"},
|
||||
{"Register at reg.i2p", "Зареєструвати на reg.i2p"},
|
||||
{"Description", "Опис"},
|
||||
@@ -165,32 +168,33 @@ namespace ukrainian // language namespace
|
||||
{"You may try to find this host on jump services below", "Ви можете спробувати знайти дану адресу на джамп сервісах нижче"},
|
||||
{"Invalid request", "Некоректний запит"},
|
||||
{"Proxy unable to parse your request", "Проксі не може розібрати ваш запит"},
|
||||
{"addresshelper is not supported", "addresshelper не підтримується"},
|
||||
{"Host", "Адреса"},
|
||||
{"added to router's addressbook from helper", "доданий в адресну книгу маршрутизатора через хелпер"},
|
||||
{"Click here to proceed:", "Натисніть тут щоб продовжити:"},
|
||||
{"Continue", "Продовжити"},
|
||||
{"Addresshelper found", "Знайдено addresshelper"},
|
||||
{"already in router's addressbook", "вже в адресній книзі маршрутизатора"},
|
||||
{"Click here to update record:", "Натисніть тут щоб оновити запис:"},
|
||||
{"invalid request uri", "некоректний URI запиту"},
|
||||
{"Addresshelper is not supported", "Адресна книга не підтримується"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "Хост %s <font color=red>вже в адресній книзі маршрутизатора</font>. <b>Будьте обережні: джерело цієї адреси може зашкодити!</b> Натисніть тут, щоб оновити запис: <a href=\"%s%s%s&update=true\">Продовжити</a>."},
|
||||
{"Addresshelper forced update rejected", "Адресна книга відхилила примусове оновлення"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Щоб додати хост <b>%s</b> в адресі маршрутизатора, натисніть тут: <a href=\"%s%s%s\">Продовжити</a>."},
|
||||
{"Addresshelper request", "Запит на адресну сторінку"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "Хост %s доданий в адресну книгу маршрутизатора від помічника. Натисніть тут, щоб продовжити: <a href=\"%s\">Продовжити</a>."},
|
||||
{"Addresshelper adding", "Адреса додана"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "Хост %s <font color=red>вже в адресній книзі маршрутизатора</font>. Натисніть тут, щоб оновити запис: <a href=\"%s%s%s&update=true\">Продовжити</a>."},
|
||||
{"Addresshelper update", "Оновлення адресної книги"},
|
||||
{"Invalid request URI", "Некоректний URI запиту"},
|
||||
{"Can't detect destination host from request", "Не вдалось визначити адресу призначення з запиту"},
|
||||
{"Outproxy failure", "Помилка зовнішнього проксі"},
|
||||
{"bad outproxy settings", "некоректні налаштування зовнішнього проксі"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "не в I2P мережі, але зовнішній проксі не включений"},
|
||||
{"unknown outproxy url", "невідомий URL зовнішнього проксі"},
|
||||
{"cannot resolve upstream proxy", "не вдається визначити висхідний проксі"},
|
||||
{"hostname too long", "ім'я вузла надто довге"},
|
||||
{"cannot connect to upstream socks proxy", "не вдається підключитися до висхідного SOCKS проксі"},
|
||||
{"Cannot negotiate with socks proxy", "Не вдається домовитися з висхідним SOCKS проксі"},
|
||||
{"Bad outproxy settings", "Некоректні налаштування зовнішнього проксі"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Адрес %s не в I2P мережі, але зовнішній проксі не включений"},
|
||||
{"Unknown outproxy URL", "Невідомий URL зовнішнього проксі"},
|
||||
{"Cannot resolve upstream proxy", "Не вдається визначити висхідний проксі"},
|
||||
{"Hostname is too long", "Ім'я вузла надто довге"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Не вдалося підключитися до висхідного SOCKS проксі сервера"},
|
||||
{"Cannot negotiate with SOCKS proxy", "Не вдається домовитися з висхідним SOCKS проксі"},
|
||||
{"CONNECT error", "Помилка CONNECT запиту"},
|
||||
{"Failed to Connect", "Не вдалося підключитися"},
|
||||
{"socks proxy error", "помилка SOCKS проксі"},
|
||||
{"failed to send request to upstream", "не вдалося відправити запит висхідному проксі"},
|
||||
{"No Reply From socks proxy", "Немає відповіді від SOCKS проксі сервера"},
|
||||
{"cannot connect", "не вдалося підключитися"},
|
||||
{"http out proxy not implemented", "підтримка зовнішнього HTTP проксі сервера не реалізована"},
|
||||
{"cannot connect to upstream http proxy", "не вдалося підключитися до висхідного HTTP проксі сервера"},
|
||||
{"Failed to connect", "Не вдалося підключитися"},
|
||||
{"SOCKS proxy error", "Помилка SOCKS проксі"},
|
||||
{"Failed to send request to upstream", "Не вдалося відправити запит висхідному проксі"},
|
||||
{"No reply from SOCKS proxy", "Немає відповіді від SOCKS проксі сервера"},
|
||||
{"Cannot connect", "Не вдалося підключитися"},
|
||||
{"HTTP out proxy not implemented", "Підтримка зовнішнього HTTP проксі сервера не реалізована"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Не вдалося підключитися до висхідного HTTP проксі сервера"},
|
||||
{"Host is down", "Вузол недоступний"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Не вдалося встановити з'єднання до запитаного вузла, можливо він не в мережі. Спробуйте повторити запит пізніше."},
|
||||
{"", ""},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2021-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -40,6 +40,7 @@ namespace uzbek // language namespace
|
||||
{"established", "aloqa o'rnatildi"},
|
||||
{"unknown", "noma'lum"},
|
||||
{"exploratory", "tadqiqiy"},
|
||||
{"Purple I2P Webconsole", "Veb-konsoli Purple I2P"},
|
||||
{"<b>i2pd</b> webconsole", "<b>i2pd</b> veb-konsoli"},
|
||||
{"Main page", "Asosiy sahifa"},
|
||||
{"Router commands", "Router buyruqlari"},
|
||||
@@ -57,10 +58,11 @@ namespace uzbek // language namespace
|
||||
{"Unknown", "Notanish"},
|
||||
{"Proxy", "Proksi"},
|
||||
{"Mesh", "Mesh To'r"},
|
||||
{"Error", "Xato"},
|
||||
{"Clock skew", "Aniq vaqt emas"},
|
||||
{"Offline", "Oflayn"},
|
||||
{"Symmetric NAT", "Simmetrik NAT"},
|
||||
{"Full cone NAT", "Full cone NAT"},
|
||||
{"No Descriptors", "Deskriptorlar yo'q"},
|
||||
{"Uptime", "Ish vaqti"},
|
||||
{"Network status", "Tarmoq holati"},
|
||||
{"Network status v6", "Tarmoq holati v6"},
|
||||
@@ -116,9 +118,10 @@ namespace uzbek // language namespace
|
||||
{"Gateway", "Kirish yo'li"},
|
||||
{"TunnelID", "TunnelID"},
|
||||
{"EndDate", "Tugash Sanasi"},
|
||||
{"not floodfill", "floodfill emas"},
|
||||
{"floodfill mode is disabled", "floodfill rejimi o'chirilgan"},
|
||||
{"Queue size", "Navbat hajmi"},
|
||||
{"Run peer test", "Sinovni boshlang"},
|
||||
{"Reload tunnels configuration", "Tunnel konfiguratsiyasini qayta yuklash"},
|
||||
{"Decline transit tunnels", "Tranzit tunnellarini rad etish"},
|
||||
{"Accept transit tunnels", "Tranzit tunnellarni qabul qilish"},
|
||||
{"Cancel graceful shutdown", "Yumshoq to'xtashni bekor qilish"},
|
||||
@@ -146,8 +149,8 @@ namespace uzbek // language namespace
|
||||
{"Destination not found", "Yo'nalish topilmadi"},
|
||||
{"StreamID can't be null", "StreamID bo'sh bo'lishi mumkin emas"},
|
||||
{"Return to destination page", "Manzilgoh sahifasiga qaytish"},
|
||||
{"You will be redirected in 5 seconds", "Siz 5 soniya ichida qayta yo'naltirilasiz"},
|
||||
{"Transit tunnels count must not exceed 65535", "Tranzit tunnellar soni 65535 dan oshmasligi kerak"},
|
||||
{"You will be redirected in %d seconds", "Siz %d soniyadan so‘ng boshqa yo‘nalishga yo‘naltirilasiz"},
|
||||
{"Transit tunnels count must not exceed %d", "Tranzit tunnellar soni %d dan oshmasligi kerak"},
|
||||
{"Back to commands list", "Buyruqlar ro'yxatiga qaytish"},
|
||||
{"Register at reg.i2p", "Reg.i2p-da ro'yxatdan o'ting"},
|
||||
{"Description", "Tavsif"},
|
||||
@@ -165,32 +168,33 @@ namespace uzbek // language namespace
|
||||
{"You may try to find this host on jump services below", "Siz xost quyida o'tish xizmatlari orqali topishga harakat qilishingiz mumkin"},
|
||||
{"Invalid request", "Noto‘g‘ri so‘rov"},
|
||||
{"Proxy unable to parse your request", "Proksi sizning so'rovingizni aniqlab ololmayapti"},
|
||||
{"addresshelper is not supported", "addresshelper qo'llab -quvvatlanmaydi"},
|
||||
{"Host", "Xost"},
|
||||
{"added to router's addressbook from helper", "'helper'dan routerning 'addressbook'ga qo'shildi"},
|
||||
{"Click here to proceed:", "Davom etish uchun shu yerni bosing:"},
|
||||
{"Continue", "Davom etish"},
|
||||
{"Addresshelper found", "Addresshelper topildi"},
|
||||
{"already in router's addressbook", "allaqachon 'addressbook'da yozilgan"},
|
||||
{"Click here to update record:", "Yozuvni yangilash uchun shu yerni bosing:"},
|
||||
{"invalid request uri", "noto'g'ri URI so'rovi"},
|
||||
{"Addresshelper is not supported", "Addresshelper qo'llab-quvvatlanmaydi"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. <b>Be careful: source of this URL may be harmful!</b> Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "%s xosti <font color=red>allaqachon routerning manzillar kitobida</font>. <b>Ehtiyot bo'ling: bu URL manbasi zararli bo'lishi mumkin!</b> Yozuvni yangilash uchun bu yerni bosing: <a href=\"%s%s%s&update=true\">Davom etish</a>."},
|
||||
{"Addresshelper forced update rejected", "Addresshelperni majburiy yangilash rad etildi"},
|
||||
{"To add host <b>%s</b> in router's addressbook, click here: <a href=\"%s%s%s\">Continue</a>.", "Routerning manzillar kitobiga <b>%s</b> xostini qo'shish uchun bu yerni bosing: <a href=\"%s%s%s\">Davom etish</a>."},
|
||||
{"Addresshelper request", "Addresshelper so'rovi"},
|
||||
{"Host %s added to router's addressbook from helper. Click here to proceed: <a href=\"%s\">Continue</a>.", "Yordamchidan router manzillar kitobiga %s xost qo‘shildi. Davom etish uchun bu yerga bosing: <a href=\"%s\">Davom etish</a>."},
|
||||
{"Addresshelper adding", "Addresshelperni qo'shish"},
|
||||
{"Host %s is <font color=red>already in router's addressbook</font>. Click here to update record: <a href=\"%s%s%s&update=true\">Continue</a>.", "%s xosti <font color=red>allaqachon routerning manzillar kitobida</font>. Yozuvni yangilash uchun shu yerni bosing: <a href=\"%s%s%s&update=true\">Davom etish</a>."},
|
||||
{"Addresshelper update", "Addresshelperni yangilash"},
|
||||
{"Invalid request URI", "Noto'g'ri URI so'rovi"},
|
||||
{"Can't detect destination host from request", "So‘rov orqali manzil xostini aniqlab bo'lmayapti"},
|
||||
{"Outproxy failure", "Tashqi proksi muvaffaqiyatsizligi"},
|
||||
{"bad outproxy settings", "noto'g'ri tashqi proksi-server sozlamalari"},
|
||||
{"not inside I2P network, but outproxy is not enabled", "I2P tarmog'ida emas, lekin tashqi proksi yoqilmagan"},
|
||||
{"unknown outproxy url", "noma'lum outproxy url"},
|
||||
{"cannot resolve upstream proxy", "yuqoridagi 'proxy-server'ni aniqlab olib bolmayapti"},
|
||||
{"hostname too long", "xost nomi juda uzun"},
|
||||
{"cannot connect to upstream socks proxy", "yuqori 'socks proxy'ga ulanib bo'lmayapti"},
|
||||
{"Cannot negotiate with socks proxy", "'Socks proxy' bilan muzokara olib bo'lmaydi"},
|
||||
{"Bad outproxy settings", "Noto'g'ri tashqi proksi-server sozlamalari"},
|
||||
{"Host %s is not inside I2P network, but outproxy is not enabled", "Xost %s I2P tarmog'ida emas, lekin tashqi proksi yoqilmagan"},
|
||||
{"Unknown outproxy URL", "Noma'lum outproxy URL"},
|
||||
{"Cannot resolve upstream proxy", "Yuqoridagi 'proxy-server'ni aniqlab olib bolmayapti"},
|
||||
{"Hostname is too long", "Xost nomi juda uzun"},
|
||||
{"Cannot connect to upstream SOCKS proxy", "Yuqori 'SOCKS proxy'ga ulanib bo'lmayapti"},
|
||||
{"Cannot negotiate with SOCKS proxy", "'SOCKS proxy' bilan muzokara olib bo'lmaydi"},
|
||||
{"CONNECT error", "CONNECT xatosi"},
|
||||
{"Failed to Connect", "Ulanib bo'lmayapti"},
|
||||
{"socks proxy error", "'socks proxy' xatosi"},
|
||||
{"failed to send request to upstream", "yuqori http proksi-serveriga so'rovni uborib bo'lmadi"},
|
||||
{"No Reply From socks proxy", "'Socks proxy'dan javob yo'q"},
|
||||
{"cannot connect", "ulanib bo'lmaydi"},
|
||||
{"http out proxy not implemented", "tashqi HTTP proksi-serverni qo'llab-quvvatlash amalga oshirilmagan"},
|
||||
{"cannot connect to upstream http proxy", "yuqori http 'proxy-server'iga ulanib bo'lmayapti"},
|
||||
{"Failed to connect", "Ulanib bo'lmayapti"},
|
||||
{"SOCKS proxy error", "'SOCKS proxy' xatosi"},
|
||||
{"Failed to send request to upstream", "Yuqori proksi-serveriga so'rovni uborib bo'lmadi"},
|
||||
{"No reply from SOCKS proxy", "'SOCKS proxy'dan javob yo'q"},
|
||||
{"Cannot connect", "Ulanib bo'lmaydi"},
|
||||
{"HTTP out proxy not implemented", "Tashqi HTTP proksi-serverni qo'llab-quvvatlash amalga oshirilmagan"},
|
||||
{"Cannot connect to upstream HTTP proxy", "Yuqori 'HTTP proxy'ga ulanib bo'lmayapti"},
|
||||
{"Host is down", "Xost ishlamayapti"},
|
||||
{"Can't create connection to requested host, it may be down. Please try again later.", "Talab qilingan xost bilan aloqa o'rnatilmadi, u ishlamay qolishi mumkin. Iltimos keyinroq qayta urinib ko'ring."},
|
||||
{"", ""},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -45,7 +45,7 @@ namespace config {
|
||||
("logclftime", bool_switch()->default_value(false), "Write full CLF-formatted date and time to log (default: disabled, write only time)")
|
||||
("family", value<std::string>()->default_value(""), "Specify a family, router belongs to")
|
||||
("datadir", value<std::string>()->default_value(""), "Path to storage of i2pd data (RI, keys, peer profiles, ...)")
|
||||
("host", value<std::string>()->default_value("0.0.0.0"), "External IP")
|
||||
("host", value<std::string>()->default_value(""), "External IP")
|
||||
("ifname", value<std::string>()->default_value(""), "Network interface to bind to")
|
||||
("ifname4", value<std::string>()->default_value(""), "Network interface to bind to for ipv4")
|
||||
("ifname6", value<std::string>()->default_value(""), "Network interface to bind to for ipv6")
|
||||
@@ -95,6 +95,7 @@ namespace config {
|
||||
("http.hostname", value<std::string>()->default_value("localhost"), "Expected hostname for WebUI")
|
||||
("http.webroot", value<std::string>()->default_value("/"), "WebUI root path (default: / )")
|
||||
("http.lang", value<std::string>()->default_value("english"), "WebUI language (default: english )")
|
||||
("http.showTotalTCSR", value<bool>()->default_value(false), "Show additional value with total TCSR since router's start (default: false)")
|
||||
;
|
||||
|
||||
options_description httpproxy("HTTP Proxy options");
|
||||
@@ -148,7 +149,8 @@ namespace config {
|
||||
sam.add_options()
|
||||
("sam.enabled", value<bool>()->default_value(true), "Enable or disable SAM Application bridge")
|
||||
("sam.address", value<std::string>()->default_value("127.0.0.1"), "SAM listen address")
|
||||
("sam.port", value<uint16_t>()->default_value(7656), "SAM listen port")
|
||||
("sam.port", value<uint16_t>()->default_value(7656), "SAM listen TCP port")
|
||||
("sam.portudp", value<uint16_t>()->default_value(0), "SAM listen UDP port")
|
||||
("sam.singlethread", value<bool>()->default_value(true), "Sessions run in the SAM bridge's thread")
|
||||
;
|
||||
|
||||
@@ -214,10 +216,11 @@ namespace config {
|
||||
"https://reseed.onion.im/,"
|
||||
"https://i2pseed.creativecowpat.net:8443/,"
|
||||
"https://reseed.i2pgit.org/,"
|
||||
"https://i2p.novg.net/,"
|
||||
"https://banana.incognet.io/,"
|
||||
"https://reseed-pl.i2pd.xyz/,"
|
||||
"https://www2.mk16.de/"
|
||||
"https://www2.mk16.de/,"
|
||||
"https://i2p.ghativega.in/,"
|
||||
"https://i2p.novg.net/"
|
||||
), "Reseed URLs, separated by comma")
|
||||
("reseed.yggurls", value<std::string>()->default_value(
|
||||
"http://[324:71e:281a:9ed3::ace]:7070/,"
|
||||
@@ -284,7 +287,7 @@ namespace config {
|
||||
|
||||
options_description nettime("Time sync options");
|
||||
nettime.add_options()
|
||||
("nettime.enabled", value<bool>()->default_value(false), "Disable time sync (default: disabled)")
|
||||
("nettime.enabled", value<bool>()->default_value(false), "Enable NTP time sync (default: disabled)")
|
||||
("nettime.ntpservers", value<std::string>()->default_value(
|
||||
"0.pool.ntp.org,"
|
||||
"1.pool.ntp.org,"
|
||||
|
||||
@@ -399,6 +399,11 @@ namespace client
|
||||
|
||||
void LeaseSetDestination::HandleDatabaseStoreMessage (const uint8_t * buf, size_t len)
|
||||
{
|
||||
if (len < DATABASE_STORE_HEADER_SIZE)
|
||||
{
|
||||
LogPrint (eLogError, "Destination: Database store msg is too short ", len);
|
||||
return;
|
||||
}
|
||||
uint32_t replyToken = bufbe32toh (buf + DATABASE_STORE_REPLY_TOKEN_OFFSET);
|
||||
size_t offset = DATABASE_STORE_HEADER_SIZE;
|
||||
if (replyToken)
|
||||
@@ -406,6 +411,11 @@ namespace client
|
||||
LogPrint (eLogInfo, "Destination: Reply token is ignored for DatabaseStore");
|
||||
offset += 36;
|
||||
}
|
||||
if (offset > len || len > i2p::data::MAX_LS_BUFFER_SIZE + offset)
|
||||
{
|
||||
LogPrint (eLogError, "Destination: Database store message is too long ", len);
|
||||
return;
|
||||
}
|
||||
i2p::data::IdentHash key (buf + DATABASE_STORE_KEY_OFFSET);
|
||||
std::shared_ptr<i2p::data::LeaseSet> leaseSet;
|
||||
switch (buf[DATABASE_STORE_TYPE_OFFSET])
|
||||
@@ -467,12 +477,15 @@ namespace client
|
||||
{
|
||||
auto ls2 = std::make_shared<i2p::data::LeaseSet2> (buf + offset, len - offset,
|
||||
it2->second->requestedBlindedKey, m_LeaseSetPrivKey ? ((const uint8_t *)*m_LeaseSetPrivKey) : nullptr , GetPreferredCryptoType ());
|
||||
if (ls2->IsValid ())
|
||||
if (ls2->IsValid () && !ls2->IsExpired ())
|
||||
{
|
||||
leaseSet = ls2;
|
||||
std::lock_guard<std::mutex> lock(m_RemoteLeaseSetsMutex);
|
||||
m_RemoteLeaseSets[ls2->GetIdentHash ()] = ls2; // ident is not key
|
||||
m_RemoteLeaseSets[key] = ls2; // also store as key for next lookup
|
||||
leaseSet = ls2;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Destination: New remote encrypted LeaseSet2 failed");
|
||||
}
|
||||
else
|
||||
LogPrint (eLogInfo, "Destination: Couldn't find request for encrypted LeaseSet2");
|
||||
@@ -763,9 +776,17 @@ namespace client
|
||||
request->requestTime = ts;
|
||||
if (!SendLeaseSetRequest (dest, floodfill, request))
|
||||
{
|
||||
// request failed
|
||||
m_LeaseSetRequests.erase (ret.first);
|
||||
if (requestComplete) requestComplete (nullptr);
|
||||
// try another
|
||||
LogPrint (eLogWarning, "Destination: Couldn't send LeaseSet request to ", floodfill->GetIdentHash ().ToBase64 (), ". Trying another");
|
||||
request->excluded.insert (floodfill->GetIdentHash ());
|
||||
floodfill = i2p::data::netdb.GetClosestFloodfill (dest, request->excluded);
|
||||
if (!SendLeaseSetRequest (dest, floodfill, request))
|
||||
{
|
||||
// request failed
|
||||
LogPrint (eLogWarning, "Destination: LeaseSet request for ", dest.ToBase32 (), " was not sent");
|
||||
m_LeaseSetRequests.erase (ret.first);
|
||||
if (requestComplete) requestComplete (nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // duplicate
|
||||
@@ -792,11 +813,11 @@ namespace client
|
||||
std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request)
|
||||
{
|
||||
if (!request->replyTunnel || !request->replyTunnel->IsEstablished ())
|
||||
request->replyTunnel = m_Pool->GetNextInboundTunnel (nullptr, nextFloodfill->GetCompatibleTransports (true));
|
||||
if (!request->replyTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no inbound tunnels found");
|
||||
request->replyTunnel = m_Pool->GetNextInboundTunnel (nullptr, nextFloodfill->GetCompatibleTransports (false)); // outbound from floodfill
|
||||
if (!request->replyTunnel) LogPrint (eLogWarning, "Destination: Can't send LeaseSet request, no compatible inbound tunnels found");
|
||||
if (!request->outboundTunnel || !request->outboundTunnel->IsEstablished ())
|
||||
request->outboundTunnel = m_Pool->GetNextOutboundTunnel (nullptr, nextFloodfill->GetCompatibleTransports (false));
|
||||
if (!request->outboundTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no outbound tunnels found");
|
||||
request->outboundTunnel = m_Pool->GetNextOutboundTunnel (nullptr, nextFloodfill->GetCompatibleTransports (true)); // inbound from floodfill
|
||||
if (!request->outboundTunnel) LogPrint (eLogWarning, "Destination: Can't send LeaseSet request, no compatible outbound tunnels found");
|
||||
|
||||
if (request->replyTunnel && request->outboundTunnel)
|
||||
{
|
||||
@@ -1152,11 +1173,11 @@ namespace client
|
||||
},
|
||||
dest, port);
|
||||
while (!done)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> l(streamRequestCompleteMutex);
|
||||
if (!done)
|
||||
streamRequestComplete.wait (l);
|
||||
}
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -335,7 +335,8 @@ namespace garlic
|
||||
case eECIESx25519BlkAckRequest:
|
||||
{
|
||||
LogPrint (eLogDebug, "Garlic: Ack request");
|
||||
m_AckRequests.push_back ({receiveTagset->GetTagSetID (), index});
|
||||
if (receiveTagset)
|
||||
m_AckRequests.push_back ({receiveTagset->GetTagSetID (), index});
|
||||
break;
|
||||
}
|
||||
case eECIESx25519BlkTermination:
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace data
|
||||
if (m_IsDirty) deflateReset (&m_Deflator);
|
||||
m_IsDirty = true;
|
||||
size_t offset = 0;
|
||||
int err;
|
||||
int err = 0;
|
||||
for (const auto& it: bufs)
|
||||
{
|
||||
m_Deflator.next_in = const_cast<uint8_t *>(it.first);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -93,15 +93,18 @@ namespace http
|
||||
std::size_t pos_c = 0; /* < work position */
|
||||
if(url.at(0) != '/' || pos_p > 0) {
|
||||
std::size_t pos_s = 0;
|
||||
|
||||
/* schema */
|
||||
pos_c = url.find("://");
|
||||
if (pos_c != std::string::npos) {
|
||||
schema = url.substr(0, pos_c);
|
||||
pos_p = pos_c + 3;
|
||||
}
|
||||
|
||||
/* user[:pass] */
|
||||
pos_s = url.find('/', pos_p); /* find first slash */
|
||||
pos_c = url.find('@', pos_p); /* find end of 'user' or 'user:pass' part */
|
||||
|
||||
if (pos_c != std::string::npos && (pos_s == std::string::npos || pos_s > pos_c)) {
|
||||
std::size_t delim = url.find(':', pos_p);
|
||||
if (delim && delim != std::string::npos && delim < pos_c) {
|
||||
@@ -113,21 +116,28 @@ namespace http
|
||||
}
|
||||
pos_p = pos_c + 1;
|
||||
}
|
||||
|
||||
/* hostname[:port][/path] */
|
||||
if (url[pos_p] == '[') // ipv6
|
||||
if (url.at(pos_p) == '[') // ipv6
|
||||
{
|
||||
auto pos_b = url.find(']', pos_p);
|
||||
if (pos_b == std::string::npos) return false;
|
||||
ipv6 = true;
|
||||
pos_c = url.find_first_of(":/", pos_b);
|
||||
}
|
||||
else
|
||||
pos_c = url.find_first_of(":/", pos_p);
|
||||
|
||||
if (pos_c == std::string::npos) {
|
||||
/* only hostname, without post and path */
|
||||
host = url.substr(pos_p, std::string::npos);
|
||||
host = ipv6 ?
|
||||
url.substr(pos_p + 1, url.length() - 1) :
|
||||
url.substr(pos_p, std::string::npos);
|
||||
return true;
|
||||
} else if (url.at(pos_c) == ':') {
|
||||
host = url.substr(pos_p, pos_c - pos_p);
|
||||
host = ipv6 ?
|
||||
url.substr(pos_p + 1, pos_c - pos_p - 2) :
|
||||
url.substr(pos_p, pos_c - pos_p);
|
||||
/* port[/path] */
|
||||
pos_p = pos_c + 1;
|
||||
pos_c = url.find('/', pos_p);
|
||||
@@ -147,7 +157,9 @@ namespace http
|
||||
pos_p = pos_c;
|
||||
} else {
|
||||
/* start of path part found */
|
||||
host = url.substr(pos_p, pos_c - pos_p);
|
||||
host = ipv6 ?
|
||||
url.substr(pos_p + 1, pos_c - pos_p - 2) :
|
||||
url.substr(pos_p, pos_c - pos_p);
|
||||
pos_p = pos_c;
|
||||
}
|
||||
}
|
||||
@@ -160,6 +172,7 @@ namespace http
|
||||
return true;
|
||||
} else if (url.at(pos_c) == '?') {
|
||||
/* found query part */
|
||||
hasquery = true;
|
||||
path = url.substr(pos_p, pos_c - pos_p);
|
||||
pos_p = pos_c + 1;
|
||||
pos_c = url.find('#', pos_p);
|
||||
@@ -211,15 +224,25 @@ namespace http
|
||||
} else if (user != "") {
|
||||
out += user + "@";
|
||||
}
|
||||
if (port) {
|
||||
out += host + ":" + std::to_string(port);
|
||||
if (ipv6) {
|
||||
if (port) {
|
||||
out += "[" + host + "]:" + std::to_string(port);
|
||||
} else {
|
||||
out += "[" + host + "]";
|
||||
}
|
||||
} else {
|
||||
out += host;
|
||||
if (port) {
|
||||
out += host + ":" + std::to_string(port);
|
||||
} else {
|
||||
out += host;
|
||||
}
|
||||
}
|
||||
}
|
||||
out += path;
|
||||
if (hasquery) // add query even if it was empty
|
||||
out += "?";
|
||||
if (query != "")
|
||||
out += "?" + query;
|
||||
out += query;
|
||||
if (frag != "")
|
||||
out += "#" + frag;
|
||||
return out;
|
||||
@@ -347,6 +370,14 @@ namespace http
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t HTTPReq::GetNumHeaders (const std::string& name) const
|
||||
{
|
||||
size_t num = 0;
|
||||
for (auto& it : headers)
|
||||
if (it.first == name) num++;
|
||||
return num;
|
||||
}
|
||||
|
||||
bool HTTPRes::is_chunked() const
|
||||
{
|
||||
auto it = headers.find("Transfer-Encoding");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -33,10 +33,12 @@ namespace http
|
||||
std::string host;
|
||||
unsigned short int port;
|
||||
std::string path;
|
||||
bool hasquery;
|
||||
std::string query;
|
||||
std::string frag;
|
||||
bool ipv6;
|
||||
|
||||
URL(): schema(""), user(""), pass(""), host(""), port(0), path(""), query(""), frag("") {};
|
||||
URL(): schema(""), user(""), pass(""), host(""), port(0), path(""), hasquery(false), query(""), frag(""), ipv6(false) {};
|
||||
|
||||
/**
|
||||
* @brief Tries to parse url from string
|
||||
@@ -101,6 +103,8 @@ namespace http
|
||||
void RemoveHeader (const std::string& name, const std::string& exempt); // remove all headers starting with name, but exempt
|
||||
void RemoveHeader (const std::string& name) { RemoveHeader (name, ""); };
|
||||
std::string GetHeader (const std::string& name) const;
|
||||
size_t GetNumHeaders (const std::string& name) const;
|
||||
size_t GetNumHeaders () const { return headers.size (); };
|
||||
};
|
||||
|
||||
struct HTTPRes : HTTPMsg {
|
||||
|
||||
@@ -353,21 +353,6 @@ namespace i2p
|
||||
return !msg->GetPayload ()[DATABASE_STORE_TYPE_OFFSET]; // 0- RouterInfo
|
||||
}
|
||||
|
||||
static uint16_t g_MaxNumTransitTunnels = DEFAULT_MAX_NUM_TRANSIT_TUNNELS; // TODO:
|
||||
void SetMaxNumTransitTunnels (uint16_t maxNumTransitTunnels)
|
||||
{
|
||||
if (maxNumTransitTunnels > 0 && g_MaxNumTransitTunnels != maxNumTransitTunnels)
|
||||
{
|
||||
LogPrint (eLogDebug, "I2NP: Max number of transit tunnels set to ", maxNumTransitTunnels);
|
||||
g_MaxNumTransitTunnels = maxNumTransitTunnels;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t GetMaxNumTransitTunnels ()
|
||||
{
|
||||
return g_MaxNumTransitTunnels;
|
||||
}
|
||||
|
||||
static bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText)
|
||||
{
|
||||
for (int i = 0; i < num; i++)
|
||||
@@ -379,10 +364,7 @@ namespace i2p
|
||||
if (!i2p::context.DecryptTunnelBuildRecord (record + BUILD_REQUEST_RECORD_ENCRYPTED_OFFSET, clearText)) return false;
|
||||
uint8_t retCode = 0;
|
||||
// replace record to reply
|
||||
if (i2p::context.AcceptsTunnels () &&
|
||||
i2p::tunnel::tunnels.GetTransitTunnels ().size () <= g_MaxNumTransitTunnels &&
|
||||
!i2p::transport::transports.IsBandwidthExceeded () &&
|
||||
!i2p::transport::transports.IsTransitBandwidthExceeded ())
|
||||
if (i2p::context.AcceptsTunnels () && !i2p::context.IsHighCongestion ())
|
||||
{
|
||||
auto transitTunnel = i2p::tunnel::CreateTransitTunnel (
|
||||
bufbe32toh (clearText + ECIES_BUILD_REQUEST_RECORD_RECEIVE_TUNNEL_OFFSET),
|
||||
@@ -576,11 +558,8 @@ namespace i2p
|
||||
|
||||
// check if we accept this tunnel
|
||||
uint8_t retCode = 0;
|
||||
if (!i2p::context.AcceptsTunnels () ||
|
||||
i2p::tunnel::tunnels.GetTransitTunnels ().size () > g_MaxNumTransitTunnels ||
|
||||
i2p::transport::transports.IsBandwidthExceeded () ||
|
||||
i2p::transport::transports.IsTransitBandwidthExceeded ())
|
||||
retCode = 30;
|
||||
if (!i2p::context.AcceptsTunnels () || i2p::context.IsHighCongestion ())
|
||||
retCode = 30;
|
||||
if (!retCode)
|
||||
{
|
||||
// create new transit tunnel
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -308,10 +308,6 @@ namespace tunnel
|
||||
|
||||
std::vector<std::shared_ptr<I2NPMessage> > m_TunnelMsgs, m_TunnelGatewayMsgs;
|
||||
};
|
||||
|
||||
const uint16_t DEFAULT_MAX_NUM_TRANSIT_TUNNELS = 5000;
|
||||
void SetMaxNumTransitTunnels (uint16_t maxNumTransitTunnels);
|
||||
uint16_t GetMaxNumTransitTunnels ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,23 @@
|
||||
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#if defined(_MSC_VER)
|
||||
#include <stdlib.h>
|
||||
#define htobe16(x) _byteswap_ushort(x)
|
||||
#define htole16(x) (x)
|
||||
#define be16toh(x) _byteswap_ushort(x)
|
||||
#define le16toh(x) (x)
|
||||
|
||||
#define htobe32(x) _byteswap_ulong(x)
|
||||
#define htole32(x) (x)
|
||||
#define be32toh(x) _byteswap_ulong(x)
|
||||
#define le32toh(x) (x)
|
||||
|
||||
#define htobe64(x) _byteswap_uint64(x)
|
||||
#define htole64(x) (x)
|
||||
#define be64toh(x) _byteswap_uint64(x)
|
||||
#define le64toh(x) (x)
|
||||
#else
|
||||
#define htobe16(x) __builtin_bswap16(x)
|
||||
#define htole16(x) (x)
|
||||
#define be16toh(x) __builtin_bswap16(x)
|
||||
@@ -50,6 +67,7 @@
|
||||
#define htole64(x) (x)
|
||||
#define be64toh(x) __builtin_bswap64(x)
|
||||
#define le64toh(x) (x)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define NEEDS_LOCAL_ENDIAN
|
||||
|
||||
372
libi2pd/KadDHT.cpp
Normal file
372
libi2pd/KadDHT.cpp
Normal file
@@ -0,0 +1,372 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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 "KadDHT.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
DHTNode::DHTNode ():
|
||||
zero (nullptr), one (nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
DHTNode::~DHTNode ()
|
||||
{
|
||||
if (zero) delete zero;
|
||||
if (one) delete one;
|
||||
}
|
||||
|
||||
void DHTNode::MoveRouterUp (bool fromOne)
|
||||
{
|
||||
DHTNode *& side = fromOne ? one : zero;
|
||||
if (side)
|
||||
{
|
||||
if (router) router = nullptr; // shouldn't happen
|
||||
router = side->router;
|
||||
side->router = nullptr;
|
||||
delete side;
|
||||
side = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
DHTTable::DHTTable ():
|
||||
m_Size (0)
|
||||
{
|
||||
m_Root = new DHTNode;
|
||||
}
|
||||
|
||||
DHTTable::~DHTTable ()
|
||||
{
|
||||
delete m_Root;
|
||||
}
|
||||
|
||||
void DHTTable::Clear ()
|
||||
{
|
||||
m_Size = 0;
|
||||
delete m_Root;
|
||||
m_Root = new DHTNode;
|
||||
}
|
||||
|
||||
void DHTTable::Insert (const std::shared_ptr<RouterInfo>& r)
|
||||
{
|
||||
if (!r) return;
|
||||
return Insert (r, m_Root, 0);
|
||||
}
|
||||
|
||||
void DHTTable::Insert (const std::shared_ptr<RouterInfo>& r, DHTNode * root, int level)
|
||||
{
|
||||
if (root->router)
|
||||
{
|
||||
if (root->router->GetIdentHash () == r->GetIdentHash ())
|
||||
{
|
||||
root->router = r; // replace
|
||||
return;
|
||||
}
|
||||
auto r2 = root->router;
|
||||
root->router = nullptr; m_Size--;
|
||||
int bit1, bit2;
|
||||
do
|
||||
{
|
||||
bit1 = r->GetIdentHash ().GetBit (level);
|
||||
bit2 = r2->GetIdentHash ().GetBit (level);
|
||||
if (bit1 == bit2)
|
||||
{
|
||||
if (bit1)
|
||||
{
|
||||
if (root->one) return; // someting wrong
|
||||
root->one = new DHTNode;
|
||||
root = root->one;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero) return; // someting wrong
|
||||
root->zero = new DHTNode;
|
||||
root = root->zero;
|
||||
}
|
||||
level++;
|
||||
}
|
||||
}
|
||||
while (bit1 == bit2);
|
||||
|
||||
if (!root->zero)
|
||||
root->zero = new DHTNode;
|
||||
if (!root->one)
|
||||
root->one = new DHTNode;
|
||||
if (bit1)
|
||||
{
|
||||
Insert (r2, root->zero, level + 1);
|
||||
Insert (r, root->one, level + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Insert (r2, root->one, level + 1);
|
||||
Insert (r, root->zero, level + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!root->zero && !root->one)
|
||||
{
|
||||
root->router = r; m_Size++;
|
||||
return;
|
||||
}
|
||||
int bit = r->GetIdentHash ().GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (!root->one)
|
||||
root->one = new DHTNode;
|
||||
Insert (r, root->one, level + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!root->zero)
|
||||
root->zero = new DHTNode;
|
||||
Insert (r, root->zero, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DHTTable::Remove (const IdentHash& h)
|
||||
{
|
||||
return Remove (h, m_Root, 0);
|
||||
}
|
||||
|
||||
bool DHTTable::Remove (const IdentHash& h, DHTNode * root, int level)
|
||||
{
|
||||
if (root)
|
||||
{
|
||||
if (root->router && root->router->GetIdentHash () == h)
|
||||
{
|
||||
root->router = nullptr;
|
||||
m_Size--;
|
||||
return true;
|
||||
}
|
||||
int bit = h.GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (root->one && Remove (h, root->one, level + 1))
|
||||
{
|
||||
if (root->one->IsEmpty ())
|
||||
{
|
||||
delete root->one;
|
||||
root->one = nullptr;
|
||||
if (root->zero && root->zero->router)
|
||||
root->MoveRouterUp (false);
|
||||
}
|
||||
else if (root->one->router && !root->zero)
|
||||
root->MoveRouterUp (true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero && Remove (h, root->zero, level + 1))
|
||||
{
|
||||
if (root->zero->IsEmpty ())
|
||||
{
|
||||
delete root->zero;
|
||||
root->zero = nullptr;
|
||||
if (root->one && root->one->router)
|
||||
root->MoveRouterUp (true);
|
||||
}
|
||||
else if (root->zero->router && !root->one)
|
||||
root->MoveRouterUp (false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<RouterInfo> DHTTable::FindClosest (const IdentHash& h, const Filter& filter) const
|
||||
{
|
||||
if (filter) m_Filter = filter;
|
||||
auto r = FindClosest (h, m_Root, 0);
|
||||
m_Filter = nullptr;
|
||||
return r;
|
||||
}
|
||||
|
||||
std::shared_ptr<RouterInfo> DHTTable::FindClosest (const IdentHash& h, DHTNode * root, int level) const
|
||||
{
|
||||
bool split = false;
|
||||
do
|
||||
{
|
||||
if (root->router)
|
||||
return (!m_Filter || m_Filter (root->router)) ? root->router : nullptr;
|
||||
split = root->zero && root->one;
|
||||
if (!split)
|
||||
{
|
||||
if (root->zero) root = root->zero;
|
||||
else if (root->one) root = root->one;
|
||||
else return nullptr;
|
||||
level++;
|
||||
}
|
||||
}
|
||||
while (!split);
|
||||
int bit = h.GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (root->one)
|
||||
{
|
||||
auto r = FindClosest (h, root->one, level + 1);
|
||||
if (r) return r;
|
||||
}
|
||||
if (root->zero)
|
||||
{
|
||||
auto r = FindClosest (h, root->zero, level + 1);
|
||||
if (r) return r;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero)
|
||||
{
|
||||
auto r = FindClosest (h, root->zero, level + 1);
|
||||
if (r) return r;
|
||||
}
|
||||
if (root->one)
|
||||
{
|
||||
auto r = FindClosest (h, root->one, level + 1);
|
||||
if (r) return r;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<RouterInfo> > DHTTable::FindClosest (const IdentHash& h, size_t num, const Filter& filter) const
|
||||
{
|
||||
std::vector<std::shared_ptr<RouterInfo> > vec;
|
||||
if (num > 0)
|
||||
{
|
||||
if (filter) m_Filter = filter;
|
||||
FindClosest (h, num, m_Root, 0, vec);
|
||||
m_Filter = nullptr;
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
void DHTTable::FindClosest (const IdentHash& h, size_t num, DHTNode * root, int level, std::vector<std::shared_ptr<RouterInfo> >& hashes) const
|
||||
{
|
||||
if (hashes.size () >= num) return;
|
||||
bool split = false;
|
||||
do
|
||||
{
|
||||
if (root->router)
|
||||
{
|
||||
if (!m_Filter || m_Filter (root->router))
|
||||
hashes.push_back (root->router);
|
||||
return;
|
||||
}
|
||||
split = root->zero && root->one;
|
||||
if (!split)
|
||||
{
|
||||
if (root->zero) root = root->zero;
|
||||
else if (root->one) root = root->one;
|
||||
else return;
|
||||
level++;
|
||||
}
|
||||
}
|
||||
while (!split);
|
||||
int bit = h.GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (root->one)
|
||||
FindClosest (h, num, root->one, level + 1, hashes);
|
||||
if (hashes.size () < num && root->zero)
|
||||
FindClosest (h, num, root->zero, level + 1, hashes);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero)
|
||||
FindClosest (h, num, root->zero, level + 1, hashes);
|
||||
if (hashes.size () < num && root->one)
|
||||
FindClosest (h, num, root->one, level + 1, hashes);
|
||||
}
|
||||
}
|
||||
|
||||
void DHTTable::Cleanup (const Filter& filter)
|
||||
{
|
||||
if (filter)
|
||||
{
|
||||
m_Filter = filter;
|
||||
Cleanup (m_Root);
|
||||
m_Filter = nullptr;
|
||||
}
|
||||
else
|
||||
Clear ();
|
||||
}
|
||||
|
||||
void DHTTable::Cleanup (DHTNode * root)
|
||||
{
|
||||
if (!root) return;
|
||||
if (root->router)
|
||||
{
|
||||
if (!m_Filter || !m_Filter (root->router))
|
||||
{
|
||||
m_Size--;
|
||||
root->router = nullptr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (root->zero)
|
||||
{
|
||||
Cleanup (root->zero);
|
||||
if (root->zero->IsEmpty ())
|
||||
{
|
||||
delete root->zero;
|
||||
root->zero = nullptr;
|
||||
}
|
||||
}
|
||||
if (root->one)
|
||||
{
|
||||
Cleanup (root->one);
|
||||
if (root->one->IsEmpty ())
|
||||
{
|
||||
delete root->one;
|
||||
root->one = nullptr;
|
||||
if (root->zero && root->zero->router)
|
||||
root->MoveRouterUp (false);
|
||||
}
|
||||
else if (root->one->router && !root->zero)
|
||||
root->MoveRouterUp (true);
|
||||
}
|
||||
}
|
||||
|
||||
void DHTTable::Print (std::stringstream& s)
|
||||
{
|
||||
Print (s, m_Root, 0);
|
||||
}
|
||||
|
||||
void DHTTable::Print (std::stringstream& s, DHTNode * root, int level)
|
||||
{
|
||||
if (!root) return;
|
||||
s << std::string (level, '-');
|
||||
if (root->router)
|
||||
{
|
||||
if (!root->zero && !root->one)
|
||||
s << '>' << GetIdentHashAbbreviation (root->router->GetIdentHash ());
|
||||
else
|
||||
s << "error";
|
||||
}
|
||||
s << std::endl;
|
||||
if (root->zero)
|
||||
{
|
||||
s << std::string (level, '-') << "0" << std::endl;
|
||||
Print (s, root->zero, level + 1);
|
||||
}
|
||||
if (root->one)
|
||||
{
|
||||
s << std::string (level, '-') << "1" << std::endl;
|
||||
Print (s, root->one, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
74
libi2pd/KadDHT.h
Normal file
74
libi2pd/KadDHT.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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 KADDHT_H__
|
||||
#define KADDHT_H__
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <functional>
|
||||
#include "RouterInfo.h"
|
||||
|
||||
// Kademlia DHT (XOR distance)
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
struct DHTNode
|
||||
{
|
||||
DHTNode * zero, * one;
|
||||
std::shared_ptr<RouterInfo> router;
|
||||
|
||||
DHTNode ();
|
||||
~DHTNode ();
|
||||
|
||||
bool IsEmpty () const { return !zero && !one && !router; };
|
||||
void MoveRouterUp (bool fromOne);
|
||||
};
|
||||
|
||||
class DHTTable
|
||||
{
|
||||
typedef std::function<bool (const std::shared_ptr<RouterInfo>&)> Filter;
|
||||
public:
|
||||
|
||||
DHTTable ();
|
||||
~DHTTable ();
|
||||
|
||||
void Insert (const std::shared_ptr<RouterInfo>& r);
|
||||
bool Remove (const IdentHash& h);
|
||||
std::shared_ptr<RouterInfo> FindClosest (const IdentHash& h, const Filter& filter = nullptr) const;
|
||||
std::vector<std::shared_ptr<RouterInfo> > FindClosest (const IdentHash& h, size_t num, const Filter& filter = nullptr) const;
|
||||
|
||||
void Print (std::stringstream& s);
|
||||
size_t GetSize () const { return m_Size; };
|
||||
void Clear ();
|
||||
void Cleanup (const Filter& filter);
|
||||
|
||||
private:
|
||||
|
||||
void Insert (const std::shared_ptr<RouterInfo>& r, DHTNode * root, int level); // recursive
|
||||
bool Remove (const IdentHash& h, DHTNode * root, int level);
|
||||
std::shared_ptr<RouterInfo> FindClosest (const IdentHash& h, DHTNode * root, int level) const;
|
||||
void FindClosest (const IdentHash& h, size_t num, DHTNode * root, int level, std::vector<std::shared_ptr<RouterInfo> >& hashes) const;
|
||||
void Cleanup (DHTNode * root);
|
||||
void Print (std::stringstream& s, DHTNode * root, int level);
|
||||
|
||||
private:
|
||||
|
||||
DHTNode * m_Root;
|
||||
size_t m_Size;
|
||||
// transient
|
||||
mutable Filter m_Filter;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -315,7 +315,7 @@ namespace data
|
||||
{
|
||||
// standard LS2 header
|
||||
std::shared_ptr<const IdentityEx> identity;
|
||||
if (readIdentity)
|
||||
if (readIdentity || !GetIdentity ())
|
||||
{
|
||||
identity = std::make_shared<IdentityEx>(buf, len);
|
||||
SetIdentity (identity);
|
||||
@@ -366,6 +366,8 @@ namespace data
|
||||
VerifySignature (identity, buf, len, offset);
|
||||
SetIsValid (verified);
|
||||
}
|
||||
else
|
||||
SetIsValid (true);
|
||||
offset += m_TransientVerifier ? m_TransientVerifier->GetSignatureLen () : identity->GetSignatureLen ();
|
||||
if (offset > len) {
|
||||
LogPrint (eLogWarning, "LeaseSet2: short buffer: wanted ", int(offset), "bytes, have ", int(len));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -145,6 +145,7 @@ namespace data
|
||||
{
|
||||
public:
|
||||
|
||||
LeaseSet2 (uint8_t storeType): LeaseSet (true), m_StoreType (storeType) {}; // for update
|
||||
LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases = true, CryptoKeyType preferredCrypto = CRYPTO_KEY_TYPE_ELGAMAL);
|
||||
LeaseSet2 (const uint8_t * buf, size_t len, std::shared_ptr<const BlindedPublicKey> key, const uint8_t * secret = nullptr, CryptoKeyType preferredCrypto = CRYPTO_KEY_TYPE_ELGAMAL); // store type 5, called from local netdb only
|
||||
uint8_t GetStoreType () const { return m_StoreType; };
|
||||
|
||||
@@ -693,10 +693,20 @@ namespace transport
|
||||
SendTerminationAndTerminate (eNTCP2Message3Error);
|
||||
return;
|
||||
}
|
||||
auto addr = ri.GetNTCP2AddressWithStaticKey (m_Establisher->m_RemoteStaticKey);
|
||||
if (!addr)
|
||||
auto addr = m_RemoteEndpoint.address ().is_v4 () ? ri.GetNTCP2V4Address () :
|
||||
(i2p::util::net::IsYggdrasilAddress (m_RemoteEndpoint.address ()) ? ri.GetYggdrasilAddress () : ri.GetNTCP2V6Address ());
|
||||
if (!addr || memcmp (m_Establisher->m_RemoteStaticKey, addr->s, 32))
|
||||
{
|
||||
LogPrint (eLogError, "NTCP2: No NTCP2 address with static key found in SessionConfirmed");
|
||||
LogPrint (eLogError, "NTCP2: Wrong static key in SessionConfirmed");
|
||||
Terminate ();
|
||||
return;
|
||||
}
|
||||
if (addr->IsPublishedNTCP2 () && m_RemoteEndpoint.address () != addr->host &&
|
||||
(!m_RemoteEndpoint.address ().is_v6 () || (i2p::util::net::IsYggdrasilAddress (m_RemoteEndpoint.address ()) ?
|
||||
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data () + 1, addr->host.to_v6 ().to_bytes ().data () + 1, 7) : // from the same yggdrasil subnet
|
||||
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data (), addr->host.to_v6 ().to_bytes ().data (), 8)))) // temporary address
|
||||
{
|
||||
LogPrint (eLogError, "NTCP2: Host mismatch between published address ", addr->host, " and actual endpoint ", m_RemoteEndpoint.address ());
|
||||
Terminate ();
|
||||
return;
|
||||
}
|
||||
@@ -874,8 +884,20 @@ namespace transport
|
||||
switch (blk)
|
||||
{
|
||||
case eNTCP2BlkDateTime:
|
||||
{
|
||||
LogPrint (eLogDebug, "NTCP2: Datetime");
|
||||
break;
|
||||
if (m_IsEstablished)
|
||||
{
|
||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
uint64_t tsA = bufbe32toh (frame + offset);
|
||||
if (tsA < ts - NTCP2_CLOCK_SKEW || tsA > ts + NTCP2_CLOCK_SKEW)
|
||||
{
|
||||
LogPrint (eLogWarning, "NTCP2: Established session time difference ", (int)(ts - tsA), " exceeds clock skew");
|
||||
SendTerminationAndTerminate (eNTCP2ClockSkew);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case eNTCP2BlkOptions:
|
||||
LogPrint (eLogDebug, "NTCP2: Options");
|
||||
break;
|
||||
@@ -1120,12 +1142,17 @@ namespace transport
|
||||
{
|
||||
if (!IsEstablished ()) return;
|
||||
auto riLen = i2p::context.GetRouterInfo ().GetBufferLen ();
|
||||
size_t payloadLen = riLen + 4; // 3 bytes block header + 1 byte RI flag
|
||||
size_t payloadLen = riLen + 3 + 1 + 7; // 3 bytes block header + 1 byte RI flag + 7 bytes DateTime
|
||||
m_NextSendBuffer = new uint8_t[payloadLen + 16 + 2 + 64]; // up to 64 bytes padding
|
||||
m_NextSendBuffer[2] = eNTCP2BlkRouterInfo;
|
||||
htobe16buf (m_NextSendBuffer + 3, riLen + 1); // size
|
||||
m_NextSendBuffer[5] = 0; // flag
|
||||
memcpy (m_NextSendBuffer + 6, i2p::context.GetRouterInfo ().GetBuffer (), riLen);
|
||||
// DateTime block
|
||||
m_NextSendBuffer[2] = eNTCP2BlkDateTime;
|
||||
htobe16buf (m_NextSendBuffer + 3, 4);
|
||||
htobe32buf (m_NextSendBuffer + 5, (i2p::util::GetMillisecondsSinceEpoch () + 500)/1000);
|
||||
// RouterInfo block
|
||||
m_NextSendBuffer[9] = eNTCP2BlkRouterInfo;
|
||||
htobe16buf (m_NextSendBuffer + 10, riLen + 1); // size
|
||||
m_NextSendBuffer[12] = 0; // flag
|
||||
memcpy (m_NextSendBuffer + 13, i2p::context.GetRouterInfo ().GetBuffer (), riLen);
|
||||
// padding block
|
||||
auto paddingSize = CreatePaddingBlock (payloadLen, m_NextSendBuffer + 2 + payloadLen, 64);
|
||||
payloadLen += paddingSize;
|
||||
@@ -1430,7 +1457,7 @@ namespace transport
|
||||
|
||||
void NTCP2Server::HandleAccept (std::shared_ptr<NTCP2Session> conn, const boost::system::error_code& error)
|
||||
{
|
||||
if (!error)
|
||||
if (!error && conn)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
auto ep = conn->GetSocket ().remote_endpoint(ec);
|
||||
@@ -1439,17 +1466,14 @@ namespace transport
|
||||
LogPrint (eLogDebug, "NTCP2: Connected from ", ep);
|
||||
if (!i2p::util::net::IsInReservedRange(ep.address ()))
|
||||
{
|
||||
if (conn)
|
||||
if (m_PendingIncomingSessions.emplace (ep.address (), conn).second)
|
||||
{
|
||||
if (m_PendingIncomingSessions.emplace (ep.address (), conn).second)
|
||||
{
|
||||
conn->SetRemoteEndpoint (ep);
|
||||
conn->ServerLogin ();
|
||||
conn = nullptr;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogInfo, "NTCP2: Incoming session from ", ep.address (), " is already pending");
|
||||
conn->SetRemoteEndpoint (ep);
|
||||
conn->ServerLogin ();
|
||||
conn = nullptr;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogInfo, "NTCP2: Incoming session from ", ep.address (), " is already pending");
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "NTCP2: Incoming connection from invalid IP ", ep.address ());
|
||||
@@ -1480,7 +1504,7 @@ namespace transport
|
||||
|
||||
void NTCP2Server::HandleAcceptV6 (std::shared_ptr<NTCP2Session> conn, const boost::system::error_code& error)
|
||||
{
|
||||
if (!error)
|
||||
if (!error && conn)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
auto ep = conn->GetSocket ().remote_endpoint(ec);
|
||||
@@ -1490,17 +1514,14 @@ namespace transport
|
||||
if (!i2p::util::net::IsInReservedRange(ep.address ()) ||
|
||||
i2p::util::net::IsYggdrasilAddress (ep.address ()))
|
||||
{
|
||||
if (conn)
|
||||
if (m_PendingIncomingSessions.emplace (ep.address (), conn).second)
|
||||
{
|
||||
if (m_PendingIncomingSessions.emplace (ep.address (), conn).second)
|
||||
{
|
||||
conn->SetRemoteEndpoint (ep);
|
||||
conn->ServerLogin ();
|
||||
conn = nullptr;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogInfo, "NTCP2: Incoming session from ", ep.address (), " is already pending");
|
||||
conn->SetRemoteEndpoint (ep);
|
||||
conn->ServerLogin ();
|
||||
conn = nullptr;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogInfo, "NTCP2: Incoming session from ", ep.address (), " is already pending");
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "NTCP2: Incoming connection from invalid IP ", ep.address ());
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace data
|
||||
{
|
||||
NetDb netdb;
|
||||
|
||||
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr), m_Reseeder (nullptr), m_Storage("netDb", "r", "routerInfo-", "dat"), m_PersistProfiles (true), m_HiddenMode(false)
|
||||
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr), m_Reseeder (nullptr), m_Storage("netDb", "r", "routerInfo-", "dat"), m_PersistProfiles (true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace data
|
||||
Load ();
|
||||
|
||||
uint16_t threshold; i2p::config::GetOption("reseed.threshold", threshold);
|
||||
if (m_RouterInfos.size () < threshold || m_Floodfills.size () < NETDB_MIN_FLOODFILLS) // reseed if # of router less than threshold or too few floodfiils
|
||||
if (m_RouterInfos.size () < threshold || m_Floodfills.GetSize () < NETDB_MIN_FLOODFILLS) // reseed if # of router less than threshold or too few floodfiils
|
||||
{
|
||||
Reseed ();
|
||||
}
|
||||
@@ -66,13 +66,13 @@ namespace data
|
||||
if (it != m_RouterInfos.end ())
|
||||
{
|
||||
// remove own router
|
||||
m_Floodfills.remove (it->second);
|
||||
m_Floodfills.Remove (it->second->GetIdentHash ());
|
||||
m_RouterInfos.erase (it);
|
||||
}
|
||||
// insert own router
|
||||
m_RouterInfos.emplace (i2p::context.GetIdentHash (), i2p::context.GetSharedRouterInfo ());
|
||||
if (i2p::context.IsFloodfill ())
|
||||
m_Floodfills.push_back (i2p::context.GetSharedRouterInfo ());
|
||||
m_Floodfills.Insert (i2p::context.GetSharedRouterInfo ());
|
||||
|
||||
i2p::config::GetOption("persist.profiles", m_PersistProfiles);
|
||||
|
||||
@@ -85,11 +85,10 @@ namespace data
|
||||
if (m_IsRunning)
|
||||
{
|
||||
if (m_PersistProfiles)
|
||||
for (auto& it: m_RouterInfos)
|
||||
it.second->SaveProfile ();
|
||||
SaveProfiles ();
|
||||
DeleteObsoleteProfiles ();
|
||||
m_RouterInfos.clear ();
|
||||
m_Floodfills.clear ();
|
||||
m_Floodfills.Clear ();
|
||||
if (m_Thread)
|
||||
{
|
||||
m_IsRunning = false;
|
||||
@@ -107,7 +106,7 @@ namespace data
|
||||
{
|
||||
i2p::util::SetThreadName("NetDB");
|
||||
|
||||
uint64_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0;
|
||||
uint64_t lastSave = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0;
|
||||
uint64_t lastProfilesCleanup = i2p::util::GetSecondsSinceEpoch ();
|
||||
int16_t profilesCleanupVariance = 0;
|
||||
|
||||
@@ -133,9 +132,6 @@ namespace data
|
||||
case eI2NPDatabaseLookup:
|
||||
HandleDatabaseLookupMsg (msg);
|
||||
break;
|
||||
case eI2NPDeliveryStatus:
|
||||
HandleDeliveryStatusMsg (msg);
|
||||
break;
|
||||
case eI2NPDummyMsg:
|
||||
// plain RouterInfo from NTCP2 with flags for now
|
||||
HandleNTCP2RouterInfoMsg (msg);
|
||||
@@ -153,13 +149,13 @@ namespace data
|
||||
if (!i2p::transport::transports.IsOnline ()) continue; // don't manage netdb when offline
|
||||
|
||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
if (ts - lastManageRequest >= 15) // manage requests every 15 seconds
|
||||
if (ts - lastManageRequest >= 15 || ts + 15 < lastManageRequest) // manage requests every 15 seconds
|
||||
{
|
||||
m_Requests.ManageRequests ();
|
||||
lastManageRequest = ts;
|
||||
}
|
||||
|
||||
if (ts - lastSave >= 60) // save routers, manage leasesets and validate subscriptions every minute
|
||||
if (ts - lastSave >= 60 || ts + 60 < lastSave) // save routers, manage leasesets and validate subscriptions every minute
|
||||
{
|
||||
if (lastSave)
|
||||
{
|
||||
@@ -169,46 +165,23 @@ namespace data
|
||||
lastSave = ts;
|
||||
}
|
||||
|
||||
if (ts - lastDestinationCleanup >= i2p::garlic::INCOMING_TAGS_EXPIRATION_TIMEOUT)
|
||||
if (ts - lastDestinationCleanup >= i2p::garlic::INCOMING_TAGS_EXPIRATION_TIMEOUT ||
|
||||
ts + i2p::garlic::INCOMING_TAGS_EXPIRATION_TIMEOUT < lastDestinationCleanup)
|
||||
{
|
||||
i2p::context.CleanupDestination ();
|
||||
lastDestinationCleanup = ts;
|
||||
}
|
||||
|
||||
if (ts - lastProfilesCleanup >= (uint64_t)(i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance))
|
||||
if (ts - lastProfilesCleanup >= (uint64_t)(i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance) ||
|
||||
ts + i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT < lastProfilesCleanup)
|
||||
{
|
||||
if (m_PersistProfiles) PersistProfiles ();
|
||||
DeleteObsoleteProfiles ();
|
||||
lastProfilesCleanup = ts;
|
||||
profilesCleanupVariance = (rand () % (2 * i2p::data::PEER_PROFILE_AUTOCLEAN_VARIANCE) - i2p::data::PEER_PROFILE_AUTOCLEAN_VARIANCE);
|
||||
}
|
||||
|
||||
// publish
|
||||
if (!m_HiddenMode && i2p::transport::transports.IsOnline ())
|
||||
{
|
||||
bool publish = false;
|
||||
if (m_PublishReplyToken)
|
||||
{
|
||||
// next publishing attempt
|
||||
if (ts - lastPublish >= NETDB_PUBLISH_CONFIRMATION_TIMEOUT) publish = true;
|
||||
}
|
||||
else if (i2p::context.GetLastUpdateTime () > lastPublish ||
|
||||
ts - lastPublish >= NETDB_PUBLISH_INTERVAL)
|
||||
{
|
||||
// new publish
|
||||
m_PublishExcluded.clear ();
|
||||
if (i2p::context.IsFloodfill ())
|
||||
m_PublishExcluded.insert (i2p::context.GetIdentHash ()); // do publish to ourselves
|
||||
publish = true;
|
||||
}
|
||||
if (publish) // update timestamp and publish
|
||||
{
|
||||
i2p::context.UpdateTimestamp (ts);
|
||||
Publish ();
|
||||
lastPublish = ts;
|
||||
}
|
||||
}
|
||||
|
||||
if (ts - lastExploratory >= 30) // exploratory every 30 seconds
|
||||
if (ts - lastExploratory >= 30 || ts + 30 < lastExploratory) // exploratory every 30 seconds
|
||||
{
|
||||
auto numRouters = m_RouterInfos.size ();
|
||||
if (!numRouters)
|
||||
@@ -221,7 +194,7 @@ namespace data
|
||||
if (numRouters < 1) numRouters = 1;
|
||||
if (numRouters > 9) numRouters = 9;
|
||||
m_Requests.ManageRequests ();
|
||||
if(!m_HiddenMode)
|
||||
if(!i2p::context.IsHidden ())
|
||||
Explore (numRouters);
|
||||
lastExploratory = ts;
|
||||
}
|
||||
@@ -234,12 +207,6 @@ namespace data
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::SetHidden(bool hide)
|
||||
{
|
||||
// TODO: remove reachable addresses from router info
|
||||
m_HiddenMode = hide;
|
||||
}
|
||||
|
||||
std::shared_ptr<const RouterInfo> NetDb::AddRouterInfo (const uint8_t * buf, int len)
|
||||
{
|
||||
bool updated;
|
||||
@@ -273,7 +240,24 @@ namespace data
|
||||
bool wasFloodfill = r->IsFloodfill ();
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||
r->Update (buf, len);
|
||||
if (!r->Update (buf, len))
|
||||
{
|
||||
updated = false;
|
||||
m_Requests.RequestComplete (ident, r);
|
||||
return r;
|
||||
}
|
||||
if (r->IsUnreachable ())
|
||||
{
|
||||
// delete router as invalid after update
|
||||
m_RouterInfos.erase (ident);
|
||||
if (wasFloodfill)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
m_Floodfills.Remove (r->GetIdentHash ());
|
||||
}
|
||||
m_Requests.RequestComplete (ident, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
|
||||
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
|
||||
@@ -281,9 +265,9 @@ namespace data
|
||||
LogPrint (eLogDebug, "NetDb: RouterInfo floodfill status updated: ", ident.ToBase64());
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
if (wasFloodfill)
|
||||
m_Floodfills.remove (r);
|
||||
m_Floodfills.Remove (r->GetIdentHash ());
|
||||
else if (r->IsEligibleFloodfill ())
|
||||
m_Floodfills.push_back (r);
|
||||
m_Floodfills.Insert (r);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -295,7 +279,7 @@ namespace data
|
||||
else
|
||||
{
|
||||
r = std::make_shared<RouterInfo> (buf, len);
|
||||
if (!r->IsUnreachable () && r->HasValidAddresses () &&
|
||||
if (!r->IsUnreachable () && r->HasValidAddresses () && (!r->IsFloodfill () || !r->GetProfile ()->IsUnreachable ()) &&
|
||||
i2p::util::GetMillisecondsSinceEpoch () + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL > r->GetTimestamp ())
|
||||
{
|
||||
bool inserted = false;
|
||||
@@ -309,7 +293,7 @@ namespace data
|
||||
if (r->IsFloodfill () && r->IsEligibleFloodfill ())
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
m_Floodfills.push_back (r);
|
||||
m_Floodfills.Insert (r);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -427,7 +411,15 @@ namespace data
|
||||
{
|
||||
auto it = m_RouterInfos.find (ident);
|
||||
if (it != m_RouterInfos.end ())
|
||||
return it->second->SetUnreachable (unreachable);
|
||||
{
|
||||
it->second->SetUnreachable (unreachable);
|
||||
if (unreachable)
|
||||
{
|
||||
auto profile = it->second->GetProfile ();
|
||||
if (profile)
|
||||
profile->Unreachable ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::Reseed ()
|
||||
@@ -439,8 +431,8 @@ namespace data
|
||||
}
|
||||
|
||||
// try reseeding from floodfill first if specified
|
||||
std::string riPath;
|
||||
if(i2p::config::GetOption("reseed.floodfill", riPath))
|
||||
std::string riPath; i2p::config::GetOption("reseed.floodfill", riPath);
|
||||
if (!riPath.empty())
|
||||
{
|
||||
auto ri = std::make_shared<RouterInfo>(riPath);
|
||||
if (ri->IsFloodfill())
|
||||
@@ -502,7 +494,7 @@ namespace data
|
||||
if (m_RouterInfos.emplace (r->GetIdentHash (), r).second)
|
||||
{
|
||||
if (r->IsFloodfill () && r->IsEligibleFloodfill ())
|
||||
m_Floodfills.push_back (r);
|
||||
m_Floodfills.Insert (r);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -586,7 +578,7 @@ namespace data
|
||||
{
|
||||
// make sure we cleanup netDb from previous attempts
|
||||
m_RouterInfos.clear ();
|
||||
m_Floodfills.clear ();
|
||||
m_Floodfills.Clear ();
|
||||
|
||||
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch();
|
||||
std::vector<std::string> files;
|
||||
@@ -594,14 +586,14 @@ namespace data
|
||||
for (const auto& path : files)
|
||||
LoadRouterInfo (path, ts);
|
||||
|
||||
LogPrint (eLogInfo, "NetDb: ", m_RouterInfos.size(), " routers loaded (", m_Floodfills.size (), " floodfils)");
|
||||
LogPrint (eLogInfo, "NetDb: ", m_RouterInfos.size(), " routers loaded (", m_Floodfills.GetSize (), " floodfils)");
|
||||
}
|
||||
|
||||
void NetDb::SaveUpdated ()
|
||||
{
|
||||
int updatedCount = 0, deletedCount = 0, deletedFloodfillsCount = 0;
|
||||
auto total = m_RouterInfos.size ();
|
||||
auto totalFloodfills = m_Floodfills.size ();
|
||||
auto totalFloodfills = m_Floodfills.GetSize ();
|
||||
uint64_t expirationTimeout = NETDB_MAX_EXPIRATION_TIMEOUT*1000LL;
|
||||
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch();
|
||||
auto uptime = i2p::context.GetUptime ();
|
||||
@@ -619,32 +611,43 @@ namespace data
|
||||
std::string ident = it.second->GetIdentHashBase64();
|
||||
if (it.second->IsUpdated ())
|
||||
{
|
||||
it.second->SaveToFile (m_Storage.Path(ident));
|
||||
if (it.second->GetBuffer ())
|
||||
{
|
||||
// we have something to save
|
||||
it.second->SaveToFile (m_Storage.Path(ident));
|
||||
it.second->SetUnreachable (false);
|
||||
it.second->DeleteBuffer ();
|
||||
}
|
||||
it.second->SetUpdated (false);
|
||||
it.second->SetUnreachable (false);
|
||||
it.second->DeleteBuffer ();
|
||||
updatedCount++;
|
||||
continue;
|
||||
}
|
||||
if (it.second->GetProfile ()->IsUnreachable ())
|
||||
it.second->SetUnreachable (true);
|
||||
// make router reachable back if too few routers or floodfills
|
||||
if (it.second->IsUnreachable () && (total - deletedCount < NETDB_MIN_ROUTERS || isLowRate ||
|
||||
(it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
|
||||
it.second->SetUnreachable (false);
|
||||
// find & mark expired routers
|
||||
if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & RouterInfo::eSSU2V4))
|
||||
// non-reachable router, but reachable by ipv4 SSU2 means introducers
|
||||
{
|
||||
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
|
||||
// RouterInfo expires after 1 hour if uses introducer
|
||||
if (!it.second->IsUnreachable ())
|
||||
{
|
||||
// find & mark expired routers
|
||||
if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & RouterInfo::eSSU2V4))
|
||||
// non-reachable router, but reachable by ipv4 SSU2 means introducers
|
||||
{
|
||||
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
|
||||
// RouterInfo expires after 1 hour if uses introducer
|
||||
it.second->SetUnreachable (true);
|
||||
}
|
||||
else if (checkForExpiration && ts > it.second->GetTimestamp () + expirationTimeout)
|
||||
it.second->SetUnreachable (true);
|
||||
}
|
||||
else if (checkForExpiration && ts > it.second->GetTimestamp () + expirationTimeout)
|
||||
it.second->SetUnreachable (true);
|
||||
else if (ts + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < it.second->GetTimestamp ())
|
||||
{
|
||||
LogPrint (eLogWarning, "NetDb: RouterInfo is from future for ", (it.second->GetTimestamp () - ts)/1000LL, " seconds");
|
||||
it.second->SetUnreachable (true);
|
||||
}
|
||||
else if (ts + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < it.second->GetTimestamp ())
|
||||
{
|
||||
LogPrint (eLogWarning, "NetDb: RouterInfo is from future for ", (it.second->GetTimestamp () - ts)/1000LL, " seconds");
|
||||
it.second->SetUnreachable (true);
|
||||
}
|
||||
if (it.second->IsUnreachable () && i2p::transport::transports.IsConnected (it.second->GetIdentHash ()))
|
||||
it.second->SetUnreachable (false); // don't expire connected router
|
||||
}
|
||||
|
||||
if (it.second->IsUnreachable ())
|
||||
{
|
||||
@@ -671,22 +674,21 @@ namespace data
|
||||
for (auto it = m_RouterInfos.begin (); it != m_RouterInfos.end ();)
|
||||
{
|
||||
if (it->second->IsUnreachable ())
|
||||
{
|
||||
if (m_PersistProfiles) it->second->SaveProfile ();
|
||||
it = m_RouterInfos.erase (it);
|
||||
continue;
|
||||
}
|
||||
++it;
|
||||
else
|
||||
{
|
||||
it->second->DropProfile ();
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// clean up expired floodfills or not floodfills anymore
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
for (auto it = m_Floodfills.begin (); it != m_Floodfills.end ();)
|
||||
if ((*it)->IsUnreachable () || !(*it)->IsFloodfill ())
|
||||
it = m_Floodfills.erase (it);
|
||||
else
|
||||
++it;
|
||||
m_Floodfills.Cleanup ([](const std::shared_ptr<RouterInfo>& r)->bool
|
||||
{
|
||||
return r && r->IsFloodfill () && !r->IsUnreachable ();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -811,7 +813,7 @@ namespace data
|
||||
{
|
||||
LogPrint (eLogError, "NetDb: Database store message is too long ", len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!m->from) // unsolicited LS must be received directly
|
||||
{
|
||||
if (storeType == NETDB_STORE_TYPE_LEASESET) // 1
|
||||
@@ -821,7 +823,7 @@ namespace data
|
||||
}
|
||||
else // all others are considered as LeaseSet2
|
||||
{
|
||||
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet2 of type ", storeType, " for ", ident.ToBase32());
|
||||
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet2 of type ", int(storeType), " for ", ident.ToBase32());
|
||||
updated = AddLeaseSet2 (ident, buf + offset, len - offset, storeType);
|
||||
}
|
||||
}
|
||||
@@ -1006,11 +1008,10 @@ namespace data
|
||||
lookupType == DATABASE_LOOKUP_TYPE_NORMAL_LOOKUP)
|
||||
{
|
||||
auto router = FindRouter (ident);
|
||||
if (router)
|
||||
if (router && !router->IsUnreachable ())
|
||||
{
|
||||
LogPrint (eLogDebug, "NetDb: Requested RouterInfo ", key, " found");
|
||||
PopulateRouterInfoBuffer (router);
|
||||
if (router->GetBuffer ())
|
||||
if (PopulateRouterInfoBuffer (router))
|
||||
replyMsg = CreateDatabaseStoreMsg (router);
|
||||
}
|
||||
}
|
||||
@@ -1088,16 +1089,6 @@ namespace data
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::HandleDeliveryStatusMsg (std::shared_ptr<const I2NPMessage> msg)
|
||||
{
|
||||
if (m_PublishReplyToken == bufbe32toh (msg->GetPayload () + DELIVERY_STATUS_MSGID_OFFSET))
|
||||
{
|
||||
LogPrint (eLogInfo, "NetDb: Publishing confirmed. reply token=", m_PublishReplyToken);
|
||||
m_PublishExcluded.clear ();
|
||||
m_PublishReplyToken = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::Explore (int numDestinations)
|
||||
{
|
||||
// new requests
|
||||
@@ -1148,41 +1139,6 @@ namespace data
|
||||
outbound->SendTunnelDataMsg (msgs);
|
||||
}
|
||||
|
||||
void NetDb::Publish ()
|
||||
{
|
||||
i2p::context.UpdateStats (); // for floodfill
|
||||
|
||||
if (m_PublishExcluded.size () > NETDB_MAX_PUBLISH_EXCLUDED_FLOODFILLS)
|
||||
{
|
||||
LogPrint (eLogError, "NetDb: Couldn't publish our RouterInfo to ", NETDB_MAX_PUBLISH_EXCLUDED_FLOODFILLS, " closest routers. Try again");
|
||||
m_PublishExcluded.clear ();
|
||||
}
|
||||
|
||||
auto floodfill = GetClosestFloodfill (i2p::context.GetIdentHash (), m_PublishExcluded);
|
||||
if (floodfill)
|
||||
{
|
||||
uint32_t replyToken;
|
||||
RAND_bytes ((uint8_t *)&replyToken, 4);
|
||||
LogPrint (eLogInfo, "NetDb: Publishing our RouterInfo to ", i2p::data::GetIdentHashAbbreviation(floodfill->GetIdentHash ()), ". reply token=", replyToken);
|
||||
m_PublishExcluded.insert (floodfill->GetIdentHash ());
|
||||
m_PublishReplyToken = replyToken;
|
||||
if (floodfill->IsReachableFrom (i2p::context.GetRouterInfo ()) || // are we able to connect?
|
||||
i2p::transport::transports.IsConnected (floodfill->GetIdentHash ())) // already connected ?
|
||||
// send directly
|
||||
transports.SendMessage (floodfill->GetIdentHash (), CreateDatabaseStoreMsg (i2p::context.GetSharedRouterInfo (), replyToken));
|
||||
else
|
||||
{
|
||||
// otherwise through exploratory
|
||||
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false)) : nullptr;
|
||||
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel (nullptr, floodfill->GetCompatibleTransports (true)) : nullptr;
|
||||
if (inbound && outbound)
|
||||
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0,
|
||||
CreateDatabaseStoreMsg (i2p::context.GetSharedRouterInfo (), replyToken, inbound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::Flood (const IdentHash& ident, std::shared_ptr<I2NPMessage> floodMsg)
|
||||
{
|
||||
std::set<IdentHash> excluded;
|
||||
@@ -1254,7 +1210,7 @@ namespace data
|
||||
router->IsReachableFrom (*compatibleWith)) &&
|
||||
(router->GetCaps () & RouterInfo::eHighBandwidth) &&
|
||||
router->GetVersion () >= NETDB_MIN_HIGHBANDWIDTH_VERSION &&
|
||||
router->IsECIES ();
|
||||
router->IsECIES () && !router->IsHighCongestion ();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1322,80 +1278,40 @@ namespace data
|
||||
}
|
||||
|
||||
std::shared_ptr<const RouterInfo> NetDb::GetClosestFloodfill (const IdentHash& destination,
|
||||
const std::set<IdentHash>& excluded, bool closeThanUsOnly) const
|
||||
const std::set<IdentHash>& excluded) const
|
||||
{
|
||||
std::shared_ptr<const RouterInfo> r;
|
||||
XORMetric minMetric;
|
||||
IdentHash destKey = CreateRoutingKey (destination);
|
||||
if (closeThanUsOnly)
|
||||
minMetric = destKey ^ i2p::context.GetIdentHash ();
|
||||
else
|
||||
minMetric.SetMax ();
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
for (const auto& it: m_Floodfills)
|
||||
{
|
||||
if (!it->IsUnreachable ())
|
||||
return m_Floodfills.FindClosest (destKey, [&excluded](const std::shared_ptr<RouterInfo>& r)->bool
|
||||
{
|
||||
XORMetric m = destKey ^ it->GetIdentHash ();
|
||||
if (m < minMetric && !excluded.count (it->GetIdentHash ()))
|
||||
{
|
||||
minMetric = m;
|
||||
r = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
return r && !r->IsUnreachable () && !r->GetProfile ()->IsUnreachable () &&
|
||||
!excluded.count (r->GetIdentHash ());
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<IdentHash> NetDb::GetClosestFloodfills (const IdentHash& destination, size_t num,
|
||||
std::set<IdentHash>& excluded, bool closeThanUsOnly) const
|
||||
{
|
||||
struct Sorted
|
||||
{
|
||||
std::shared_ptr<const RouterInfo> r;
|
||||
XORMetric metric;
|
||||
bool operator< (const Sorted& other) const { return metric < other.metric; };
|
||||
};
|
||||
|
||||
std::set<Sorted> sorted;
|
||||
std::vector<IdentHash> res;
|
||||
IdentHash destKey = CreateRoutingKey (destination);
|
||||
XORMetric ourMetric;
|
||||
if (closeThanUsOnly) ourMetric = destKey ^ i2p::context.GetIdentHash ();
|
||||
std::vector<std::shared_ptr<RouterInfo> > v;
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
for (const auto& it: m_Floodfills)
|
||||
{
|
||||
if (!it->IsUnreachable ())
|
||||
v = m_Floodfills.FindClosest (destKey, num, [&excluded](const std::shared_ptr<RouterInfo>& r)->bool
|
||||
{
|
||||
XORMetric m = destKey ^ it->GetIdentHash ();
|
||||
if (closeThanUsOnly && ourMetric < m) continue;
|
||||
if (sorted.size () < num)
|
||||
sorted.insert ({it, m});
|
||||
else if (m < sorted.rbegin ()->metric)
|
||||
{
|
||||
sorted.insert ({it, m});
|
||||
sorted.erase (std::prev (sorted.end ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<IdentHash> res;
|
||||
size_t i = 0;
|
||||
for (const auto& it: sorted)
|
||||
return r && !r->IsUnreachable () && !r->GetProfile ()->IsUnreachable () &&
|
||||
!excluded.count (r->GetIdentHash ());
|
||||
});
|
||||
}
|
||||
if (v.empty ()) return res;
|
||||
|
||||
XORMetric ourMetric;
|
||||
if (closeThanUsOnly) ourMetric = destKey ^ i2p::context.GetIdentHash ();
|
||||
for (auto& it: v)
|
||||
{
|
||||
if (i < num)
|
||||
{
|
||||
const auto& ident = it.r->GetIdentHash ();
|
||||
if (!excluded.count (ident))
|
||||
{
|
||||
res.push_back (ident);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (closeThanUsOnly && ourMetric < (destKey ^ it->GetIdentHash ())) break;
|
||||
res.push_back (it->GetIdentHash ());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1447,10 +1363,11 @@ namespace data
|
||||
m_LeasesPool.CleanUpMt ();
|
||||
}
|
||||
|
||||
void NetDb::PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r)
|
||||
bool NetDb::PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r)
|
||||
{
|
||||
if (!r || r->GetBuffer ()) return;
|
||||
r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
|
||||
if (!r) return false;
|
||||
if (r->GetBuffer ()) return true;
|
||||
return r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <inttypes.h>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
@@ -31,6 +30,7 @@
|
||||
#include "Family.h"
|
||||
#include "version.h"
|
||||
#include "util.h"
|
||||
#include "KadDHT.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
@@ -45,11 +45,8 @@ namespace data
|
||||
const int NETDB_MAX_EXPIRATION_TIMEOUT = 27 * 60 * 60; // 27 hours
|
||||
const int NETDB_MAX_OFFLINE_EXPIRATION_TIMEOUT = 180; // in days
|
||||
const int NETDB_EXPIRATION_TIMEOUT_THRESHOLD = 2*60; // 2 minutes
|
||||
const int NETDB_PUBLISH_INTERVAL = 60 * 40;
|
||||
const int NETDB_PUBLISH_CONFIRMATION_TIMEOUT = 5; // in seconds
|
||||
const int NETDB_MAX_PUBLISH_EXCLUDED_FLOODFILLS = 15;
|
||||
const int NETDB_MIN_HIGHBANDWIDTH_VERSION = MAKE_VERSION_NUMBER(0, 9, 36); // 0.9.36
|
||||
const int NETDB_MIN_FLOODFILL_VERSION = MAKE_VERSION_NUMBER(0, 9, 38); // 0.9.38
|
||||
const int NETDB_MIN_HIGHBANDWIDTH_VERSION = MAKE_VERSION_NUMBER(0, 9, 51); // 0.9.51
|
||||
const int NETDB_MIN_FLOODFILL_VERSION = MAKE_VERSION_NUMBER(0, 9, 51); // 0.9.51
|
||||
const int NETDB_MIN_SHORT_TUNNEL_BUILD_VERSION = MAKE_VERSION_NUMBER(0, 9, 51); // 0.9.51
|
||||
|
||||
/** function for visiting a leaseset stored in a floodfill */
|
||||
@@ -86,14 +83,13 @@ namespace data
|
||||
void HandleDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
void HandleDatabaseLookupMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
void HandleNTCP2RouterInfoMsg (std::shared_ptr<const I2NPMessage> m);
|
||||
void HandleDeliveryStatusMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
|
||||
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
||||
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
||||
std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
|
||||
std::shared_ptr<const RouterInfo> GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const;
|
||||
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
||||
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
||||
std::vector<IdentHash> GetClosestFloodfills (const IdentHash& destination, size_t num,
|
||||
std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
||||
std::shared_ptr<const RouterInfo> GetClosestNonFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
||||
@@ -102,15 +98,12 @@ namespace data
|
||||
|
||||
void PostI2NPMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
|
||||
/** set hidden mode, aka don't publish our RI to netdb and don't explore */
|
||||
void SetHidden(bool hide);
|
||||
|
||||
void Reseed ();
|
||||
Families& GetFamilies () { return m_Families; };
|
||||
|
||||
// for web interface
|
||||
int GetNumRouters () const { return m_RouterInfos.size (); };
|
||||
int GetNumFloodfills () const { return m_Floodfills.size (); };
|
||||
int GetNumFloodfills () const { return m_Floodfills.GetSize (); };
|
||||
int GetNumLeaseSets () const { return m_LeaseSets.size (); };
|
||||
|
||||
/** visit all lease sets we currently store */
|
||||
@@ -124,7 +117,7 @@ namespace data
|
||||
|
||||
void ClearRouterInfos () { m_RouterInfos.clear (); };
|
||||
std::shared_ptr<RouterInfo::Buffer> NewRouterInfoBuffer () { return m_RouterInfoBuffersPool.AcquireSharedMt (); };
|
||||
void PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r);
|
||||
bool PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r);
|
||||
std::shared_ptr<RouterInfo::Address> NewRouterInfoAddress () { return m_RouterInfoAddressesPool.AcquireSharedMt (); };
|
||||
boost::shared_ptr<RouterInfo::Addresses> NewRouterInfoAddresses ()
|
||||
{
|
||||
@@ -144,7 +137,6 @@ namespace data
|
||||
void SaveUpdated ();
|
||||
void Run (); // exploratory thread
|
||||
void Explore (int numDestinations);
|
||||
void Publish ();
|
||||
void Flood (const IdentHash& ident, std::shared_ptr<I2NPMessage> floodMsg);
|
||||
void ManageLeaseSets ();
|
||||
void ManageRequests ();
|
||||
@@ -164,7 +156,7 @@ namespace data
|
||||
mutable std::mutex m_RouterInfosMutex;
|
||||
std::unordered_map<IdentHash, std::shared_ptr<RouterInfo> > m_RouterInfos;
|
||||
mutable std::mutex m_FloodfillsMutex;
|
||||
std::list<std::shared_ptr<RouterInfo> > m_Floodfills;
|
||||
DHTTable m_Floodfills;
|
||||
|
||||
bool m_IsRunning;
|
||||
std::thread * m_Thread;
|
||||
@@ -183,9 +175,6 @@ namespace data
|
||||
/** router info we are bootstrapping from or nullptr if we are not currently doing that*/
|
||||
std::shared_ptr<RouterInfo> m_FloodfillBootstrap;
|
||||
|
||||
/** true if in hidden mode */
|
||||
bool m_HiddenMode;
|
||||
|
||||
std::set<IdentHash> m_PublishExcluded;
|
||||
uint32_t m_PublishReplyToken = 0;
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
#include <thread>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include "Base.h"
|
||||
@@ -19,24 +22,27 @@ namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
i2p::fs::HashedStorage m_ProfilesStorage("peerProfiles", "p", "profile-", "txt");
|
||||
static i2p::fs::HashedStorage g_ProfilesStorage("peerProfiles", "p", "profile-", "txt");
|
||||
static std::unordered_map<i2p::data::IdentHash, std::shared_ptr<RouterProfile> > g_Profiles;
|
||||
static std::mutex g_ProfilesMutex;
|
||||
|
||||
static boost::posix_time::ptime GetTime ()
|
||||
{
|
||||
return boost::posix_time::second_clock::local_time();
|
||||
}
|
||||
|
||||
RouterProfile::RouterProfile ():
|
||||
m_LastUpdateTime (boost::posix_time::second_clock::local_time()),
|
||||
m_LastDeclineTime (0),
|
||||
m_LastUpdateTime (GetTime ()), m_IsUpdated (false),
|
||||
m_LastDeclineTime (0), m_LastUnreachableTime (0),
|
||||
m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0), m_NumTunnelsNonReplied (0),
|
||||
m_NumTimesTaken (0), m_NumTimesRejected (0)
|
||||
{
|
||||
}
|
||||
|
||||
boost::posix_time::ptime RouterProfile::GetTime () const
|
||||
{
|
||||
return boost::posix_time::second_clock::local_time();
|
||||
}
|
||||
|
||||
void RouterProfile::UpdateTime ()
|
||||
{
|
||||
m_LastUpdateTime = GetTime ();
|
||||
m_IsUpdated = true;
|
||||
}
|
||||
|
||||
void RouterProfile::Save (const IdentHash& identHash)
|
||||
@@ -52,12 +58,14 @@ namespace data
|
||||
// fill property tree
|
||||
boost::property_tree::ptree pt;
|
||||
pt.put (PEER_PROFILE_LAST_UPDATE_TIME, boost::posix_time::to_simple_string (m_LastUpdateTime));
|
||||
if (m_LastUnreachableTime)
|
||||
pt.put (PEER_PROFILE_LAST_UNREACHABLE_TIME, m_LastUnreachableTime);
|
||||
pt.put_child (PEER_PROFILE_SECTION_PARTICIPATION, participation);
|
||||
pt.put_child (PEER_PROFILE_SECTION_USAGE, usage);
|
||||
|
||||
// save to file
|
||||
std::string ident = identHash.ToBase64 ();
|
||||
std::string path = m_ProfilesStorage.Path(ident);
|
||||
std::string path = g_ProfilesStorage.Path(ident);
|
||||
|
||||
try {
|
||||
boost::property_tree::write_ini (path, pt);
|
||||
@@ -70,7 +78,7 @@ namespace data
|
||||
void RouterProfile::Load (const IdentHash& identHash)
|
||||
{
|
||||
std::string ident = identHash.ToBase64 ();
|
||||
std::string path = m_ProfilesStorage.Path(ident);
|
||||
std::string path = g_ProfilesStorage.Path(ident);
|
||||
boost::property_tree::ptree pt;
|
||||
|
||||
if (!i2p::fs::Exists(path))
|
||||
@@ -96,6 +104,7 @@ namespace data
|
||||
m_LastUpdateTime = boost::posix_time::time_from_string (t);
|
||||
if ((GetTime () - m_LastUpdateTime).hours () < PEER_PROFILE_EXPIRATION_TIMEOUT)
|
||||
{
|
||||
m_LastUnreachableTime = pt.get (PEER_PROFILE_LAST_UNREACHABLE_TIME, 0);
|
||||
try
|
||||
{
|
||||
// read participations
|
||||
@@ -133,15 +142,15 @@ namespace data
|
||||
{
|
||||
UpdateTime ();
|
||||
if (ret > 0)
|
||||
{
|
||||
{
|
||||
m_NumTunnelsDeclined++;
|
||||
m_LastDeclineTime = i2p::util::GetSecondsSinceEpoch ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
m_NumTunnelsAgreed++;
|
||||
m_LastDeclineTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RouterProfile::TunnelNonReplied ()
|
||||
@@ -152,6 +161,12 @@ namespace data
|
||||
m_LastDeclineTime = i2p::util::GetSecondsSinceEpoch ();
|
||||
}
|
||||
|
||||
void RouterProfile::Unreachable ()
|
||||
{
|
||||
m_LastUnreachableTime = i2p::util::GetSecondsSinceEpoch ();
|
||||
UpdateTime ();
|
||||
}
|
||||
|
||||
bool RouterProfile::IsLowPartcipationRate () const
|
||||
{
|
||||
return 4*m_NumTunnelsAgreed < m_NumTunnelsDeclined; // < 20% rate
|
||||
@@ -167,14 +182,15 @@ namespace data
|
||||
{
|
||||
if (!m_LastDeclineTime) return false;
|
||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
if (ts > m_LastDeclineTime + PEER_PROFILE_DECLINED_RECENTLY_INTERVAL)
|
||||
if (ts > m_LastDeclineTime + PEER_PROFILE_DECLINED_RECENTLY_INTERVAL ||
|
||||
ts + PEER_PROFILE_DECLINED_RECENTLY_INTERVAL < m_LastDeclineTime)
|
||||
m_LastDeclineTime = 0;
|
||||
return m_LastDeclineTime;
|
||||
}
|
||||
|
||||
return (bool)m_LastDeclineTime;
|
||||
}
|
||||
|
||||
bool RouterProfile::IsBad ()
|
||||
{
|
||||
if (IsDeclinedRecently ()) return true;
|
||||
if (IsDeclinedRecently () || IsUnreachable ()) return true;
|
||||
auto isBad = IsAlwaysDeclining () || IsLowPartcipationRate () /*|| IsLowReplyRate ()*/;
|
||||
if (isBad && m_NumTimesRejected > 10*(m_NumTimesTaken + 1))
|
||||
{
|
||||
@@ -188,32 +204,98 @@ namespace data
|
||||
return isBad;
|
||||
}
|
||||
|
||||
bool RouterProfile::IsUnreachable ()
|
||||
{
|
||||
if (!m_LastUnreachableTime) return false;
|
||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
if (ts > m_LastUnreachableTime + PEER_PROFILE_UNREACHABLE_INTERVAL ||
|
||||
ts + PEER_PROFILE_UNREACHABLE_INTERVAL < m_LastUnreachableTime)
|
||||
m_LastUnreachableTime = 0;
|
||||
return (bool)m_LastUnreachableTime;
|
||||
}
|
||||
|
||||
std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
||||
auto it = g_Profiles.find (identHash);
|
||||
if (it != g_Profiles.end ())
|
||||
return it->second;
|
||||
}
|
||||
auto profile = std::make_shared<RouterProfile> ();
|
||||
profile->Load (identHash); // if possible
|
||||
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
||||
g_Profiles.emplace (identHash, profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
void InitProfilesStorage ()
|
||||
{
|
||||
m_ProfilesStorage.SetPlace(i2p::fs::GetDataDir());
|
||||
m_ProfilesStorage.Init(i2p::data::GetBase64SubstitutionTable(), 64);
|
||||
g_ProfilesStorage.SetPlace(i2p::fs::GetDataDir());
|
||||
g_ProfilesStorage.Init(i2p::data::GetBase64SubstitutionTable(), 64);
|
||||
}
|
||||
|
||||
void PersistProfiles ()
|
||||
{
|
||||
auto ts = GetTime ();
|
||||
std::list<std::pair<i2p::data::IdentHash, std::shared_ptr<RouterProfile> > > tmp;
|
||||
{
|
||||
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
||||
for (auto it = g_Profiles.begin (); it != g_Profiles.end ();)
|
||||
{
|
||||
if ((ts - it->second->GetLastUpdateTime ()).total_seconds () > PEER_PROFILE_PERSIST_INTERVAL)
|
||||
{
|
||||
if (it->second->IsUpdated ())
|
||||
tmp.push_back (std::make_pair (it->first, it->second));
|
||||
it = g_Profiles.erase (it);
|
||||
}
|
||||
else
|
||||
it++;
|
||||
}
|
||||
}
|
||||
for (auto& it: tmp)
|
||||
if (it.second) it.second->Save (it.first);
|
||||
}
|
||||
|
||||
void SaveProfiles ()
|
||||
{
|
||||
std::unordered_map<i2p::data::IdentHash, std::shared_ptr<RouterProfile> > tmp;
|
||||
{
|
||||
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
||||
tmp = g_Profiles;
|
||||
g_Profiles.clear ();
|
||||
}
|
||||
auto ts = GetTime ();
|
||||
for (auto& it: tmp)
|
||||
if (it.second->IsUpdated () && (ts - it.second->GetLastUpdateTime ()).total_seconds () < PEER_PROFILE_EXPIRATION_TIMEOUT*3600)
|
||||
it.second->Save (it.first);
|
||||
}
|
||||
|
||||
void DeleteObsoleteProfiles ()
|
||||
{
|
||||
{
|
||||
auto ts = GetTime ();
|
||||
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
||||
for (auto it = g_Profiles.begin (); it != g_Profiles.end ();)
|
||||
{
|
||||
if ((ts - it->second->GetLastUpdateTime ()).total_seconds () >= PEER_PROFILE_EXPIRATION_TIMEOUT*3600)
|
||||
it = g_Profiles.erase (it);
|
||||
else
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
std::time_t now = std::time(nullptr);
|
||||
|
||||
std::vector<std::string> files;
|
||||
m_ProfilesStorage.Traverse(files);
|
||||
g_ProfilesStorage.Traverse(files);
|
||||
for (const auto& path: files) {
|
||||
if (stat(path.c_str(), &st) != 0) {
|
||||
LogPrint(eLogWarning, "Profiling: Can't stat(): ", path);
|
||||
continue;
|
||||
}
|
||||
if (((now - st.st_mtime) / 3600) >= PEER_PROFILE_EXPIRATION_TIMEOUT) {
|
||||
if (now - st.st_mtime >= PEER_PROFILE_EXPIRATION_TIMEOUT*3600) {
|
||||
LogPrint(eLogDebug, "Profiling: Removing expired peer profile: ", path);
|
||||
i2p::fs::Remove(path);
|
||||
}
|
||||
|
||||
@@ -22,16 +22,19 @@ namespace data
|
||||
const char PEER_PROFILE_SECTION_USAGE[] = "usage";
|
||||
// params
|
||||
const char PEER_PROFILE_LAST_UPDATE_TIME[] = "lastupdatetime";
|
||||
const char PEER_PROFILE_LAST_UNREACHABLE_TIME[] = "lastunreachabletime";
|
||||
const char PEER_PROFILE_PARTICIPATION_AGREED[] = "agreed";
|
||||
const char PEER_PROFILE_PARTICIPATION_DECLINED[] = "declined";
|
||||
const char PEER_PROFILE_PARTICIPATION_NON_REPLIED[] = "nonreplied";
|
||||
const char PEER_PROFILE_USAGE_TAKEN[] = "taken";
|
||||
const char PEER_PROFILE_USAGE_REJECTED[] = "rejected";
|
||||
|
||||
const int PEER_PROFILE_EXPIRATION_TIMEOUT = 72; // in hours (3 days)
|
||||
const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 24 * 3600; // in seconds (1 day)
|
||||
const int PEER_PROFILE_AUTOCLEAN_VARIANCE = 3 * 3600; // in seconds (3 hours)
|
||||
const int PEER_PROFILE_EXPIRATION_TIMEOUT = 36; // in hours (1.5 days)
|
||||
const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 6 * 3600; // in seconds (6 hours)
|
||||
const int PEER_PROFILE_AUTOCLEAN_VARIANCE = 3600; // in seconds (1 hour)
|
||||
const int PEER_PROFILE_DECLINED_RECENTLY_INTERVAL = 150; // in seconds (2.5 minutes)
|
||||
const int PEER_PROFILE_PERSIST_INTERVAL = 3300; // in seconds (55 minutes)
|
||||
const int PEER_PROFILE_UNREACHABLE_INTERVAL = 2*3600; // on seconds (2 hours)
|
||||
|
||||
class RouterProfile
|
||||
{
|
||||
@@ -44,13 +47,18 @@ namespace data
|
||||
void Load (const IdentHash& identHash);
|
||||
|
||||
bool IsBad ();
|
||||
bool IsUnreachable ();
|
||||
|
||||
void TunnelBuildResponse (uint8_t ret);
|
||||
void TunnelNonReplied ();
|
||||
|
||||
void Unreachable ();
|
||||
|
||||
boost::posix_time::ptime GetLastUpdateTime () const { return m_LastUpdateTime; };
|
||||
bool IsUpdated () const { return m_IsUpdated; };
|
||||
|
||||
private:
|
||||
|
||||
boost::posix_time::ptime GetTime () const;
|
||||
void UpdateTime ();
|
||||
|
||||
bool IsAlwaysDeclining () const { return !m_NumTunnelsAgreed && m_NumTunnelsDeclined >= 5; };
|
||||
@@ -61,7 +69,8 @@ namespace data
|
||||
private:
|
||||
|
||||
boost::posix_time::ptime m_LastUpdateTime; // TODO: use std::chrono
|
||||
uint64_t m_LastDeclineTime; // in seconds
|
||||
bool m_IsUpdated;
|
||||
uint64_t m_LastDeclineTime, m_LastUnreachableTime; // in seconds
|
||||
// participation
|
||||
uint32_t m_NumTunnelsAgreed;
|
||||
uint32_t m_NumTunnelsDeclined;
|
||||
@@ -74,6 +83,8 @@ namespace data
|
||||
std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash);
|
||||
void InitProfilesStorage ();
|
||||
void DeleteObsoleteProfiles ();
|
||||
void SaveProfiles ();
|
||||
void PersistProfiles ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -320,7 +320,7 @@ namespace data
|
||||
uint16_t fileNameLength, extraFieldLength;
|
||||
s.read ((char *)&fileNameLength, 2);
|
||||
fileNameLength = le16toh (fileNameLength);
|
||||
if ( fileNameLength > 255 ) {
|
||||
if ( fileNameLength >= 255 ) {
|
||||
// too big
|
||||
LogPrint(eLogError, "Reseed: SU3 fileNameLength too large: ", fileNameLength);
|
||||
return numFiles;
|
||||
@@ -687,12 +687,23 @@ namespace data
|
||||
while (it != end)
|
||||
{
|
||||
boost::asio::ip::tcp::endpoint ep = *it;
|
||||
if ((ep.address ().is_v4 () && i2p::context.SupportsV4 ()) ||
|
||||
(ep.address ().is_v6 () && i2p::context.SupportsV6 ()))
|
||||
if (
|
||||
(
|
||||
!i2p::util::net::IsInReservedRange(ep.address ()) && (
|
||||
(ep.address ().is_v4 () && i2p::context.SupportsV4 ()) ||
|
||||
(ep.address ().is_v6 () && i2p::context.SupportsV6 ())
|
||||
)
|
||||
) ||
|
||||
(
|
||||
i2p::util::net::IsYggdrasilAddress (ep.address ()) &&
|
||||
i2p::context.SupportsMesh ()
|
||||
)
|
||||
)
|
||||
{
|
||||
s.lowest_layer().connect (ep, ecode);
|
||||
if (!ecode)
|
||||
{
|
||||
LogPrint (eLogDebug, "Reseed: Resolved to ", ep.address ());
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
@@ -780,17 +791,45 @@ namespace data
|
||||
boost::asio::io_service service;
|
||||
boost::asio::ip::tcp::socket s(service, boost::asio::ip::tcp::v6());
|
||||
|
||||
if (url.host.length () < 2) return ""; // assume []
|
||||
auto host = url.host.substr (1, url.host.length () - 2);
|
||||
LogPrint (eLogDebug, "Reseed: Connecting to Yggdrasil ", url.host, ":", url.port);
|
||||
s.connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v6::from_string (host), url.port), ecode);
|
||||
auto it = boost::asio::ip::tcp::resolver(service).resolve (
|
||||
boost::asio::ip::tcp::resolver::query (url.host, std::to_string(url.port)), ecode);
|
||||
|
||||
if (!ecode)
|
||||
{
|
||||
LogPrint (eLogDebug, "Reseed: Connected to Yggdrasil ", url.host, ":", url.port);
|
||||
bool connected = false;
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
while (it != end)
|
||||
{
|
||||
boost::asio::ip::tcp::endpoint ep = *it;
|
||||
if (
|
||||
i2p::util::net::IsYggdrasilAddress (ep.address ()) &&
|
||||
i2p::context.SupportsMesh ()
|
||||
)
|
||||
{
|
||||
LogPrint (eLogDebug, "Reseed: Yggdrasil: Resolved to ", ep.address ());
|
||||
s.connect (ep, ecode);
|
||||
if (!ecode)
|
||||
{
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
it++;
|
||||
}
|
||||
if (!connected)
|
||||
{
|
||||
LogPrint(eLogError, "Reseed: Yggdrasil: Failed to connect to ", url.host);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!ecode)
|
||||
{
|
||||
LogPrint (eLogDebug, "Reseed: Yggdrasil: Connected to ", url.host, ":", url.port);
|
||||
return ReseedRequest (s, url.to_string());
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Reseed: Couldn't connect to Yggdrasil ", url.host, ": ", ecode.message ());
|
||||
LogPrint (eLogError, "Reseed: Yggdrasil: Couldn't connect to ", url.host, ": ", ecode.message ());
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "Log.h"
|
||||
#include "Family.h"
|
||||
#include "ECIESX25519AEADRatchetSession.h"
|
||||
#include "Transports.h"
|
||||
#include "Tunnel.h"
|
||||
#include "RouterContext.h"
|
||||
|
||||
namespace i2p
|
||||
@@ -29,7 +31,8 @@ namespace i2p
|
||||
RouterContext::RouterContext ():
|
||||
m_LastUpdateTime (0), m_AcceptsTunnels (true), m_IsFloodfill (false),
|
||||
m_ShareRatio (100), m_Status (eRouterStatusUnknown), m_StatusV6 (eRouterStatusUnknown),
|
||||
m_Error (eRouterErrorNone), m_ErrorV6 (eRouterErrorNone), m_NetID (I2PD_NET_ID)
|
||||
m_Error (eRouterErrorNone), m_ErrorV6 (eRouterErrorNone), m_NetID (I2PD_NET_ID),
|
||||
m_PublishReplyToken (0), m_IsHiddenMode (false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,6 +50,34 @@ namespace i2p
|
||||
m_ECIESSession = std::make_shared<i2p::garlic::RouterIncomingRatchetSession>(m_InitialNoiseState);
|
||||
}
|
||||
|
||||
void RouterContext::Start ()
|
||||
{
|
||||
if (!m_Service)
|
||||
{
|
||||
m_Service.reset (new RouterService);
|
||||
m_Service->Start ();
|
||||
if (!m_IsHiddenMode)
|
||||
{
|
||||
m_PublishTimer.reset (new boost::asio::deadline_timer (m_Service->GetService ()));
|
||||
ScheduleInitialPublish ();
|
||||
m_CongestionUpdateTimer.reset (new boost::asio::deadline_timer (m_Service->GetService ()));
|
||||
ScheduleCongestionUpdate ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RouterContext::Stop ()
|
||||
{
|
||||
if (m_Service)
|
||||
{
|
||||
if (m_PublishTimer)
|
||||
m_PublishTimer->cancel ();
|
||||
if (m_CongestionUpdateTimer)
|
||||
m_CongestionUpdateTimer->cancel ();
|
||||
m_Service->Stop ();
|
||||
}
|
||||
}
|
||||
|
||||
void RouterContext::CreateNewRouter ()
|
||||
{
|
||||
m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519,
|
||||
@@ -85,96 +116,103 @@ namespace i2p
|
||||
bool ssu2Published = false;
|
||||
if (ssu2)
|
||||
i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||
uint8_t caps = 0, addressCaps = 0;
|
||||
uint8_t caps = 0;
|
||||
if (ipv4)
|
||||
{
|
||||
std::string host = "127.0.0.1";
|
||||
if (!i2p::config::IsDefault("host"))
|
||||
i2p::config::GetOption("host", host);
|
||||
else if (!nat)
|
||||
{
|
||||
std::string host;
|
||||
if (!nat)
|
||||
// we have no NAT so set external address from local address
|
||||
std::string address4; i2p::config::GetOption("address4", address4);
|
||||
if (!address4.empty ()) host = address4;
|
||||
}
|
||||
i2p::config::GetOption("address4", host);
|
||||
if (host.empty ()) i2p::config::GetOption("host", host);
|
||||
|
||||
if (ntcp2)
|
||||
{
|
||||
if (ntcp2Published)
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address_v4::from_string (host), port);
|
||||
else // add non-published NTCP2 address
|
||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||
if (!ntcp2Port) ntcp2Port = port;
|
||||
if (ntcp2Published && ntcp2Port)
|
||||
{
|
||||
addressCaps = i2p::data::RouterInfo::AddressCaps::eV4;
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv);
|
||||
boost::asio::ip::address addr;
|
||||
if (!host.empty ())
|
||||
addr = boost::asio::ip::address::from_string (host);
|
||||
if (!addr.is_v4())
|
||||
addr = boost::asio::ip::address_v4 ();
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, addr, ntcp2Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add non-published NTCP2 address
|
||||
uint8_t addressCaps = i2p::data::RouterInfo::AddressCaps::eV4;
|
||||
if (ipv6) addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6;
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, ntcp2Port, addressCaps);
|
||||
}
|
||||
}
|
||||
if (ssu2)
|
||||
{
|
||||
if (ssu2Published)
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
if (ssu2Published && ssu2Port)
|
||||
{
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v4::from_string (host), ssu2Port);
|
||||
boost::asio::ip::address addr;
|
||||
if (!host.empty ())
|
||||
addr = boost::asio::ip::address::from_string (host);
|
||||
if (!addr.is_v4())
|
||||
addr = boost::asio::ip::address_v4 ();
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, addr, ssu2Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4;
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro);
|
||||
uint8_t addressCaps = i2p::data::RouterInfo::AddressCaps::eV4;
|
||||
if (ipv6) addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6;
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, ssu2Port, addressCaps);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ipv6)
|
||||
{
|
||||
std::string host;
|
||||
if (!i2p::config::IsDefault("host") && !ipv4) // override if v6 only
|
||||
i2p::config::GetOption("host", host);
|
||||
else
|
||||
{
|
||||
std::string address6; i2p::config::GetOption("address6", address6);
|
||||
if (!address6.empty ()) host = address6;
|
||||
}
|
||||
std::string host; i2p::config::GetOption("address6", host);
|
||||
if (host.empty () && !ipv4) i2p::config::GetOption("host", host); // use host for ipv6 only if ipv4 is not presented
|
||||
|
||||
if (ntcp2)
|
||||
{
|
||||
bool added = false;
|
||||
if (ntcp2Published)
|
||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||
if (!ntcp2Port) ntcp2Port = port;
|
||||
if (ntcp2Published && ntcp2Port)
|
||||
{
|
||||
std::string ntcp2Host;
|
||||
if (!i2p::config::IsDefault ("ntcp2.addressv6"))
|
||||
i2p::config::GetOption ("ntcp2.addressv6", ntcp2Host);
|
||||
else
|
||||
ntcp2Host = host;
|
||||
if (!ntcp2Host.empty () && port)
|
||||
{
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address_v6::from_string (ntcp2Host), port);
|
||||
added = true;
|
||||
}
|
||||
boost::asio::ip::address addr;
|
||||
if (!ntcp2Host.empty ())
|
||||
addr = boost::asio::ip::address::from_string (ntcp2Host);
|
||||
if (!addr.is_v6())
|
||||
addr = boost::asio::ip::address_v6 ();
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, addr, ntcp2Port);
|
||||
}
|
||||
if (!added)
|
||||
else
|
||||
{
|
||||
if (!ipv4) // no other ntcp2 addresses yet
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv);
|
||||
addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6;
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, ntcp2Port, i2p::data::RouterInfo::AddressCaps::eV6);
|
||||
}
|
||||
}
|
||||
if (ssu2)
|
||||
{
|
||||
bool added = false;
|
||||
if (ssu2Published)
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
if (ssu2Published && ssu2Port)
|
||||
{
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
if (!host.empty () && ssu2Port)
|
||||
{
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v6::from_string (host), ssu2Port);
|
||||
added = true;
|
||||
}
|
||||
boost::asio::ip::address addr;
|
||||
if (!host.empty ())
|
||||
addr = boost::asio::ip::address::from_string (host);
|
||||
if (!addr.is_v6())
|
||||
addr = boost::asio::ip::address_v6 ();
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, addr, ssu2Port);
|
||||
}
|
||||
if (!added)
|
||||
else
|
||||
{
|
||||
if (!ipv4) // no other ssu2 addresses yet
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro);
|
||||
addressCaps |= i2p::data::RouterInfo::AddressCaps::eV6;
|
||||
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, ssu2Port, i2p::data::RouterInfo::AddressCaps::eV6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,8 +223,6 @@ namespace i2p
|
||||
routerInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, yggaddr, port);
|
||||
}
|
||||
|
||||
if (addressCaps)
|
||||
routerInfo.SetUnreachableAddressesTransportCaps (addressCaps);
|
||||
routerInfo.UpdateCaps (caps); // caps + L
|
||||
routerInfo.SetProperty ("netId", std::to_string (m_NetID));
|
||||
routerInfo.SetProperty ("router.version", I2P_VERSION);
|
||||
@@ -197,8 +233,13 @@ namespace i2p
|
||||
|
||||
uint16_t RouterContext::SelectRandomPort () const
|
||||
{
|
||||
uint16_t port = rand () % (30777 - 9111) + 9111; // I2P network ports range
|
||||
if (port == 9150) port = 9151; // Tor browser
|
||||
uint16_t port;
|
||||
do
|
||||
{
|
||||
port = rand () % (30777 - 9111) + 9111; // I2P network ports range
|
||||
}
|
||||
while(i2p::util::net::IsPortInReservedRange(port));
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
@@ -250,7 +291,7 @@ namespace i2p
|
||||
break;
|
||||
case eRouterStatusTesting:
|
||||
m_Error = eRouterErrorNone;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
@@ -272,7 +313,7 @@ namespace i2p
|
||||
break;
|
||||
case eRouterStatusTesting:
|
||||
m_ErrorV6 = eRouterErrorNone;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
@@ -286,7 +327,7 @@ namespace i2p
|
||||
bool updated = false;
|
||||
for (auto& address : *addresses)
|
||||
{
|
||||
if (address && address->port != port && address->transportStyle == i2p::data::RouterInfo::eTransportSSU2)
|
||||
if (address && address->port != port)
|
||||
{
|
||||
address->port = port;
|
||||
updated = true;
|
||||
@@ -296,65 +337,67 @@ namespace i2p
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::PublishNTCP2Address (std::shared_ptr<i2p::data::RouterInfo::Address> address,
|
||||
int port, bool publish) const
|
||||
{
|
||||
if (!address) return;
|
||||
if (!port && !address->port) port = SelectRandomPort ();
|
||||
if (port) address->port = port;
|
||||
address->published = publish;
|
||||
memcpy (address->i, m_NTCP2Keys->iv, 16);
|
||||
}
|
||||
|
||||
void RouterContext::PublishNTCP2Address (int port, bool publish, bool v4, bool v6, bool ygg)
|
||||
{
|
||||
if (!m_NTCP2Keys) return;
|
||||
auto addresses = m_RouterInfo.GetAddresses ();
|
||||
if (!addresses) return;
|
||||
bool updated = false;
|
||||
for (auto& address : *addresses)
|
||||
if (v4)
|
||||
{
|
||||
if (address && address->IsNTCP2 () && (address->port != port || address->published != publish))
|
||||
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V4Idx];
|
||||
if (addr && (addr->port != port || addr->published != publish))
|
||||
{
|
||||
bool isAddr = v4 && address->IsV4 ();
|
||||
if (!isAddr && (v6 || ygg))
|
||||
{
|
||||
if (i2p::util::net::IsYggdrasilAddress (address->host))
|
||||
isAddr = ygg;
|
||||
else
|
||||
isAddr = v6 && address->IsV6 ();
|
||||
}
|
||||
if (isAddr)
|
||||
{
|
||||
if (!port && !address->port) port = SelectRandomPort ();
|
||||
if (port) address->port = port;
|
||||
address->published = publish;
|
||||
memcpy (address->i, m_NTCP2Keys->iv, 16);
|
||||
updated = true;
|
||||
}
|
||||
PublishNTCP2Address (addr, port, publish);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
if (v6)
|
||||
{
|
||||
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6Idx];
|
||||
if (addr && (addr->port != port || addr->published != publish))
|
||||
{
|
||||
PublishNTCP2Address (addr, port, publish);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
if (ygg)
|
||||
{
|
||||
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6MeshIdx];
|
||||
if (addr && (addr->port != port || addr->published != publish))
|
||||
{
|
||||
PublishNTCP2Address (addr, port, publish);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated)
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::UpdateNTCP2Address (bool enable)
|
||||
void RouterContext::UpdateNTCP2Keys ()
|
||||
{
|
||||
if (!m_NTCP2Keys) return;
|
||||
auto addresses = m_RouterInfo.GetAddresses ();
|
||||
if (!addresses) return;
|
||||
bool found = false, updated = false;
|
||||
for (auto& it: *addresses)
|
||||
{
|
||||
if (it && it->IsNTCP2 ())
|
||||
{
|
||||
found = true;
|
||||
if (enable)
|
||||
{
|
||||
it->s = m_NTCP2Keys->staticPublicKey;
|
||||
memcpy (it->i, m_NTCP2Keys->iv, 16);
|
||||
}
|
||||
else
|
||||
it.reset ();
|
||||
updated = true;
|
||||
it->s = m_NTCP2Keys->staticPublicKey;
|
||||
memcpy (it->i, m_NTCP2Keys->iv, 16);
|
||||
}
|
||||
}
|
||||
if (enable && !found)
|
||||
{
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv);
|
||||
updated = true;
|
||||
}
|
||||
if (updated)
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::PublishSSU2Address (int port, bool publish, bool v4, bool v6)
|
||||
@@ -393,47 +436,19 @@ namespace i2p
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::UpdateSSU2Address (bool enable)
|
||||
void RouterContext::UpdateSSU2Keys ()
|
||||
{
|
||||
if (!m_SSU2Keys) return;
|
||||
auto addresses = m_RouterInfo.GetAddresses ();
|
||||
if (!addresses) return;
|
||||
bool found = false, updated = false;
|
||||
for (auto& it : *addresses)
|
||||
for (auto& it: *addresses)
|
||||
{
|
||||
if (it && it->IsSSU2 ())
|
||||
{
|
||||
found = true;
|
||||
if (enable)
|
||||
{
|
||||
it->s = m_SSU2Keys->staticPublicKey;
|
||||
it->i = m_SSU2Keys->intro;
|
||||
}
|
||||
else
|
||||
it.reset ();
|
||||
updated = true;
|
||||
it->s = m_SSU2Keys->staticPublicKey;
|
||||
it->i = m_SSU2Keys->intro;
|
||||
}
|
||||
}
|
||||
if (enable && !found)
|
||||
{
|
||||
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
|
||||
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
||||
bool published; i2p::config::GetOption("ntcp2.published", published);
|
||||
if (published)
|
||||
{
|
||||
if (ipv4) m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::AddressCaps::eV4);
|
||||
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)
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::UpdateAddress (const boost::asio::ip::address& host)
|
||||
@@ -728,45 +743,69 @@ namespace i2p
|
||||
if (!port) port = SelectRandomPort ();
|
||||
}
|
||||
// NTCP2
|
||||
if (!foundNTCP2)
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
if (ntcp2)
|
||||
{
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||
if (ntcp2)
|
||||
if (!foundNTCP2)
|
||||
{
|
||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||
if (!ntcp2Port) ntcp2Port = port;
|
||||
bool added = false;
|
||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||
if (ntcp2Published)
|
||||
{
|
||||
std::string ntcp2Host;
|
||||
if (!i2p::config::IsDefault ("ntcp2.addressv6"))
|
||||
i2p::config::GetOption ("ntcp2.addressv6", ntcp2Host);
|
||||
else
|
||||
ntcp2Host = "::1";
|
||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||
if (!ntcp2Port) ntcp2Port = port;
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address::from_string (ntcp2Host), ntcp2Port);
|
||||
i2p::config::GetOption("host", ntcp2Host);
|
||||
if (!ntcp2Host.empty () && ntcp2Port)
|
||||
{
|
||||
auto addr = boost::asio::ip::address::from_string (ntcp2Host);
|
||||
if (addr.is_v6 ())
|
||||
{
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, addr, ntcp2Port);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV6);
|
||||
if (!added)
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, ntcp2Port, i2p::data::RouterInfo::eV6);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.RemoveNTCP2Address (false);
|
||||
// SSU2
|
||||
if (!foundSSU2)
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
{
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
if (!foundSSU2)
|
||||
{
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
bool added = false;
|
||||
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||
if (ssu2Published)
|
||||
if (ssu2Published && ssu2Port)
|
||||
{
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("::1"), ssu2Port);
|
||||
std::string host; i2p::config::GetOption("host", host);
|
||||
if (!host.empty ())
|
||||
{
|
||||
auto addr = boost::asio::ip::address::from_string (host);
|
||||
if (addr.is_v6 ())
|
||||
{
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, addr, ssu2Port);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV6);
|
||||
if (!added)
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, ssu2Port, i2p::data::RouterInfo::eV6);
|
||||
}
|
||||
}
|
||||
m_RouterInfo.EnableV6 ();
|
||||
else
|
||||
m_RouterInfo.RemoveSSU2Address (false);
|
||||
if (ntcp2 || ssu2)
|
||||
m_RouterInfo.EnableV6 ();
|
||||
}
|
||||
else
|
||||
m_RouterInfo.DisableV6 ();
|
||||
@@ -775,14 +814,9 @@ namespace i2p
|
||||
|
||||
void RouterContext::SetSupportsV4 (bool supportsV4)
|
||||
{
|
||||
// check if updates
|
||||
if (supportsV4 && SupportsV4 ()) return;
|
||||
if (!supportsV4 && !SupportsV4 ()) return;
|
||||
// update
|
||||
if (supportsV4)
|
||||
{
|
||||
bool foundNTCP2 = false, foundSSU2 = false;
|
||||
std::string host = "127.0.0.1";
|
||||
uint16_t port = 0;
|
||||
auto addresses = m_RouterInfo.GetAddresses ();
|
||||
if (addresses)
|
||||
@@ -811,40 +845,66 @@ namespace i2p
|
||||
if (!port) port = SelectRandomPort ();
|
||||
}
|
||||
// NTCP2
|
||||
if (!foundNTCP2)
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
if (ntcp2)
|
||||
{
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
if (ntcp2)
|
||||
if (!foundNTCP2)
|
||||
{
|
||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||
if (!ntcp2Port) ntcp2Port = port;
|
||||
bool added = false;
|
||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||
if (ntcp2Published)
|
||||
if (ntcp2Published && ntcp2Port)
|
||||
{
|
||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||
if (!ntcp2Port) ntcp2Port = port;
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address::from_string (host), ntcp2Port);
|
||||
std::string host; i2p::config::GetOption("host", host);
|
||||
if (!host.empty ())
|
||||
{
|
||||
auto addr = boost::asio::ip::address::from_string (host);
|
||||
if (addr.is_v4 ())
|
||||
{
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, addr, ntcp2Port);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV4);
|
||||
if (!added)
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, ntcp2Port, i2p::data::RouterInfo::eV4);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.RemoveNTCP2Address (true);
|
||||
// SSU2
|
||||
if (!foundSSU2)
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
{
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
if (!foundSSU2)
|
||||
{
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
bool added = false;
|
||||
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||
if (ssu2Published)
|
||||
std::string host; i2p::config::GetOption("host", host);
|
||||
if (ssu2Published && ssu2Port)
|
||||
{
|
||||
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||
if (!ssu2Port) ssu2Port = port;
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("127.0.0.1"), ssu2Port);
|
||||
std::string host; i2p::config::GetOption("host", host);
|
||||
if (!host.empty ())
|
||||
{
|
||||
auto addr = boost::asio::ip::address::from_string (host);
|
||||
if (addr.is_v4 ())
|
||||
{
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, addr, ssu2Port);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV4);
|
||||
if (!added)
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, ssu2Port, i2p::data::RouterInfo::eV4);
|
||||
}
|
||||
}
|
||||
m_RouterInfo.EnableV4 ();
|
||||
else
|
||||
m_RouterInfo.RemoveSSU2Address (true);
|
||||
if (ntcp2 || ssu2)
|
||||
m_RouterInfo.EnableV4 ();
|
||||
}
|
||||
else
|
||||
m_RouterInfo.DisableV4 ();
|
||||
@@ -898,29 +958,18 @@ namespace i2p
|
||||
|
||||
void RouterContext::UpdateNTCP2V6Address (const boost::asio::ip::address& host)
|
||||
{
|
||||
bool isYgg = i2p::util::net::IsYggdrasilAddress (host);
|
||||
bool updated = false;
|
||||
auto addresses = m_RouterInfo.GetAddresses ();
|
||||
if (!addresses) return;
|
||||
for (auto& addr: *addresses)
|
||||
std::shared_ptr<i2p::data::RouterInfo::Address> addr;
|
||||
if (i2p::util::net::IsYggdrasilAddress (host)) // yggdrasil
|
||||
addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6MeshIdx];
|
||||
else if (host.is_v6 ())
|
||||
addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6Idx];
|
||||
if (addr && addr->IsPublishedNTCP2 () && addr->host != host)
|
||||
{
|
||||
if (addr && addr->IsPublishedNTCP2 ())
|
||||
{
|
||||
bool isYgg1 = i2p::util::net::IsYggdrasilAddress (addr->host);
|
||||
if (addr->IsV6 () && ((isYgg && isYgg1) || (!isYgg && !isYgg1)))
|
||||
{
|
||||
if (addr->host != host)
|
||||
{
|
||||
addr->host = host;
|
||||
updated = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updated)
|
||||
addr->host = host;
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
}
|
||||
|
||||
void RouterContext::UpdateStats ()
|
||||
@@ -988,6 +1037,20 @@ namespace i2p
|
||||
}
|
||||
n2k.close ();
|
||||
}
|
||||
// read SSU2 keys if available
|
||||
std::ifstream s2k (i2p::fs::DataDirPath (SSU2_KEYS), std::ifstream::in | std::ifstream::binary);
|
||||
if (s2k)
|
||||
{
|
||||
s2k.seekg (0, std::ios::end);
|
||||
size_t len = s2k.tellg();
|
||||
s2k.seekg (0, std::ios::beg);
|
||||
if (len == sizeof (SSU2PrivateKeys))
|
||||
{
|
||||
m_SSU2Keys.reset (new SSU2PrivateKeys ());
|
||||
s2k.read ((char *)m_SSU2Keys.get (), sizeof (SSU2PrivateKeys));
|
||||
}
|
||||
s2k.close ();
|
||||
}
|
||||
// read RouterInfo
|
||||
m_RouterInfo.SetRouterIdentity (oldIdentity ? oldIdentity : GetIdentity ());
|
||||
i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO));
|
||||
@@ -1008,40 +1071,26 @@ namespace i2p
|
||||
if (IsUnreachable ())
|
||||
SetReachable (true, true); // we assume reachable until we discover firewall through peer tests
|
||||
|
||||
// read NTCP2
|
||||
bool updated = false;
|
||||
// create new NTCP2 keys if required
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
|
||||
if (ntcp2 || ygg)
|
||||
if ((ntcp2 || ygg) && !m_NTCP2Keys)
|
||||
{
|
||||
if (!m_NTCP2Keys) NewNTCP2Keys ();
|
||||
UpdateNTCP2Address (true); // enable NTCP2
|
||||
NewNTCP2Keys ();
|
||||
UpdateNTCP2Keys ();
|
||||
updated = true;
|
||||
}
|
||||
else
|
||||
UpdateNTCP2Address (false); // disable NTCP2
|
||||
|
||||
// read SSU2
|
||||
// create new SSU2 keys if required
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
if (ssu2 && !m_SSU2Keys)
|
||||
{
|
||||
// read SSU2 keys if available
|
||||
std::ifstream s2k (i2p::fs::DataDirPath (SSU2_KEYS), std::ifstream::in | std::ifstream::binary);
|
||||
if (s2k)
|
||||
{
|
||||
s2k.seekg (0, std::ios::end);
|
||||
size_t len = s2k.tellg();
|
||||
s2k.seekg (0, std::ios::beg);
|
||||
if (len == sizeof (SSU2PrivateKeys))
|
||||
{
|
||||
m_SSU2Keys.reset (new SSU2PrivateKeys ());
|
||||
s2k.read ((char *)m_SSU2Keys.get (), sizeof (SSU2PrivateKeys));
|
||||
}
|
||||
s2k.close ();
|
||||
}
|
||||
if (!m_SSU2Keys) NewSSU2Keys ();
|
||||
UpdateSSU2Address (true); // enable SSU2
|
||||
NewSSU2Keys ();
|
||||
UpdateSSU2Keys ();
|
||||
updated = true;
|
||||
}
|
||||
else
|
||||
UpdateSSU2Address (false); // disable SSU2
|
||||
if (updated)
|
||||
UpdateRouterInfo ();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1062,6 +1111,13 @@ namespace i2p
|
||||
return i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||
}
|
||||
|
||||
bool RouterContext::IsHighCongestion () const
|
||||
{
|
||||
return i2p::tunnel::tunnels.IsTooManyTransitTunnels () ||
|
||||
i2p::transport::transports.IsBandwidthExceeded () ||
|
||||
i2p::transport::transports.IsTransitBandwidthExceeded ();
|
||||
}
|
||||
|
||||
void RouterContext::HandleI2NPMessage (const uint8_t * buf, size_t len)
|
||||
{
|
||||
i2p::HandleI2NPMessage (CreateI2NPMessage (buf, GetI2NPMessageLength (buf, len)));
|
||||
@@ -1075,10 +1131,16 @@ namespace i2p
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void RouterContext::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_GarlicMutex);
|
||||
if (m_Service)
|
||||
m_Service->GetService ().post (std::bind (&RouterContext::PostGarlicMessage, this, msg));
|
||||
else
|
||||
LogPrint (eLogError, "Router: service is NULL");
|
||||
}
|
||||
|
||||
void RouterContext::PostGarlicMessage (std::shared_ptr<I2NPMessage> msg)
|
||||
{
|
||||
uint8_t * buf = msg->GetPayload ();
|
||||
uint32_t len = bufbe32toh (buf);
|
||||
if (len > msg->GetLength ())
|
||||
@@ -1095,23 +1157,38 @@ namespace i2p
|
||||
else
|
||||
LogPrint (eLogError, "Router: Session is not set for ECIES router");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RouterContext::ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg)
|
||||
{
|
||||
if (i2p::data::netdb.GetPublishReplyToken () == bufbe32toh (msg->GetPayload () + DELIVERY_STATUS_MSGID_OFFSET))
|
||||
i2p::data::netdb.PostI2NPMsg (msg);
|
||||
if (m_Service)
|
||||
m_Service->GetService ().post (std::bind (&RouterContext::PostDeliveryStatusMessage, this, msg));
|
||||
else
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_GarlicMutex);
|
||||
i2p::garlic::GarlicDestination::ProcessDeliveryStatusMessage (msg);
|
||||
}
|
||||
LogPrint (eLogError, "Router: service is NULL");
|
||||
}
|
||||
|
||||
void RouterContext::PostDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg)
|
||||
{
|
||||
if (m_PublishReplyToken == bufbe32toh (msg->GetPayload () + DELIVERY_STATUS_MSGID_OFFSET))
|
||||
{
|
||||
LogPrint (eLogInfo, "Router: Publishing confirmed. reply token=", m_PublishReplyToken);
|
||||
m_PublishExcluded.clear ();
|
||||
m_PublishReplyToken = 0;
|
||||
SchedulePublish ();
|
||||
}
|
||||
else
|
||||
i2p::garlic::GarlicDestination::ProcessDeliveryStatusMessage (msg);
|
||||
}
|
||||
|
||||
void RouterContext::CleanupDestination ()
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_GarlicMutex);
|
||||
i2p::garlic::GarlicDestination::CleanupExpiredTags ();
|
||||
if (m_Service)
|
||||
m_Service->GetService ().post ([this]()
|
||||
{
|
||||
this->i2p::garlic::GarlicDestination::CleanupExpiredTags ();
|
||||
});
|
||||
else
|
||||
LogPrint (eLogError, "Router: service is NULL");
|
||||
}
|
||||
|
||||
uint32_t RouterContext::GetUptime () const
|
||||
@@ -1186,4 +1263,143 @@ namespace i2p
|
||||
}
|
||||
return *m_SSU2StaticKeys;
|
||||
}
|
||||
|
||||
void RouterContext::ScheduleInitialPublish ()
|
||||
{
|
||||
if (m_PublishTimer)
|
||||
{
|
||||
m_PublishTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_INITIAL_PUBLISH_INTERVAL));
|
||||
m_PublishTimer->async_wait (std::bind (&RouterContext::HandleInitialPublishTimer,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Router: Publish timer is NULL");
|
||||
}
|
||||
|
||||
void RouterContext::HandleInitialPublishTimer (const boost::system::error_code& ecode)
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
{
|
||||
if (m_RouterInfo.IsReachableBy (i2p::data::RouterInfo::eAllTransports))
|
||||
HandlePublishTimer (ecode);
|
||||
else
|
||||
ScheduleInitialPublish ();
|
||||
}
|
||||
}
|
||||
|
||||
void RouterContext::SchedulePublish ()
|
||||
{
|
||||
if (m_PublishTimer)
|
||||
{
|
||||
m_PublishTimer->cancel ();
|
||||
m_PublishTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_PUBLISH_INTERVAL +
|
||||
rand () % ROUTER_INFO_PUBLISH_INTERVAL_VARIANCE));
|
||||
m_PublishTimer->async_wait (std::bind (&RouterContext::HandlePublishTimer,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Router: Publish timer is NULL");
|
||||
}
|
||||
|
||||
void RouterContext::HandlePublishTimer (const boost::system::error_code& ecode)
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
{
|
||||
m_PublishExcluded.clear ();
|
||||
m_PublishReplyToken = 0;
|
||||
if (IsFloodfill ())
|
||||
{
|
||||
UpdateStats (); // for floodfill
|
||||
m_PublishExcluded.insert (i2p::context.GetIdentHash ()); // don't publish to ourselves
|
||||
}
|
||||
UpdateTimestamp (i2p::util::GetSecondsSinceEpoch ());
|
||||
Publish ();
|
||||
SchedulePublishResend ();
|
||||
}
|
||||
}
|
||||
|
||||
void RouterContext::Publish ()
|
||||
{
|
||||
if (!i2p::transport::transports.IsOnline ()) return;
|
||||
if (m_PublishExcluded.size () > ROUTER_INFO_MAX_PUBLISH_EXCLUDED_FLOODFILLS)
|
||||
{
|
||||
LogPrint (eLogError, "Router: Couldn't publish our RouterInfo to ", ROUTER_INFO_MAX_PUBLISH_EXCLUDED_FLOODFILLS, " closest routers. Try again");
|
||||
m_PublishExcluded.clear ();
|
||||
UpdateTimestamp (i2p::util::GetSecondsSinceEpoch ());
|
||||
}
|
||||
|
||||
auto floodfill = i2p::data::netdb.GetClosestFloodfill (i2p::context.GetIdentHash (), m_PublishExcluded);
|
||||
if (floodfill)
|
||||
{
|
||||
uint32_t replyToken;
|
||||
RAND_bytes ((uint8_t *)&replyToken, 4);
|
||||
LogPrint (eLogInfo, "Router: Publishing our RouterInfo to ", i2p::data::GetIdentHashAbbreviation(floodfill->GetIdentHash ()), ". reply token=", replyToken);
|
||||
if (floodfill->IsReachableFrom (i2p::context.GetRouterInfo ()) || // are we able to connect?
|
||||
i2p::transport::transports.IsConnected (floodfill->GetIdentHash ())) // already connected ?
|
||||
// send directly
|
||||
i2p::transport::transports.SendMessage (floodfill->GetIdentHash (), CreateDatabaseStoreMsg (i2p::context.GetSharedRouterInfo (), replyToken));
|
||||
else
|
||||
{
|
||||
// otherwise through exploratory
|
||||
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false)) : nullptr;
|
||||
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel (nullptr, floodfill->GetCompatibleTransports (true)) : nullptr;
|
||||
if (inbound && outbound)
|
||||
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0,
|
||||
CreateDatabaseStoreMsg (i2p::context.GetSharedRouterInfo (), replyToken, inbound));
|
||||
else
|
||||
LogPrint (eLogInfo, "Router: Can't publish our RouterInfo. No tunnles. Try again in ", ROUTER_INFO_CONFIRMATION_TIMEOUT, " seconds");
|
||||
}
|
||||
m_PublishExcluded.insert (floodfill->GetIdentHash ());
|
||||
m_PublishReplyToken = replyToken;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogInfo, "Router: Can't find floodfill to publish our RouterInfo");
|
||||
}
|
||||
|
||||
void RouterContext::SchedulePublishResend ()
|
||||
{
|
||||
if (m_PublishTimer)
|
||||
{
|
||||
m_PublishTimer->cancel ();
|
||||
m_PublishTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_CONFIRMATION_TIMEOUT));
|
||||
m_PublishTimer->async_wait (std::bind (&RouterContext::HandlePublishResendTimer,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Router: Publish timer is NULL");
|
||||
}
|
||||
|
||||
void RouterContext::HandlePublishResendTimer (const boost::system::error_code& ecode)
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
{
|
||||
i2p::context.UpdateTimestamp (i2p::util::GetSecondsSinceEpoch ());
|
||||
Publish ();
|
||||
SchedulePublishResend ();
|
||||
}
|
||||
}
|
||||
|
||||
void RouterContext::ScheduleCongestionUpdate ()
|
||||
{
|
||||
if (m_CongestionUpdateTimer)
|
||||
{
|
||||
m_CongestionUpdateTimer->cancel ();
|
||||
m_CongestionUpdateTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_CONGESTION_UPDATE_INTERVAL));
|
||||
m_CongestionUpdateTimer->async_wait (std::bind (&RouterContext::HandleCongestionUpdateTimer,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Router: Congestion update timer is NULL");
|
||||
}
|
||||
|
||||
void RouterContext::HandleCongestionUpdateTimer (const boost::system::error_code& ecode)
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
{
|
||||
if (m_RouterInfo.SetHighCongestion (IsHighCongestion ()))
|
||||
UpdateRouterInfo ();
|
||||
ScheduleCongestionUpdate ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -12,12 +12,13 @@
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <set>
|
||||
#include <boost/asio.hpp>
|
||||
#include "Identity.h"
|
||||
#include "RouterInfo.h"
|
||||
#include "Garlic.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
@@ -30,7 +31,13 @@ namespace garlic
|
||||
const char ROUTER_KEYS[] = "router.keys";
|
||||
const char NTCP2_KEYS[] = "ntcp2.keys";
|
||||
const char SSU2_KEYS[] = "ssu2.keys";
|
||||
const int ROUTER_INFO_UPDATE_INTERVAL = 1800; // 30 minutes
|
||||
const int ROUTER_INFO_UPDATE_INTERVAL = 30*60; // 30 minutes
|
||||
const int ROUTER_INFO_PUBLISH_INTERVAL = 39*60; // in seconds
|
||||
const int ROUTER_INFO_INITIAL_PUBLISH_INTERVAL = 10; // in seconds
|
||||
const int ROUTER_INFO_PUBLISH_INTERVAL_VARIANCE = 105;// in seconds
|
||||
const int ROUTER_INFO_CONFIRMATION_TIMEOUT = 5; // in seconds
|
||||
const int ROUTER_INFO_MAX_PUBLISH_EXCLUDED_FLOODFILLS = 15;
|
||||
const int ROUTER_INFO_CONGESTION_UPDATE_INTERVAL = 12*60; // in seconds
|
||||
|
||||
enum RouterStatus
|
||||
{
|
||||
@@ -70,11 +77,23 @@ namespace garlic
|
||||
uint8_t intro[32];
|
||||
};
|
||||
|
||||
class RouterService: public i2p::util::RunnableServiceWithWork
|
||||
{
|
||||
public:
|
||||
|
||||
RouterService (): RunnableServiceWithWork ("Router") {};
|
||||
boost::asio::io_service& GetService () { return GetIOService (); };
|
||||
void Start () { StartIOService (); };
|
||||
void Stop () { StopIOService (); };
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
RouterContext ();
|
||||
void Init ();
|
||||
|
||||
void Start ();
|
||||
void Stop ();
|
||||
|
||||
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
|
||||
i2p::data::LocalRouterInfo& GetRouterInfo () { return m_RouterInfo; };
|
||||
std::shared_ptr<i2p::data::RouterInfo> GetSharedRouterInfo ()
|
||||
@@ -116,11 +135,9 @@ namespace garlic
|
||||
bool DecryptTunnelShortRequestRecord (const uint8_t * encrypted, uint8_t * data);
|
||||
|
||||
void UpdatePort (int port); // called from Daemon
|
||||
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
|
||||
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU2 or Daemon
|
||||
void PublishNTCP2Address (int port, bool publish, bool v4, bool v6, bool ygg);
|
||||
void UpdateNTCP2Address (bool enable);
|
||||
void PublishSSU2Address (int port, bool publish, bool v4, bool v6);
|
||||
void UpdateSSU2Address (bool enable);
|
||||
bool AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4);
|
||||
void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4);
|
||||
void ClearSSU2Introducers (bool v4);
|
||||
@@ -136,6 +153,7 @@ namespace garlic
|
||||
void SetShareRatio (int percents); // 0 - 100
|
||||
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
|
||||
void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; };
|
||||
bool IsHighCongestion () const;
|
||||
bool SupportsV6 () const { return m_RouterInfo.IsV6 (); };
|
||||
bool SupportsV4 () const { return m_RouterInfo.IsV4 (); };
|
||||
bool SupportsMesh () const { return m_RouterInfo.IsMesh (); };
|
||||
@@ -143,6 +161,8 @@ namespace garlic
|
||||
void SetSupportsV4 (bool supportsV4);
|
||||
void SetSupportsMesh (bool supportsmesh, const boost::asio::ip::address_v6& host);
|
||||
void SetMTU (int mtu, bool v4);
|
||||
void SetHidden(bool hide) { m_IsHiddenMode = hide; };
|
||||
bool IsHidden() const { return m_IsHiddenMode; };
|
||||
i2p::crypto::NoiseSymmetricState& GetCurrentNoiseState () { return m_CurrentNoiseState; };
|
||||
|
||||
void UpdateNTCP2V6Address (const boost::asio::ip::address& host); // called from Daemon. TODO: remove
|
||||
@@ -177,13 +197,27 @@ namespace garlic
|
||||
void UpdateRouterInfo ();
|
||||
void NewNTCP2Keys ();
|
||||
void NewSSU2Keys ();
|
||||
bool IsSSU2Only () const; // SSU2 and no SSU
|
||||
void UpdateNTCP2Keys ();
|
||||
void UpdateSSU2Keys ();
|
||||
bool Load ();
|
||||
void SaveKeys ();
|
||||
uint16_t SelectRandomPort () const;
|
||||
void PublishNTCP2Address (std::shared_ptr<i2p::data::RouterInfo::Address> address, int port, bool publish) const;
|
||||
|
||||
bool DecryptECIESTunnelBuildRecord (const uint8_t * encrypted, uint8_t * data, size_t clearTextSize);
|
||||
void PostGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
||||
void PostDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
|
||||
|
||||
void ScheduleInitialPublish ();
|
||||
void HandleInitialPublishTimer (const boost::system::error_code& ecode);
|
||||
void SchedulePublish ();
|
||||
void HandlePublishTimer (const boost::system::error_code& ecode);
|
||||
void Publish ();
|
||||
void SchedulePublishResend ();
|
||||
void HandlePublishResendTimer (const boost::system::error_code& ecode);
|
||||
void ScheduleCongestionUpdate ();
|
||||
void HandleCongestionUpdateTimer (const boost::system::error_code& ecode);
|
||||
|
||||
private:
|
||||
|
||||
i2p::data::LocalRouterInfo m_RouterInfo;
|
||||
@@ -198,12 +232,17 @@ namespace garlic
|
||||
RouterStatus m_Status, m_StatusV6;
|
||||
RouterError m_Error, m_ErrorV6;
|
||||
int m_NetID;
|
||||
std::mutex m_GarlicMutex;
|
||||
std::unique_ptr<NTCP2PrivateKeys> m_NTCP2Keys;
|
||||
std::unique_ptr<SSU2PrivateKeys> m_SSU2Keys;
|
||||
std::unique_ptr<i2p::crypto::X25519Keys> m_NTCP2StaticKeys, m_SSU2StaticKeys;
|
||||
// for ECIESx25519
|
||||
i2p::crypto::NoiseSymmetricState m_InitialNoiseState, m_CurrentNoiseState;
|
||||
// publish
|
||||
std::unique_ptr<RouterService> m_Service;
|
||||
std::unique_ptr<boost::asio::deadline_timer> m_PublishTimer, m_CongestionUpdateTimer;
|
||||
std::set<i2p::data::IdentHash> m_PublishExcluded;
|
||||
uint32_t m_PublishReplyToken;
|
||||
bool m_IsHiddenMode; // not publish
|
||||
};
|
||||
|
||||
extern RouterContext context;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace data
|
||||
RouterInfo::RouterInfo (const std::string& fullPath):
|
||||
m_FamilyID (0), m_IsUpdated (false), m_IsUnreachable (false),
|
||||
m_SupportedTransports (0),m_ReachableTransports (0),
|
||||
m_Caps (0), m_Version (0)
|
||||
m_Caps (0), m_Version (0), m_Congestion (eLowCongestion)
|
||||
{
|
||||
m_Addresses = boost::make_shared<Addresses>(); // create empty list
|
||||
m_Buffer = NewBuffer (); // always RouterInfo's
|
||||
@@ -53,7 +53,7 @@ namespace data
|
||||
RouterInfo::RouterInfo (std::shared_ptr<Buffer>&& buf, size_t len):
|
||||
m_FamilyID (0), m_IsUpdated (true), m_IsUnreachable (false),
|
||||
m_SupportedTransports (0), m_ReachableTransports (0),
|
||||
m_Caps (0), m_Version (0)
|
||||
m_Caps (0), m_Version (0), m_Congestion (eLowCongestion)
|
||||
{
|
||||
if (len <= MAX_RI_BUFFER_SIZE)
|
||||
{
|
||||
@@ -79,13 +79,12 @@ namespace data
|
||||
{
|
||||
}
|
||||
|
||||
void RouterInfo::Update (const uint8_t * buf, size_t len)
|
||||
bool RouterInfo::Update (const uint8_t * buf, size_t len)
|
||||
{
|
||||
if (len > MAX_RI_BUFFER_SIZE)
|
||||
{
|
||||
LogPrint (eLogError, "RouterInfo: Buffer is too long ", len);
|
||||
m_IsUnreachable = true;
|
||||
return;
|
||||
LogPrint (eLogWarning, "RouterInfo: Updated buffer is too long ", len, ". Not changed");
|
||||
return false;
|
||||
}
|
||||
// verify signature since we have identity already
|
||||
int l = len - m_RouterIdentity->GetSignatureLen ();
|
||||
@@ -99,20 +98,21 @@ namespace data
|
||||
m_Caps = 0;
|
||||
// don't clean up m_Addresses, it will be replaced in ReadFromStream
|
||||
ClearProperties ();
|
||||
// copy buffer
|
||||
UpdateBuffer (buf, len);
|
||||
// skip identity
|
||||
size_t identityLen = m_RouterIdentity->GetFullLen ();
|
||||
// read new RI
|
||||
std::stringstream str (std::string ((char *)m_Buffer->data () + identityLen, m_BufferLen - identityLen));
|
||||
std::stringstream str (std::string ((char *)buf + identityLen, len - identityLen));
|
||||
ReadFromStream (str);
|
||||
if (!m_IsUnreachable)
|
||||
UpdateBuffer (buf, len); // save buffer
|
||||
// don't delete buffer until saved to the file
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrint (eLogError, "RouterInfo: Signature verification failed");
|
||||
m_IsUnreachable = true;
|
||||
}
|
||||
{
|
||||
LogPrint (eLogWarning, "RouterInfo: Updated signature verification failed. Not changed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RouterInfo::SetRouterIdentity (std::shared_ptr<const IdentityEx> identity)
|
||||
@@ -202,7 +202,7 @@ namespace data
|
||||
void RouterInfo::ReadFromStream (std::istream& s)
|
||||
{
|
||||
if (!s) return;
|
||||
m_Caps = 0;
|
||||
m_Caps = 0; m_Congestion = eLowCongestion;
|
||||
s.read ((char *)&m_Timestamp, sizeof (m_Timestamp));
|
||||
m_Timestamp = be64toh (m_Timestamp);
|
||||
// read addresses
|
||||
@@ -252,7 +252,15 @@ namespace data
|
||||
{
|
||||
boost::system::error_code ecode;
|
||||
address->host = boost::asio::ip::address::from_string (value, ecode);
|
||||
if (!ecode && !address->host.is_unspecified ()) isHost = true;
|
||||
if (!ecode && !address->host.is_unspecified ())
|
||||
{
|
||||
if (!i2p::util::net::IsInReservedRange (address->host) ||
|
||||
i2p::util::net::IsYggdrasilAddress (address->host))
|
||||
isHost = true;
|
||||
else
|
||||
// we consider such address as invalid
|
||||
address->transportStyle = eTransportUnknown;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (key, "port"))
|
||||
{
|
||||
@@ -328,11 +336,7 @@ namespace data
|
||||
address->ssu->introducers.resize (index + 1);
|
||||
}
|
||||
Introducer& introducer = address->ssu->introducers.at (index);
|
||||
if (!strcmp (key, "ihost"))
|
||||
introducer.isH = false; // SSU1
|
||||
else if (!strcmp (key, "iport"))
|
||||
introducer.isH = false; // SSU1
|
||||
else if (!strcmp (key, "itag"))
|
||||
if (!strcmp (key, "itag"))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -344,10 +348,7 @@ namespace data
|
||||
}
|
||||
}
|
||||
else if (!strcmp (key, "ih"))
|
||||
{
|
||||
Base64ToByteStream (value, strlen (value), introducer.iH, 32);
|
||||
introducer.isH = true;
|
||||
}
|
||||
else if (!strcmp (key, "iexp"))
|
||||
{
|
||||
try
|
||||
@@ -390,7 +391,7 @@ namespace data
|
||||
{
|
||||
if (address->IsV4 ()) supportedTransports |= eSSU2V4;
|
||||
if (address->IsV6 ()) supportedTransports |= eSSU2V6;
|
||||
if (address->port)
|
||||
if (isHost && address->port)
|
||||
{
|
||||
if (address->host.is_v4 ()) m_ReachableTransports |= eSSU2V4;
|
||||
if (address->host.is_v6 ()) m_ReachableTransports |= eSSU2V6;
|
||||
@@ -403,7 +404,7 @@ namespace data
|
||||
int numValid = 0;
|
||||
for (auto& it: address->ssu->introducers)
|
||||
{
|
||||
if (it.iTag && ts < it.iExp && it.isH)
|
||||
if (it.iTag && ts < it.iExp)
|
||||
numValid++;
|
||||
else
|
||||
it.iTag = 0;
|
||||
@@ -534,6 +535,15 @@ namespace data
|
||||
case CAPS_FLAG_UNREACHABLE:
|
||||
m_Caps |= Caps::eUnreachable;
|
||||
break;
|
||||
case CAPS_FLAG_MEDIUM_CONGESTION:
|
||||
m_Congestion = eMediumCongestion;
|
||||
break;
|
||||
case CAPS_FLAG_HIGH_CONGESTION:
|
||||
m_Congestion = eHighCongestion;
|
||||
break;
|
||||
case CAPS_FLAG_REJECT_ALL_CONGESTION:
|
||||
m_Congestion = eRejectAll;
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
cap++;
|
||||
@@ -581,20 +591,24 @@ namespace data
|
||||
{
|
||||
if (LoadFile (fullPath))
|
||||
LogPrint (eLogDebug, "RouterInfo: Buffer for ", GetIdentHashAbbreviation (GetIdentHash ()), " loaded from file");
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
return m_Buffer->data ();
|
||||
}
|
||||
|
||||
bool RouterInfo::SaveToFile (const std::string& fullPath)
|
||||
{
|
||||
if (m_IsUnreachable) return false; // don't save bad router
|
||||
if (!m_Buffer)
|
||||
{
|
||||
LogPrint (eLogError, "RouterInfo: Can't save, m_Buffer == NULL");
|
||||
LogPrint (eLogWarning, "RouterInfo: Can't save, m_Buffer == NULL");
|
||||
return false;
|
||||
}
|
||||
std::ofstream f (fullPath, std::ofstream::binary | std::ofstream::out);
|
||||
if (!f.is_open ()) {
|
||||
LogPrint(eLogError, "RouterInfo: Can't save to ", fullPath);
|
||||
if (!f.is_open ())
|
||||
{
|
||||
LogPrint (eLogError, "RouterInfo: Can't save to ", fullPath);
|
||||
return false;
|
||||
}
|
||||
f.write ((char *)m_Buffer->data (), m_BufferLen);
|
||||
@@ -620,22 +634,49 @@ namespace data
|
||||
return l+1;
|
||||
}
|
||||
|
||||
void RouterInfo::AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,
|
||||
const boost::asio::ip::address& host, int port, uint8_t caps)
|
||||
void RouterInfo::AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,int port, uint8_t caps)
|
||||
{
|
||||
auto addr = std::make_shared<Address>();
|
||||
addr->host = host;
|
||||
addr->port = port;
|
||||
addr->transportStyle = eTransportNTCP2;
|
||||
addr->caps = caps;
|
||||
addr->date = 0;
|
||||
if (port) addr->published = true;
|
||||
addr->published = false;
|
||||
memcpy (addr->s, staticKey, 32);
|
||||
memcpy (addr->i, iv, 16);
|
||||
if (addr->IsV4 ())
|
||||
{
|
||||
m_SupportedTransports |= eNTCP2V4;
|
||||
if (addr->published) m_ReachableTransports |= eNTCP2V4;
|
||||
(*m_Addresses)[eNTCP2V4Idx] = addr;
|
||||
}
|
||||
if (addr->IsV6 ())
|
||||
{
|
||||
m_SupportedTransports |= eNTCP2V6;
|
||||
(*m_Addresses)[eNTCP2V6Idx] = addr;
|
||||
}
|
||||
}
|
||||
|
||||
void RouterInfo::AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,
|
||||
const boost::asio::ip::address& host, int port)
|
||||
{
|
||||
auto addr = std::make_shared<Address>();
|
||||
addr->host = host;
|
||||
addr->port = port;
|
||||
addr->transportStyle = eTransportNTCP2;
|
||||
addr->date = 0;
|
||||
addr->published = true;
|
||||
memcpy (addr->s, staticKey, 32);
|
||||
memcpy (addr->i, iv, 16);
|
||||
addr->caps = 0;
|
||||
if (host.is_unspecified ())
|
||||
{
|
||||
if (host.is_v4 ()) addr->caps |= eV4;
|
||||
if (host.is_v6 ()) addr->caps |= eV6;
|
||||
}
|
||||
if (addr->IsV4 ())
|
||||
{
|
||||
m_SupportedTransports |= eNTCP2V4;
|
||||
m_ReachableTransports |= eNTCP2V4;
|
||||
(*m_Addresses)[eNTCP2V4Idx] = addr;
|
||||
}
|
||||
if (addr->IsV6 ())
|
||||
@@ -649,17 +690,34 @@ namespace data
|
||||
else
|
||||
{
|
||||
m_SupportedTransports |= eNTCP2V6;
|
||||
if (addr->published) m_ReachableTransports |= eNTCP2V6;
|
||||
m_ReachableTransports |= eNTCP2V6;
|
||||
(*m_Addresses)[eNTCP2V6Idx] = addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RouterInfo::AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, uint8_t caps)
|
||||
void RouterInfo::RemoveNTCP2Address (bool v4)
|
||||
{
|
||||
if (v4)
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V6Idx])
|
||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eNTCP2V4Idx].reset ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V4Idx])
|
||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eNTCP2V6Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
}
|
||||
|
||||
void RouterInfo::AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, int port, uint8_t caps)
|
||||
{
|
||||
auto addr = std::make_shared<Address>();
|
||||
addr->transportStyle = eTransportSSU2;
|
||||
addr->port = 0;
|
||||
addr->port = port;
|
||||
addr->caps = caps;
|
||||
addr->date = 0;
|
||||
addr->ssu.reset (new SSUExt ());
|
||||
@@ -686,12 +744,19 @@ namespace data
|
||||
addr->host = host;
|
||||
addr->port = port;
|
||||
addr->published = true;
|
||||
addr->caps = i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer; // BC;
|
||||
addr->date = 0;
|
||||
addr->ssu.reset (new SSUExt ());
|
||||
addr->ssu->mtu = 0;
|
||||
memcpy (addr->s, staticKey, 32);
|
||||
memcpy (addr->i, introKey, 32);
|
||||
if (!host.is_unspecified ())
|
||||
addr->caps = i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer; // BC;
|
||||
else
|
||||
{
|
||||
addr->caps = 0;
|
||||
if (host.is_v4 ()) addr->caps |= eV4;
|
||||
if (host.is_v6 ()) addr->caps |= eV6;
|
||||
}
|
||||
if (addr->IsV4 ())
|
||||
{
|
||||
m_SupportedTransports |= eSSU2V4;
|
||||
@@ -706,6 +771,23 @@ namespace data
|
||||
}
|
||||
}
|
||||
|
||||
void RouterInfo::RemoveSSU2Address (bool v4)
|
||||
{
|
||||
if (v4)
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V6Idx])
|
||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eSSU2V4Idx].reset ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V4Idx])
|
||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eSSU2V6Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
}
|
||||
|
||||
bool RouterInfo::IsNTCP2 (bool v4only) const
|
||||
{
|
||||
if (v4only)
|
||||
@@ -744,14 +826,14 @@ namespace data
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V6Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V6Idx]->IsV4 ())
|
||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV6;
|
||||
if ((*m_Addresses)[eNTCP2V6Idx]->IsV4 () && (*m_Addresses)[eNTCP2V4Idx])
|
||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eNTCP2V6Idx].reset ();
|
||||
}
|
||||
if ((*m_Addresses)[eSSU2V6Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V6Idx]->IsV4 ())
|
||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV6;
|
||||
if ((*m_Addresses)[eSSU2V6Idx]->IsV4 () && (*m_Addresses)[eSSU2V4Idx])
|
||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eSSU2V6Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
@@ -764,14 +846,14 @@ namespace data
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V4Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V4Idx]->IsV6 ())
|
||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV4;
|
||||
if ((*m_Addresses)[eNTCP2V4Idx]->IsV6 () && (*m_Addresses)[eNTCP2V6Idx])
|
||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eNTCP2V4Idx].reset ();
|
||||
}
|
||||
if ((*m_Addresses)[eSSU2V4Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V4Idx]->IsV6 ())
|
||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV4;
|
||||
if ((*m_Addresses)[eSSU2V4Idx]->IsV6 () && (*m_Addresses)[eSSU2V6Idx])
|
||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eSSU2V4Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
@@ -846,23 +928,14 @@ namespace data
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetNTCP2AddressWithStaticKey (const uint8_t * key) const
|
||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetNTCP2V4Address () const
|
||||
{
|
||||
if (!key) return nullptr;
|
||||
return GetAddress (
|
||||
[key](std::shared_ptr<const RouterInfo::Address> address)->bool
|
||||
{
|
||||
return address->IsNTCP2 () && !memcmp (address->s, key, 32);
|
||||
});
|
||||
return (*GetAddresses ())[eNTCP2V4Idx];
|
||||
}
|
||||
|
||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSU2AddressWithStaticKey (const uint8_t * key, bool isV6) const
|
||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetNTCP2V6Address () const
|
||||
{
|
||||
if (!key) return nullptr;
|
||||
auto addr = (*GetAddresses ())[isV6 ? eSSU2V6Idx : eSSU2V4Idx];
|
||||
if (addr && !memcmp (addr->s, key, 32))
|
||||
return addr;
|
||||
return nullptr;
|
||||
return (*GetAddresses ())[eNTCP2V6Idx];
|
||||
}
|
||||
|
||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetPublishedNTCP2V4Address () const
|
||||
@@ -886,9 +959,13 @@ namespace data
|
||||
|
||||
std::shared_ptr<RouterProfile> RouterInfo::GetProfile () const
|
||||
{
|
||||
if (!m_Profile)
|
||||
m_Profile = GetRouterProfile (GetIdentHash ());
|
||||
return m_Profile;
|
||||
auto profile = m_Profile;
|
||||
if (!profile)
|
||||
{
|
||||
profile = GetRouterProfile (GetIdentHash ());
|
||||
m_Profile = profile;
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
void RouterInfo::Encrypt (const uint8_t * data, uint8_t * encrypted) const
|
||||
@@ -977,18 +1054,33 @@ namespace data
|
||||
std::shared_ptr<RouterInfo::Address> RouterInfo::NewAddress () const
|
||||
{
|
||||
return netdb.NewRouterInfoAddress ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boost::shared_ptr<RouterInfo::Addresses> RouterInfo::NewAddresses () const
|
||||
{
|
||||
return netdb.NewRouterInfoAddresses ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RouterInfo::RefreshTimestamp ()
|
||||
{
|
||||
m_Timestamp = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
}
|
||||
|
||||
bool RouterInfo::IsHighCongestion () const
|
||||
{
|
||||
if (m_Congestion == eLowCongestion || m_Congestion == eMediumCongestion) return false;
|
||||
if (m_Congestion == eRejectAll) return true;
|
||||
if (m_Congestion == eHighCongestion)
|
||||
return (i2p::util::GetMillisecondsSinceEpoch () < m_Timestamp + HIGH_CONGESTION_INTERVAL*1000LL) ? true : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
LocalRouterInfo::LocalRouterInfo (const std::string& fullPath):
|
||||
RouterInfo (fullPath)
|
||||
{
|
||||
SetHighCongestion (false); // drop congestion
|
||||
}
|
||||
|
||||
void LocalRouterInfo::CreateBuffer (const PrivateKeys& privateKeys)
|
||||
{
|
||||
RefreshTimestamp ();
|
||||
@@ -1040,9 +1132,35 @@ namespace data
|
||||
if (c & eReachable) caps += CAPS_FLAG_REACHABLE; // reachable
|
||||
if (c & eUnreachable) caps += CAPS_FLAG_UNREACHABLE; // unreachable
|
||||
|
||||
switch (GetCongestion ())
|
||||
{
|
||||
case eMediumCongestion:
|
||||
caps += CAPS_FLAG_MEDIUM_CONGESTION;
|
||||
break;
|
||||
case eHighCongestion:
|
||||
caps += CAPS_FLAG_HIGH_CONGESTION;
|
||||
break;
|
||||
case eRejectAll:
|
||||
caps += CAPS_FLAG_REJECT_ALL_CONGESTION;
|
||||
break;
|
||||
default: ;
|
||||
};
|
||||
|
||||
SetProperty ("caps", caps);
|
||||
}
|
||||
|
||||
bool LocalRouterInfo::SetHighCongestion (bool highCongestion)
|
||||
{
|
||||
Congestion c = highCongestion ? eHighCongestion : eLowCongestion;
|
||||
if (c != GetCongestion ())
|
||||
{
|
||||
SetCongestion (c);
|
||||
UpdateCapsProperty ();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LocalRouterInfo::WriteToStream (std::ostream& s) const
|
||||
{
|
||||
auto addresses = GetAddresses ();
|
||||
@@ -1269,12 +1387,12 @@ namespace data
|
||||
{
|
||||
return std::make_shared<Address> ();
|
||||
}
|
||||
|
||||
|
||||
boost::shared_ptr<RouterInfo::Addresses> LocalRouterInfo::NewAddresses () const
|
||||
{
|
||||
return boost::make_shared<Addresses> ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool LocalRouterInfo::AddSSU2Introducer (const Introducer& introducer, bool v4)
|
||||
{
|
||||
auto addresses = GetAddresses ();
|
||||
|
||||
@@ -44,7 +44,11 @@ namespace data
|
||||
const char CAPS_FLAG_HIGH_BANDWIDTH3 = 'O'; /* 128-256 KBps */
|
||||
const char CAPS_FLAG_EXTRA_BANDWIDTH1 = 'P'; /* 256-2000 KBps */
|
||||
const char CAPS_FLAG_EXTRA_BANDWIDTH2 = 'X'; /* > 2000 KBps */
|
||||
|
||||
// congesion flags
|
||||
const char CAPS_FLAG_MEDIUM_CONGESTION = 'D';
|
||||
const char CAPS_FLAG_HIGH_CONGESTION = 'E';
|
||||
const char CAPS_FLAG_REJECT_ALL_CONGESTION = 'G';
|
||||
|
||||
const char CAPS_FLAG_V4 = '4';
|
||||
const char CAPS_FLAG_V6 = '6';
|
||||
const char CAPS_FLAG_SSU2_TESTING = 'B';
|
||||
@@ -56,6 +60,8 @@ namespace data
|
||||
const uint8_t COST_SSU2_NON_PUBLISHED = 15;
|
||||
|
||||
const size_t MAX_RI_BUFFER_SIZE = 3072; // if RouterInfo exceeds 3K we consider it as malformed, might extend later
|
||||
const int HIGH_CONGESTION_INTERVAL = 15*60; // in seconds, 15 minutes
|
||||
|
||||
class RouterInfo: public RoutingDestination
|
||||
{
|
||||
public:
|
||||
@@ -93,6 +99,14 @@ namespace data
|
||||
eUnreachable = 0x20
|
||||
};
|
||||
|
||||
enum Congestion
|
||||
{
|
||||
eLowCongestion = 0,
|
||||
eMediumCongestion,
|
||||
eHighCongestion,
|
||||
eRejectAll
|
||||
};
|
||||
|
||||
enum AddressCaps
|
||||
{
|
||||
eV4 = 0x01,
|
||||
@@ -110,11 +124,10 @@ namespace data
|
||||
|
||||
struct Introducer
|
||||
{
|
||||
Introducer (): iTag (0), iExp (0), isH (false) {};
|
||||
Introducer (): iTag (0), iExp (0) {};
|
||||
IdentHash iH;
|
||||
uint32_t iTag;
|
||||
uint32_t iExp;
|
||||
bool isH; // TODO: remove later
|
||||
};
|
||||
|
||||
struct SSUExt
|
||||
@@ -189,8 +202,8 @@ namespace data
|
||||
virtual void SetProperty (const std::string& key, const std::string& value) {};
|
||||
virtual void ClearProperties () {};
|
||||
boost::shared_ptr<Addresses> GetAddresses () const; // should be called for local RI only, otherwise must return shared_ptr
|
||||
std::shared_ptr<const Address> GetNTCP2AddressWithStaticKey (const uint8_t * key) const;
|
||||
std::shared_ptr<const Address> GetSSU2AddressWithStaticKey (const uint8_t * key, bool isV6) const;
|
||||
std::shared_ptr<const Address> GetNTCP2V4Address () const;
|
||||
std::shared_ptr<const Address> GetNTCP2V6Address () const;
|
||||
std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const;
|
||||
std::shared_ptr<const Address> GetPublishedNTCP2V6Address () const;
|
||||
std::shared_ptr<const Address> GetYggdrasilAddress () const;
|
||||
@@ -198,11 +211,14 @@ namespace data
|
||||
std::shared_ptr<const Address> GetSSU2V6Address () const;
|
||||
std::shared_ptr<const Address> GetSSU2Address (bool v4) const;
|
||||
|
||||
void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,int port, uint8_t caps); // non published
|
||||
void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,
|
||||
const boost::asio::ip::address& host = boost::asio::ip::address(), int port = 0, uint8_t caps = 0);
|
||||
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, uint8_t caps = 0); // non published
|
||||
const boost::asio::ip::address& host, int port); // published
|
||||
void RemoveNTCP2Address (bool v4);
|
||||
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, int port, uint8_t caps); // non published
|
||||
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey,
|
||||
const boost::asio::ip::address& host, int port); // published
|
||||
void RemoveSSU2Address (bool v4);
|
||||
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
|
||||
void UpdateSupportedTransports ();
|
||||
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
||||
@@ -232,14 +248,17 @@ namespace data
|
||||
bool IsEligibleFloodfill () const;
|
||||
bool IsSSU2PeerTesting (bool v4) const;
|
||||
bool IsSSU2Introducer (bool v4) const;
|
||||
bool IsHighCongestion () const;
|
||||
|
||||
uint8_t GetCaps () const { return m_Caps; };
|
||||
void SetCaps (uint8_t caps) { m_Caps = caps; };
|
||||
|
||||
Congestion GetCongestion () const { return m_Congestion; };
|
||||
|
||||
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
||||
bool IsUnreachable () const { return m_IsUnreachable; };
|
||||
|
||||
const uint8_t * GetBuffer () const { return m_Buffer->data (); };
|
||||
const uint8_t * GetBuffer () const { return m_Buffer ? m_Buffer->data () : nullptr; };
|
||||
const uint8_t * LoadBuffer (const std::string& fullPath); // load if necessary
|
||||
size_t GetBufferLen () const { return m_BufferLen; };
|
||||
|
||||
@@ -248,9 +267,9 @@ namespace data
|
||||
bool SaveToFile (const std::string& fullPath);
|
||||
|
||||
std::shared_ptr<RouterProfile> GetProfile () const;
|
||||
void SaveProfile () { if (m_Profile) m_Profile->Save (GetIdentHash ()); };
|
||||
void DropProfile () { m_Profile = nullptr; };
|
||||
|
||||
void Update (const uint8_t * buf, size_t len);
|
||||
bool Update (const uint8_t * buf, size_t len);
|
||||
void DeleteBuffer () { m_Buffer = nullptr; };
|
||||
bool IsNewer (const uint8_t * buf, size_t len) const;
|
||||
|
||||
@@ -272,7 +291,8 @@ namespace data
|
||||
void RefreshTimestamp ();
|
||||
CompatibleTransports GetReachableTransports () const { return m_ReachableTransports; };
|
||||
void SetReachableTransports (CompatibleTransports transports) { m_ReachableTransports = transports; };
|
||||
|
||||
void SetCongestion (Congestion c) { m_Congestion = c; };
|
||||
|
||||
private:
|
||||
|
||||
bool LoadFile (const std::string& fullPath);
|
||||
@@ -300,6 +320,7 @@ namespace data
|
||||
CompatibleTransports m_SupportedTransports, m_ReachableTransports;
|
||||
uint8_t m_Caps;
|
||||
int m_Version;
|
||||
Congestion m_Congestion;
|
||||
mutable std::shared_ptr<RouterProfile> m_Profile;
|
||||
};
|
||||
|
||||
@@ -308,9 +329,10 @@ namespace data
|
||||
public:
|
||||
|
||||
LocalRouterInfo () = default;
|
||||
LocalRouterInfo (const std::string& fullPath): RouterInfo (fullPath) {};
|
||||
LocalRouterInfo (const std::string& fullPath);
|
||||
void CreateBuffer (const PrivateKeys& privateKeys);
|
||||
void UpdateCaps (uint8_t caps);
|
||||
bool SetHighCongestion (bool highCongestion); // returns true if updated
|
||||
|
||||
void SetProperty (const std::string& key, const std::string& value) override;
|
||||
void DeleteProperty (const std::string& key);
|
||||
|
||||
@@ -212,6 +212,8 @@ namespace transport
|
||||
boost::asio::ip::udp::socket& socket = localEndpoint.address ().is_v6 () ? m_SocketV6 : m_SocketV4;
|
||||
try
|
||||
{
|
||||
if (socket.is_open ())
|
||||
socket.close ();
|
||||
socket.open (localEndpoint.protocol ());
|
||||
if (localEndpoint.address ().is_v6 ())
|
||||
socket.set_option (boost::asio::ip::v6_only (true));
|
||||
@@ -819,7 +821,7 @@ namespace transport
|
||||
m_CleanupTimer.async_wait (std::bind (&SSU2Server::HandleCleanupTimer,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
|
||||
void SSU2Server::HandleCleanupTimer (const boost::system::error_code& ecode)
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
@@ -848,15 +850,15 @@ namespace transport
|
||||
else
|
||||
it++;
|
||||
}
|
||||
|
||||
|
||||
m_PacketsPool.CleanUpMt ();
|
||||
m_SentPacketsPool.CleanUp ();
|
||||
m_IncompleteMessagesPool.CleanUp ();
|
||||
m_FragmentsPool.CleanUp ();
|
||||
ScheduleCleanup ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SSU2Server::ScheduleResend (bool more)
|
||||
{
|
||||
m_ResendTimer.expires_from_now (boost::posix_time::milliseconds (more ? SSU2_RESEND_CHECK_MORE_TIMEOUT :
|
||||
@@ -916,7 +918,7 @@ namespace transport
|
||||
}
|
||||
uint64_t token;
|
||||
RAND_bytes ((uint8_t *)&token, 8);
|
||||
m_IncomingTokens.emplace (ep, std::make_pair (token, ts + SSU2_TOKEN_EXPIRATION_TIMEOUT));
|
||||
m_IncomingTokens.emplace (ep, std::make_pair (token, uint32_t(ts + SSU2_TOKEN_EXPIRATION_TIMEOUT)));
|
||||
return token;
|
||||
}
|
||||
|
||||
@@ -925,7 +927,7 @@ namespace transport
|
||||
m_IncomingTokens.erase (ep); // drop previous
|
||||
uint64_t token;
|
||||
RAND_bytes ((uint8_t *)&token, 8);
|
||||
auto ret = std::make_pair (token, i2p::util::GetSecondsSinceEpoch () + SSU2_NEXT_TOKEN_EXPIRATION_TIMEOUT);
|
||||
auto ret = std::make_pair (token, uint32_t(i2p::util::GetSecondsSinceEpoch () + SSU2_NEXT_TOKEN_EXPIRATION_TIMEOUT));
|
||||
m_IncomingTokens.emplace (ep, ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -1015,7 +1017,6 @@ namespace transport
|
||||
i2p::data::RouterInfo::Introducer introducer;
|
||||
introducer.iTag = it->GetRelayTag ();
|
||||
introducer.iH = it->GetRemoteIdentity ()->GetIdentHash ();
|
||||
introducer.isH = true;
|
||||
introducer.iExp = it->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION;
|
||||
excluded.insert (it->GetRemoteIdentity ()->GetIdentHash ());
|
||||
if (i2p::context.AddSSU2Introducer (introducer, v4))
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace transport
|
||||
i2p::util::MemoryPool<SSU2SentPacket>& GetSentPacketsPool () { return m_SentPacketsPool; };
|
||||
i2p::util::MemoryPool<SSU2IncompleteMessage>& GetIncompleteMessagesPool () { return m_IncompleteMessagesPool; };
|
||||
i2p::util::MemoryPool<SSU2IncompleteMessage::Fragment>& GetFragmentsPool () { return m_FragmentsPool; };
|
||||
|
||||
|
||||
private:
|
||||
|
||||
boost::asio::ip::udp::socket& OpenSocket (const boost::asio::ip::udp::endpoint& localEndpoint);
|
||||
@@ -116,7 +116,7 @@ namespace transport
|
||||
|
||||
void ScheduleCleanup ();
|
||||
void HandleCleanupTimer (const boost::system::error_code& ecode);
|
||||
|
||||
|
||||
void ScheduleResend (bool more);
|
||||
void HandleResendTimer (const boost::system::error_code& ecode);
|
||||
|
||||
|
||||
@@ -36,34 +36,34 @@ namespace transport
|
||||
{
|
||||
bool isLast = false;
|
||||
while (outOfSequenceFragments)
|
||||
{
|
||||
{
|
||||
if (outOfSequenceFragments->fragmentNum == nextFragmentNum)
|
||||
{
|
||||
AttachNextFragment (outOfSequenceFragments->buf, outOfSequenceFragments->len);
|
||||
isLast = outOfSequenceFragments->isLast;
|
||||
if (isLast)
|
||||
outOfSequenceFragments = nullptr;
|
||||
else
|
||||
else
|
||||
outOfSequenceFragments = outOfSequenceFragments->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isLast;
|
||||
}
|
||||
}
|
||||
|
||||
void SSU2IncompleteMessage::AddOutOfSequenceFragment (std::shared_ptr<SSU2IncompleteMessage::Fragment> fragment)
|
||||
{
|
||||
{
|
||||
if (!fragment || !fragment->fragmentNum) return; // fragment 0 not allowed
|
||||
if (fragment->fragmentNum < nextFragmentNum) return; // already processed
|
||||
if (!outOfSequenceFragments)
|
||||
if (!outOfSequenceFragments)
|
||||
outOfSequenceFragments = fragment;
|
||||
else
|
||||
{
|
||||
auto frag = outOfSequenceFragments;
|
||||
std::shared_ptr<Fragment> prev;
|
||||
do
|
||||
{
|
||||
{
|
||||
if (fragment->fragmentNum < frag->fragmentNum) break; // found
|
||||
if (fragment->fragmentNum == frag->fragmentNum) return; // duplicate
|
||||
prev = frag; frag = frag->next;
|
||||
@@ -71,21 +71,21 @@ namespace transport
|
||||
while (frag);
|
||||
fragment->next = frag;
|
||||
if (prev)
|
||||
prev->next = fragment;
|
||||
prev->next = fragment;
|
||||
else
|
||||
outOfSequenceFragments = fragment;
|
||||
}
|
||||
}
|
||||
lastFragmentInsertTime = i2p::util::GetSecondsSinceEpoch ();
|
||||
}
|
||||
|
||||
|
||||
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_LastDatetimeSentPacketNum (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
|
||||
{
|
||||
@@ -1041,10 +1041,18 @@ namespace transport
|
||||
LogPrint (eLogError, "SSU2: SessionConfirmed malformed RouterInfo block");
|
||||
return false;
|
||||
}
|
||||
m_Address = ri->GetSSU2AddressWithStaticKey (S, m_RemoteEndpoint.address ().is_v6 ());
|
||||
if (!m_Address)
|
||||
m_Address = m_RemoteEndpoint.address ().is_v6 () ? ri->GetSSU2V6Address () : ri->GetSSU2V4Address ();
|
||||
if (!m_Address || memcmp (S, m_Address->s, 32))
|
||||
{
|
||||
LogPrint (eLogError, "SSU2: No SSU2 address with static key found in SessionConfirmed from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
||||
LogPrint (eLogError, "SSU2: Wrong static key in SessionConfirmed from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
||||
return false;
|
||||
}
|
||||
if (m_Address->published && m_RemoteEndpoint.address () != m_Address->host &&
|
||||
(!m_RemoteEndpoint.address ().is_v6 () ||
|
||||
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data (), m_Address->host.to_v6 ().to_bytes ().data (), 8))) // temporary address
|
||||
{
|
||||
LogPrint (eLogError, "SSU2: Host mismatch between published address ", m_Address->host,
|
||||
" and actual endpoint ", m_RemoteEndpoint.address (), " from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
||||
return false;
|
||||
}
|
||||
// update RouterInfo in netdb
|
||||
@@ -1609,6 +1617,7 @@ namespace transport
|
||||
{
|
||||
case eSSU2SessionStateSessionRequestReceived:
|
||||
case eSSU2SessionStateTokenRequestReceived:
|
||||
case eSSU2SessionStateEstablished:
|
||||
if (std::abs (offset) > SSU2_CLOCK_SKEW)
|
||||
m_TerminationReason = eSSU2TerminationReasonClockSkew;
|
||||
break;
|
||||
@@ -1652,7 +1661,7 @@ namespace transport
|
||||
// ranges
|
||||
len -= 5;
|
||||
const uint8_t * ranges = buf + 5;
|
||||
while (len > 0 && firstPacketNum)
|
||||
while (len > 0 && firstPacketNum && ackThrough - firstPacketNum < SSU2_MAX_NUM_ACK_PACKETS)
|
||||
{
|
||||
uint32_t lastPacketNum = firstPacketNum - 1;
|
||||
if (*ranges > lastPacketNum) break;
|
||||
@@ -1795,7 +1804,7 @@ namespace transport
|
||||
{
|
||||
LogPrint (eLogWarning, "SSU2: Invalid follow-on fragment num ", fragmentNum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool isLast = buf[0] & 0x01;
|
||||
uint32_t msgID; memcpy (&msgID, buf + 1, 4);
|
||||
auto it = m_IncompleteMessages.find (msgID);
|
||||
@@ -1863,10 +1872,9 @@ namespace transport
|
||||
|
||||
// send relay intro to Charlie
|
||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ()); // Alice's RI
|
||||
if (r)
|
||||
i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
||||
else
|
||||
LogPrint (eLogWarning, "SSU2: RelayRequest Alice's router info not found");
|
||||
if (r && (r->IsUnreachable () || !i2p::data::netdb.PopulateRouterInfoBuffer (r))) r = nullptr;
|
||||
if (!r) LogPrint (eLogWarning, "SSU2: RelayRequest Alice's router info not found");
|
||||
|
||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, m_MaxPayloadSize - len - 32, r) : 0;
|
||||
if (!payloadSize && r)
|
||||
@@ -2060,7 +2068,7 @@ namespace transport
|
||||
auto packet = m_Server.GetSentPacketsPool ().AcquireShared ();
|
||||
// Alice's RouterInfo
|
||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
||||
if (r && (r->IsUnreachable () || !i2p::data::netdb.PopulateRouterInfoBuffer (r))) r = nullptr;
|
||||
packet->payloadSize = r ? CreateRouterInfoBlock (packet->payload, m_MaxPayloadSize - len - 32, r) : 0;
|
||||
if (!packet->payloadSize && r)
|
||||
session->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
||||
@@ -2164,7 +2172,7 @@ namespace transport
|
||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||
// Charlie's RouterInfo
|
||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
||||
if (r && (r->IsUnreachable () || !i2p::data::netdb.PopulateRouterInfoBuffer (r))) r = nullptr;
|
||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, m_MaxPayloadSize - len - 32, r) : 0;
|
||||
if (!payloadSize && r)
|
||||
it->second.first->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
||||
@@ -2288,9 +2296,9 @@ namespace transport
|
||||
m_Server.RemoveSession (~htobe64 (((uint64_t)nonce << 32) | nonce));
|
||||
break;
|
||||
case 7: // Alice from Charlie 2
|
||||
m_Server.RemoveSession (htobe64 (((uint64_t)nonce << 32) | nonce));
|
||||
if (m_Address->IsV6 ())
|
||||
i2p::context.SetStatusV6 (eRouterStatusOK); // set status OK for ipv6 even if from SSU2
|
||||
m_Server.RemoveSession (htobe64 (((uint64_t)nonce << 32) | nonce));
|
||||
break;
|
||||
default:
|
||||
LogPrint (eLogWarning, "SSU2: PeerTest unexpected msg num ", buf[0]);
|
||||
@@ -2298,21 +2306,21 @@ namespace transport
|
||||
}
|
||||
|
||||
void SSU2Session::HandleI2NPMsg (std::shared_ptr<I2NPMessage>&& msg)
|
||||
{
|
||||
{
|
||||
if (!msg) return;
|
||||
int32_t msgID = msg->GetMsgID ();
|
||||
uint32_t msgID = msg->GetMsgID ();
|
||||
if (!msg->IsExpired ())
|
||||
{
|
||||
// m_LastActivityTimestamp is updated in ProcessData before
|
||||
if (m_ReceivedI2NPMsgIDs.emplace (msgID, (uint32_t)m_LastActivityTimestamp).second)
|
||||
m_Handler.PutNextMessage (std::move (msg));
|
||||
m_Handler.PutNextMessage (std::move (msg));
|
||||
else
|
||||
LogPrint (eLogDebug, "SSU2: Message ", msgID, " already received");
|
||||
}
|
||||
else
|
||||
LogPrint (eLogDebug, "SSU2: Message ", msgID, " expired");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool SSU2Session::ExtractEndpoint (const uint8_t * buf, size_t size, boost::asio::ip::udp::endpoint& ep)
|
||||
{
|
||||
if (size < 2) return false;
|
||||
@@ -2455,21 +2463,24 @@ namespace transport
|
||||
if (ackThrough)
|
||||
{
|
||||
if (m_OutOfSequencePackets.empty ())
|
||||
acnt = std::min ((int)ackThrough, 255); // no gaps
|
||||
acnt = std::min ((int)ackThrough, SSU2_MAX_NUM_ACNT); // no gaps
|
||||
else
|
||||
{
|
||||
auto it = m_OutOfSequencePackets.rbegin (); it++; // prev packet num
|
||||
while (it != m_OutOfSequencePackets.rend () && *it == ackThrough - acnt - 1)
|
||||
{
|
||||
acnt++;
|
||||
it++;
|
||||
if (acnt >= SSU2_MAX_NUM_ACK_PACKETS)
|
||||
break;
|
||||
else
|
||||
it++;
|
||||
}
|
||||
// ranges
|
||||
uint32_t lastNum = ackThrough - acnt;
|
||||
if (acnt > 255)
|
||||
if (acnt > SSU2_MAX_NUM_ACNT)
|
||||
{
|
||||
auto d = std::div (acnt - 255, 255);
|
||||
acnt = 255;
|
||||
auto d = std::div (acnt - SSU2_MAX_NUM_ACNT, SSU2_MAX_NUM_ACNT);
|
||||
acnt = SSU2_MAX_NUM_ACNT;
|
||||
if (d.quot > maxNumRanges)
|
||||
{
|
||||
d.quot = maxNumRanges;
|
||||
@@ -2478,7 +2489,7 @@ namespace transport
|
||||
// Acks only ranges for acnt
|
||||
for (int i = 0; i < d.quot; i++)
|
||||
{
|
||||
buf[8 + numRanges*2] = 0; buf[8 + numRanges*2 + 1] = 255; // NACKs 0, Acks 255
|
||||
buf[8 + numRanges*2] = 0; buf[8 + numRanges*2 + 1] = SSU2_MAX_NUM_ACNT; // NACKs 0, Acks 255
|
||||
numRanges++;
|
||||
}
|
||||
if (d.rem > 0)
|
||||
@@ -2487,21 +2498,25 @@ namespace transport
|
||||
numRanges++;
|
||||
}
|
||||
}
|
||||
while (it != m_OutOfSequencePackets.rend () && numRanges < maxNumRanges)
|
||||
int numPackets = acnt + numRanges*SSU2_MAX_NUM_ACNT;
|
||||
while (it != m_OutOfSequencePackets.rend () &&
|
||||
numRanges < maxNumRanges && numPackets < SSU2_MAX_NUM_ACK_PACKETS)
|
||||
{
|
||||
if (lastNum - (*it) > 255)
|
||||
if (lastNum - (*it) > SSU2_MAX_NUM_ACNT)
|
||||
{
|
||||
// NACKs only ranges
|
||||
if (lastNum > (*it) + 255*(maxNumRanges - numRanges)) break; // too many NACKs
|
||||
while (lastNum - (*it) > 255)
|
||||
if (lastNum > (*it) + SSU2_MAX_NUM_ACNT*(maxNumRanges - numRanges)) break; // too many NACKs
|
||||
while (lastNum - (*it) > SSU2_MAX_NUM_ACNT)
|
||||
{
|
||||
buf[8 + numRanges*2] = 255; buf[8 + numRanges*2 + 1] = 0; // NACKs 255, Acks 0
|
||||
lastNum -= 255;
|
||||
buf[8 + numRanges*2] = SSU2_MAX_NUM_ACNT; buf[8 + numRanges*2 + 1] = 0; // NACKs 255, Acks 0
|
||||
lastNum -= SSU2_MAX_NUM_ACNT;
|
||||
numRanges++;
|
||||
numPackets += SSU2_MAX_NUM_ACNT;
|
||||
}
|
||||
}
|
||||
// NACKs and Acks ranges
|
||||
buf[8 + numRanges*2] = lastNum - (*it) - 1; // NACKs
|
||||
numPackets += buf[8 + numRanges*2];
|
||||
lastNum = *it; it++;
|
||||
int numAcks = 1;
|
||||
while (it != m_OutOfSequencePackets.rend () && lastNum > 0 && *it == lastNum - 1)
|
||||
@@ -2509,28 +2524,31 @@ namespace transport
|
||||
numAcks++; lastNum--;
|
||||
it++;
|
||||
}
|
||||
while (numAcks > 255)
|
||||
while (numAcks > SSU2_MAX_NUM_ACNT)
|
||||
{
|
||||
// Acks only ranges
|
||||
buf[8 + numRanges*2 + 1] = 255; // Acks 255
|
||||
numAcks -= 255;
|
||||
buf[8 + numRanges*2 + 1] = SSU2_MAX_NUM_ACNT; // Acks 255
|
||||
numAcks -= SSU2_MAX_NUM_ACNT;
|
||||
numRanges++;
|
||||
numPackets += SSU2_MAX_NUM_ACNT;
|
||||
buf[8 + numRanges*2] = 0; // NACKs 0
|
||||
if (numRanges >= maxNumRanges) break;
|
||||
if (numRanges >= maxNumRanges || numPackets >= SSU2_MAX_NUM_ACK_PACKETS) break;
|
||||
}
|
||||
if (numAcks > 255) numAcks = 255;
|
||||
if (numAcks > SSU2_MAX_NUM_ACNT) numAcks = SSU2_MAX_NUM_ACNT;
|
||||
buf[8 + numRanges*2 + 1] = (uint8_t)numAcks; // Acks
|
||||
numPackets += numAcks;
|
||||
numRanges++;
|
||||
}
|
||||
if (numRanges < maxNumRanges && it == m_OutOfSequencePackets.rend ())
|
||||
if (it == m_OutOfSequencePackets.rend () &&
|
||||
numRanges < maxNumRanges && numPackets < SSU2_MAX_NUM_ACK_PACKETS)
|
||||
{
|
||||
// add range between out-of-sequence and received
|
||||
int nacks = *m_OutOfSequencePackets.begin () - m_ReceivePacketNum - 1;
|
||||
if (nacks > 0)
|
||||
{
|
||||
if (nacks > 255) nacks = 255;
|
||||
if (nacks > SSU2_MAX_NUM_ACNT) nacks = SSU2_MAX_NUM_ACNT;
|
||||
buf[8 + numRanges*2] = nacks;
|
||||
buf[8 + numRanges*2 + 1] = std::min ((int)m_ReceivePacketNum + 1, 255);
|
||||
buf[8 + numRanges*2 + 1] = std::min ((int)m_ReceivePacketNum + 1, SSU2_MAX_NUM_ACNT);
|
||||
numRanges++;
|
||||
}
|
||||
}
|
||||
@@ -2757,15 +2775,25 @@ namespace transport
|
||||
if (packetNum <= m_ReceivePacketNum) return false; // duplicate
|
||||
if (packetNum == m_ReceivePacketNum + 1)
|
||||
{
|
||||
for (auto it = m_OutOfSequencePackets.begin (); it != m_OutOfSequencePackets.end ();)
|
||||
if (!m_OutOfSequencePackets.empty ())
|
||||
{
|
||||
auto it = m_OutOfSequencePackets.begin ();
|
||||
if (*it == packetNum + 1)
|
||||
{
|
||||
packetNum++;
|
||||
it = m_OutOfSequencePackets.erase (it);
|
||||
// first out of sequence packet is in sequence now
|
||||
packetNum++; it++;
|
||||
while (it != m_OutOfSequencePackets.end ())
|
||||
{
|
||||
if (*it == packetNum + 1)
|
||||
{
|
||||
packetNum++;
|
||||
it++;
|
||||
}
|
||||
else // next out of sequence
|
||||
break;
|
||||
}
|
||||
m_OutOfSequencePackets.erase (m_OutOfSequencePackets.begin (), it);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
m_ReceivePacketNum = packetNum;
|
||||
}
|
||||
@@ -2777,7 +2805,16 @@ namespace transport
|
||||
void SSU2Session::SendQuickAck ()
|
||||
{
|
||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||
size_t payloadSize = CreateAckBlock (payload, m_MaxPayloadSize);
|
||||
size_t payloadSize = 0;
|
||||
if (m_SendPacketNum > m_LastDatetimeSentPacketNum + SSU2_SEND_DATETIME_NUM_PACKETS)
|
||||
{
|
||||
payload[0] = eSSU2BlkDateTime;
|
||||
htobe16buf (payload + 1, 4);
|
||||
htobe32buf (payload + 3, (i2p::util::GetMillisecondsSinceEpoch () + 500)/1000);
|
||||
payloadSize += 7;
|
||||
m_LastDatetimeSentPacketNum = m_SendPacketNum;
|
||||
}
|
||||
payloadSize += CreateAckBlock (payload + payloadSize, m_MaxPayloadSize - payloadSize);
|
||||
payloadSize += CreatePaddingBlock (payload + payloadSize, m_MaxPayloadSize - payloadSize);
|
||||
SendData (payload, payloadSize);
|
||||
}
|
||||
@@ -2851,8 +2888,10 @@ namespace transport
|
||||
}
|
||||
if (!m_OutOfSequencePackets.empty ())
|
||||
{
|
||||
if (m_OutOfSequencePackets.size () > 2*SSU2_MAX_NUM_ACK_RANGES ||
|
||||
*m_OutOfSequencePackets.rbegin () > m_ReceivePacketNum + 255*8)
|
||||
int ranges = 0;
|
||||
while (ranges < 8 && !m_OutOfSequencePackets.empty () &&
|
||||
(m_OutOfSequencePackets.size () > 2*SSU2_MAX_NUM_ACK_RANGES ||
|
||||
*m_OutOfSequencePackets.rbegin () > m_ReceivePacketNum + SSU2_MAX_NUM_ACK_PACKETS))
|
||||
{
|
||||
uint32_t packet = *m_OutOfSequencePackets.begin ();
|
||||
if (packet > m_ReceivePacketNum + 1)
|
||||
@@ -2861,9 +2900,13 @@ namespace transport
|
||||
packet--;
|
||||
m_ReceivePacketNum = packet - 1;
|
||||
UpdateReceivePacketNum (packet);
|
||||
ranges++;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrint (eLogError, "SSU2: Out of sequence packet ", packet, " is less than last received ", m_ReceivePacketNum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_OutOfSequencePackets.size () > 255*4)
|
||||
{
|
||||
|
||||
@@ -48,9 +48,12 @@ namespace transport
|
||||
const size_t SSU2_MAX_RTO = 2500; // in milliseconds
|
||||
const float SSU2_kAPPA = 1.8;
|
||||
const size_t SSU2_MAX_OUTGOING_QUEUE_SIZE = 500; // in messages
|
||||
const int SSU2_MAX_NUM_ACNT = 255; // acnt, acks or nacks
|
||||
const int SSU2_MAX_NUM_ACK_PACKETS = 511; // ackthrough + acnt + 1 range
|
||||
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
|
||||
const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
|
||||
|
||||
const int SSU2_SEND_DATETIME_NUM_PACKETS = 256;
|
||||
|
||||
// flags
|
||||
const uint8_t SSU2_FLAG_IMMEDIATE_ACK_REQUESTED = 0x01;
|
||||
|
||||
@@ -315,7 +318,7 @@ namespace transport
|
||||
void HandleRelayResponse (const uint8_t * buf, size_t len);
|
||||
void HandlePeerTest (const uint8_t * buf, size_t len);
|
||||
void HandleI2NPMsg (std::shared_ptr<I2NPMessage>&& msg);
|
||||
|
||||
|
||||
size_t CreateAddressBlock (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& ep);
|
||||
size_t CreateRouterInfoBlock (uint8_t * buf, size_t len, std::shared_ptr<const i2p::data::RouterInfo> r);
|
||||
size_t CreateAckBlock (uint8_t * buf, size_t len);
|
||||
@@ -342,7 +345,7 @@ namespace transport
|
||||
uint64_t m_DestConnID, m_SourceConnID;
|
||||
SSU2SessionState m_State;
|
||||
uint8_t m_KeyDataSend[64], m_KeyDataReceive[64];
|
||||
uint32_t m_SendPacketNum, m_ReceivePacketNum;
|
||||
uint32_t m_SendPacketNum, m_ReceivePacketNum, m_LastDatetimeSentPacketNum;
|
||||
std::set<uint32_t> m_OutOfSequencePackets; // packet nums > receive packet num
|
||||
std::map<uint32_t, std::shared_ptr<SSU2SentPacket> > m_SentPackets; // packetNum -> packet
|
||||
std::unordered_map<uint32_t, std::shared_ptr<SSU2IncompleteMessage> > m_IncompleteMessages; // msgID -> I2NP
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -51,8 +51,8 @@ namespace stream
|
||||
{
|
||||
// partially
|
||||
rem = len - offset;
|
||||
memcpy (buf + offset, nextBuffer->GetRemaningBuffer (), len - offset);
|
||||
nextBuffer->offset += (len - offset);
|
||||
memcpy (buf + offset, nextBuffer->GetRemaningBuffer (), rem);
|
||||
nextBuffer->offset += rem;
|
||||
offset = len; // break
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,16 @@ namespace stream
|
||||
{
|
||||
m_NumReceivedBytes += packet->GetLength ();
|
||||
if (!m_SendStreamID)
|
||||
{
|
||||
m_SendStreamID = packet->GetReceiveStreamID ();
|
||||
if (!m_RemoteIdentity && packet->GetNACKCount () == 8 && // first incoming packet
|
||||
memcmp (packet->GetNACKs (), m_LocalDestination.GetOwner ()->GetIdentHash (), 32))
|
||||
{
|
||||
LogPrint (eLogWarning, "Streaming: Destination mismatch for ", m_LocalDestination.GetOwner ()->GetIdentHash ().ToBase32 ());
|
||||
m_LocalDestination.DeletePacket (packet);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!packet->IsNoAck ()) // ack received
|
||||
ProcessAck (packet);
|
||||
@@ -384,7 +393,7 @@ namespace stream
|
||||
memset (p.buf, 0, 22); // minimal header all zeroes
|
||||
memcpy (p.buf + 4, packet->buf, 4); // but receiveStreamID is the sendStreamID from the ping
|
||||
htobe16buf (p.buf + 18, PACKET_FLAG_ECHO); // and echo flag
|
||||
ssize_t payloadLen = packet->len - (packet->GetPayload () - packet->buf);
|
||||
auto payloadLen = int(packet->len) - (packet->GetPayload () - packet->buf);
|
||||
if (payloadLen > 0)
|
||||
memcpy (p.buf + 22, packet->GetPayload (), payloadLen);
|
||||
else
|
||||
@@ -560,8 +569,19 @@ namespace stream
|
||||
else
|
||||
htobe32buf (packet + size, m_LastReceivedSequenceNumber);
|
||||
size += 4; // ack Through
|
||||
packet[size] = 0;
|
||||
size++; // NACK count
|
||||
if (m_Status == eStreamStatusNew && !m_SendStreamID && m_RemoteIdentity)
|
||||
{
|
||||
// first SYN packet
|
||||
packet[size] = 8;
|
||||
size++; // NACK count
|
||||
memcpy (packet + size, m_RemoteIdentity->GetIdentHash (), 32);
|
||||
size += 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[size] = 0;
|
||||
size++; // NACK count
|
||||
}
|
||||
packet[size] = m_RTO/1000;
|
||||
size++; // resend delay
|
||||
if (m_Status == eStreamStatusNew)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -80,6 +80,7 @@ namespace stream
|
||||
uint32_t GetAckThrough () const { return bufbe32toh (buf + 12); };
|
||||
uint8_t GetNACKCount () const { return buf[16]; };
|
||||
uint32_t GetNACK (int i) const { return bufbe32toh (buf + 17 + 4 * i); };
|
||||
const uint8_t * GetNACKs () const { return buf + 17; };
|
||||
const uint8_t * GetOption () const { return buf + 17 + GetNACKCount ()*4 + 3; }; // 3 = resendDelay + flags
|
||||
uint16_t GetFlags () const { return bufbe16toh (GetOption () - 2); };
|
||||
uint16_t GetOptionSize () const { return bufbe16toh (GetOption ()); };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -80,6 +80,13 @@ namespace data {
|
||||
return i2p::data::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz);
|
||||
}
|
||||
|
||||
uint8_t GetBit (int i) const
|
||||
{
|
||||
int pos = i >> 3; // /8
|
||||
if (pos >= (int)sz) return 0;
|
||||
return m_Buf[pos] & (0x80 >> (i & 0x07));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
union // 8 bytes aligned
|
||||
|
||||
@@ -107,7 +107,10 @@ namespace transport
|
||||
int GetTerminationTimeout () const { return m_TerminationTimeout; };
|
||||
void SetTerminationTimeout (int terminationTimeout) { m_TerminationTimeout = terminationTimeout; };
|
||||
bool IsTerminationTimeoutExpired (uint64_t ts) const
|
||||
{ return ts >= m_LastActivityTimestamp + GetTerminationTimeout (); };
|
||||
{
|
||||
return ts >= m_LastActivityTimestamp + GetTerminationTimeout () ||
|
||||
ts + GetTerminationTimeout () < m_LastActivityTimestamp;
|
||||
};
|
||||
|
||||
uint32_t GetCreationTime () const { return m_CreationTime; };
|
||||
void SetCreationTime (uint32_t ts) { m_CreationTime = ts; }; // for introducers
|
||||
|
||||
@@ -476,7 +476,7 @@ namespace transport
|
||||
bool Transports::ConnectToPeer (const i2p::data::IdentHash& ident, Peer& peer)
|
||||
{
|
||||
if (!peer.router) // reconnect
|
||||
peer.router = netdb.FindRouter (ident); // try to get new one from netdb
|
||||
peer.SetRouter (netdb.FindRouter (ident)); // try to get new one from netdb
|
||||
if (peer.router) // we have RI already
|
||||
{
|
||||
if (peer.priority.empty ())
|
||||
@@ -539,7 +539,8 @@ namespace transport
|
||||
}
|
||||
|
||||
LogPrint (eLogInfo, "Transports: No compatible addresses available");
|
||||
i2p::data::netdb.SetUnreachable (ident, true); // we are here because all connection attempts failed
|
||||
if (peer.router->IsReachableFrom (i2p::context.GetRouterInfo ()))
|
||||
i2p::data::netdb.SetUnreachable (ident, true); // we are here because all connection attempts failed but router claimed them
|
||||
peer.Done ();
|
||||
std::unique_lock<std::mutex> l(m_PeersMutex);
|
||||
m_Peers.erase (ident);
|
||||
@@ -598,7 +599,7 @@ namespace transport
|
||||
if (r)
|
||||
{
|
||||
LogPrint (eLogDebug, "Transports: RouterInfo for ", ident.ToBase64 (), " found, trying to connect");
|
||||
it->second.router = r;
|
||||
it->second.SetRouter (r);
|
||||
ConnectToPeer (ident, it->second);
|
||||
}
|
||||
else
|
||||
@@ -815,20 +816,101 @@ namespace transport
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<const i2p::data::RouterInfo> Transports::GetRandomPeer () const
|
||||
template<typename Filter>
|
||||
std::shared_ptr<const i2p::data::RouterInfo> Transports::GetRandomPeer (Filter filter) const
|
||||
{
|
||||
if (m_Peers.empty ()) return nullptr;
|
||||
if (m_Peers.empty()) return nullptr;
|
||||
bool found = false;
|
||||
i2p::data::IdentHash ident;
|
||||
{
|
||||
uint16_t inds[3];
|
||||
RAND_bytes ((uint8_t *)inds, sizeof (inds));
|
||||
std::unique_lock<std::mutex> l(m_PeersMutex);
|
||||
inds[0] %= m_Peers.size ();
|
||||
auto it = m_Peers.begin ();
|
||||
std::advance (it, rand () % m_Peers.size ());
|
||||
if (it == m_Peers.end () || it->second.router || it->second.sessions.empty () ||
|
||||
it->second.sessions.front ()->GetSendQueueSize () > PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE)
|
||||
return nullptr; // not connected or overloaded
|
||||
ident = it->first;
|
||||
std::advance (it, inds[0]);
|
||||
// try random peer
|
||||
if (it != m_Peers.end () && filter (it->second))
|
||||
{
|
||||
ident = it->first;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// try some peers around
|
||||
auto it1 = m_Peers.begin ();
|
||||
if (inds[0])
|
||||
{
|
||||
// before
|
||||
inds[1] %= inds[0];
|
||||
std::advance (it1, (inds[1] + inds[0])/2);
|
||||
}
|
||||
else
|
||||
it1 = it;
|
||||
auto it2 = it;
|
||||
if (inds[0] < m_Peers.size () - 1)
|
||||
{
|
||||
// after
|
||||
inds[2] %= (m_Peers.size () - 1 - inds[0]); inds[2] /= 2;
|
||||
std::advance (it2, inds[2]);
|
||||
}
|
||||
// it1 - from, it2 - to
|
||||
it = it1;
|
||||
while (it != it2 && it != m_Peers.end ())
|
||||
{
|
||||
if (filter (it->second))
|
||||
{
|
||||
ident = it->first;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
// still not found, try from the beginning
|
||||
it = m_Peers.begin ();
|
||||
while (it != it1 && it != m_Peers.end ())
|
||||
{
|
||||
if (filter (it->second))
|
||||
{
|
||||
ident = it->first;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
// still not found, try to the beginning
|
||||
it = it2;
|
||||
while (it != m_Peers.end ())
|
||||
{
|
||||
if (filter (it->second))
|
||||
{
|
||||
ident = it->first;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return i2p::data::netdb.FindRouter (ident);
|
||||
return found ? i2p::data::netdb.FindRouter (ident) : nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<const i2p::data::RouterInfo> Transports::GetRandomPeer (bool isHighBandwidth) const
|
||||
{
|
||||
return GetRandomPeer (
|
||||
[isHighBandwidth](const Peer& peer)->bool
|
||||
{
|
||||
// connected and not overloaded
|
||||
return !peer.router && !peer.sessions.empty () &&
|
||||
peer.sessions.front ()->GetSendQueueSize () <= PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE &&
|
||||
(!isHighBandwidth || peer.isHighBandwidth);
|
||||
});
|
||||
}
|
||||
|
||||
void Transports::RestrictRoutesToFamilies(const std::set<std::string>& families)
|
||||
|
||||
@@ -72,11 +72,15 @@ namespace transport
|
||||
uint64_t creationTime, nextRouterInfoUpdateTime;
|
||||
std::vector<std::shared_ptr<i2p::I2NPMessage> > delayedMessages;
|
||||
std::vector<i2p::data::RouterInfo::SupportedTransports> priority;
|
||||
bool isHighBandwidth;
|
||||
|
||||
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)
|
||||
nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL),
|
||||
isHighBandwidth (false)
|
||||
{
|
||||
if (router)
|
||||
isHighBandwidth = router->IsHighBandwidth ();
|
||||
}
|
||||
|
||||
void Done ()
|
||||
@@ -84,6 +88,13 @@ namespace transport
|
||||
for (auto& it: sessions)
|
||||
it->Done ();
|
||||
}
|
||||
|
||||
void SetRouter (std::shared_ptr<const i2p::data::RouterInfo> r)
|
||||
{
|
||||
router = r;
|
||||
if (router)
|
||||
isHighBandwidth = router->IsHighBandwidth ();
|
||||
}
|
||||
};
|
||||
|
||||
const uint64_t SESSION_CREATION_TIMEOUT = 15; // in seconds
|
||||
@@ -131,7 +142,7 @@ namespace transport
|
||||
bool IsBandwidthExceeded () const;
|
||||
bool IsTransitBandwidthExceeded () const;
|
||||
size_t GetNumPeers () const { return m_Peers.size (); };
|
||||
std::shared_ptr<const i2p::data::RouterInfo> GetRandomPeer () const;
|
||||
std::shared_ptr<const i2p::data::RouterInfo> GetRandomPeer (bool isHighBandwidth) const;
|
||||
|
||||
/** get a trusted first hop for restricted routes */
|
||||
std::shared_ptr<const i2p::data::RouterInfo> GetRestrictedPeer() const;
|
||||
@@ -163,6 +174,9 @@ namespace transport
|
||||
|
||||
void DetectExternalIP ();
|
||||
|
||||
template<typename Filter>
|
||||
std::shared_ptr<const i2p::data::RouterInfo> GetRandomPeer (Filter filter) const;
|
||||
|
||||
private:
|
||||
|
||||
volatile bool m_IsOnline;
|
||||
|
||||
@@ -331,12 +331,15 @@ namespace tunnel
|
||||
|
||||
Tunnels tunnels;
|
||||
|
||||
Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr),
|
||||
m_TunnelCreationSuccessRate (TCSR_START_VALUE), m_TunnelCreationAttemptsNum(0) {
|
||||
Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr), m_MaxNumTransitTunnels (DEFAULT_MAX_NUM_TRANSIT_TUNNELS),
|
||||
m_TotalNumSuccesiveTunnelCreations (0), m_TotalNumFailedTunnelCreations (0), // for normal avarage
|
||||
m_TunnelCreationSuccessRate (TCSR_START_VALUE), m_TunnelCreationAttemptsNum(0)
|
||||
{
|
||||
}
|
||||
|
||||
Tunnels::~Tunnels ()
|
||||
{
|
||||
DeleteTunnelPool(m_ExploratoryPool);
|
||||
}
|
||||
|
||||
std::shared_ptr<TunnelBase> Tunnels::GetTunnel (uint32_t tunnelID)
|
||||
@@ -437,11 +440,11 @@ namespace tunnel
|
||||
if (m_Tunnels.emplace (tunnel->GetTunnelID (), tunnel).second)
|
||||
m_TransitTunnels.push_back (tunnel);
|
||||
else
|
||||
{
|
||||
{
|
||||
LogPrint (eLogError, "Tunnel: Tunnel with id ", tunnel->GetTunnelID (), " already exists");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Tunnels::Start ()
|
||||
@@ -535,17 +538,20 @@ namespace tunnel
|
||||
if (i2p::transport::transports.IsOnline())
|
||||
{
|
||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
if (ts - lastTs >= TUNNEL_MANAGE_INTERVAL) // manage tunnels every 15 seconds
|
||||
if (ts - lastTs >= TUNNEL_MANAGE_INTERVAL || // manage tunnels every 15 seconds
|
||||
ts + TUNNEL_MANAGE_INTERVAL < lastTs)
|
||||
{
|
||||
ManageTunnels ();
|
||||
ManageTunnels (ts);
|
||||
lastTs = ts;
|
||||
}
|
||||
if (ts - lastPoolsTs >= TUNNEL_POOLS_MANAGE_INTERVAL) // manage pools every 5 seconds
|
||||
if (ts - lastPoolsTs >= TUNNEL_POOLS_MANAGE_INTERVAL || // manage pools every 5 secondsts
|
||||
ts + TUNNEL_POOLS_MANAGE_INTERVAL < lastPoolsTs)
|
||||
{
|
||||
ManageTunnelPools (ts);
|
||||
lastPoolsTs = ts;
|
||||
}
|
||||
if (ts - lastMemoryPoolTs >= TUNNEL_MEMORY_POOL_MANAGE_INTERVAL) // manage memory pool every 2 minutes
|
||||
if (ts - lastMemoryPoolTs >= TUNNEL_MEMORY_POOL_MANAGE_INTERVAL ||
|
||||
ts + TUNNEL_MEMORY_POOL_MANAGE_INTERVAL < lastMemoryPoolTs) // manage memory pool every 2 minutes
|
||||
{
|
||||
m_I2NPTunnelEndpointMessagesMemoryPool.CleanUpMt ();
|
||||
m_I2NPTunnelMessagesMemoryPool.CleanUpMt ();
|
||||
@@ -587,32 +593,32 @@ namespace tunnel
|
||||
tunnel->SendTunnelDataMsg (msg);
|
||||
}
|
||||
|
||||
void Tunnels::ManageTunnels ()
|
||||
void Tunnels::ManageTunnels (uint64_t ts)
|
||||
{
|
||||
ManagePendingTunnels ();
|
||||
ManageInboundTunnels ();
|
||||
ManageOutboundTunnels ();
|
||||
ManageTransitTunnels ();
|
||||
ManagePendingTunnels (ts);
|
||||
ManageInboundTunnels (ts);
|
||||
ManageOutboundTunnels (ts);
|
||||
ManageTransitTunnels (ts);
|
||||
}
|
||||
|
||||
void Tunnels::ManagePendingTunnels ()
|
||||
void Tunnels::ManagePendingTunnels (uint64_t ts)
|
||||
{
|
||||
ManagePendingTunnels (m_PendingInboundTunnels);
|
||||
ManagePendingTunnels (m_PendingOutboundTunnels);
|
||||
ManagePendingTunnels (m_PendingInboundTunnels, ts);
|
||||
ManagePendingTunnels (m_PendingOutboundTunnels, ts);
|
||||
}
|
||||
|
||||
template<class PendingTunnels>
|
||||
void Tunnels::ManagePendingTunnels (PendingTunnels& pendingTunnels)
|
||||
void Tunnels::ManagePendingTunnels (PendingTunnels& pendingTunnels, uint64_t ts)
|
||||
{
|
||||
// check pending tunnel. delete failed or timeout
|
||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
for (auto it = pendingTunnels.begin (); it != pendingTunnels.end ();)
|
||||
{
|
||||
auto tunnel = it->second;
|
||||
switch (tunnel->GetState ())
|
||||
{
|
||||
case eTunnelStatePending:
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT)
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT ||
|
||||
ts + TUNNEL_CREATION_TIMEOUT < tunnel->GetCreationTime ())
|
||||
{
|
||||
LogPrint (eLogDebug, "Tunnel: Pending build request ", it->first, " timeout, deleted");
|
||||
// update stats
|
||||
@@ -655,41 +661,38 @@ namespace tunnel
|
||||
}
|
||||
}
|
||||
|
||||
void Tunnels::ManageOutboundTunnels ()
|
||||
void Tunnels::ManageOutboundTunnels (uint64_t ts)
|
||||
{
|
||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
for (auto it = m_OutboundTunnels.begin (); it != m_OutboundTunnels.end ();)
|
||||
{
|
||||
for (auto it = m_OutboundTunnels.begin (); it != m_OutboundTunnels.end ();)
|
||||
auto tunnel = *it;
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
{
|
||||
auto tunnel = *it;
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
LogPrint (eLogDebug, "Tunnel: Tunnel with id ", tunnel->GetTunnelID (), " expired");
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
if (pool)
|
||||
pool->TunnelExpired (tunnel);
|
||||
// we don't have outbound tunnels in m_Tunnels
|
||||
it = m_OutboundTunnels.erase (it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tunnel->IsEstablished ())
|
||||
{
|
||||
LogPrint (eLogDebug, "Tunnel: Tunnel with id ", tunnel->GetTunnelID (), " expired");
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
if (pool)
|
||||
pool->TunnelExpired (tunnel);
|
||||
// we don't have outbound tunnels in m_Tunnels
|
||||
it = m_OutboundTunnels.erase (it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tunnel->IsEstablished ())
|
||||
if (!tunnel->IsRecreated () && ts + TUNNEL_RECREATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
{
|
||||
if (!tunnel->IsRecreated () && ts + TUNNEL_RECREATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
// let it die if the tunnel pool has been reconfigured and this is old
|
||||
if (pool && tunnel->GetNumHops() == pool->GetNumOutboundHops())
|
||||
{
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
// let it die if the tunnel pool has been reconfigured and this is old
|
||||
if (pool && tunnel->GetNumHops() == pool->GetNumOutboundHops())
|
||||
{
|
||||
tunnel->SetRecreated (true);
|
||||
pool->RecreateOutboundTunnel (tunnel);
|
||||
}
|
||||
tunnel->SetRecreated (true);
|
||||
pool->RecreateOutboundTunnel (tunnel);
|
||||
}
|
||||
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
tunnel->SetState (eTunnelStateExpiring);
|
||||
}
|
||||
++it;
|
||||
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
tunnel->SetState (eTunnelStateExpiring);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,44 +712,42 @@ namespace tunnel
|
||||
}
|
||||
}
|
||||
|
||||
void Tunnels::ManageInboundTunnels ()
|
||||
void Tunnels::ManageInboundTunnels (uint64_t ts)
|
||||
{
|
||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();)
|
||||
{
|
||||
for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();)
|
||||
auto tunnel = *it;
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT ||
|
||||
ts + TUNNEL_EXPIRATION_TIMEOUT < tunnel->GetCreationTime ())
|
||||
{
|
||||
auto tunnel = *it;
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
LogPrint (eLogDebug, "Tunnel: Tunnel with id ", tunnel->GetTunnelID (), " expired");
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
if (pool)
|
||||
pool->TunnelExpired (tunnel);
|
||||
m_Tunnels.erase (tunnel->GetTunnelID ());
|
||||
it = m_InboundTunnels.erase (it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tunnel->IsEstablished ())
|
||||
{
|
||||
LogPrint (eLogDebug, "Tunnel: Tunnel with id ", tunnel->GetTunnelID (), " expired");
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
if (pool)
|
||||
pool->TunnelExpired (tunnel);
|
||||
m_Tunnels.erase (tunnel->GetTunnelID ());
|
||||
it = m_InboundTunnels.erase (it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tunnel->IsEstablished ())
|
||||
if (!tunnel->IsRecreated () && ts + TUNNEL_RECREATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
{
|
||||
if (!tunnel->IsRecreated () && ts + TUNNEL_RECREATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
// let it die if the tunnel pool was reconfigured and has different number of hops
|
||||
if (pool && tunnel->GetNumHops() == pool->GetNumInboundHops())
|
||||
{
|
||||
auto pool = tunnel->GetTunnelPool ();
|
||||
// let it die if the tunnel pool was reconfigured and has different number of hops
|
||||
if (pool && tunnel->GetNumHops() == pool->GetNumInboundHops())
|
||||
{
|
||||
tunnel->SetRecreated (true);
|
||||
pool->RecreateInboundTunnel (tunnel);
|
||||
}
|
||||
tunnel->SetRecreated (true);
|
||||
pool->RecreateInboundTunnel (tunnel);
|
||||
}
|
||||
|
||||
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
tunnel->SetState (eTunnelStateExpiring);
|
||||
else // we don't need to cleanup expiring tunnels
|
||||
tunnel->Cleanup ();
|
||||
}
|
||||
it++;
|
||||
|
||||
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
tunnel->SetState (eTunnelStateExpiring);
|
||||
else // we don't need to cleanup expiring tunnels
|
||||
tunnel->Cleanup ();
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,13 +786,13 @@ namespace tunnel
|
||||
}
|
||||
}
|
||||
|
||||
void Tunnels::ManageTransitTunnels ()
|
||||
void Tunnels::ManageTransitTunnels (uint64_t ts)
|
||||
{
|
||||
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
for (auto it = m_TransitTunnels.begin (); it != m_TransitTunnels.end ();)
|
||||
{
|
||||
auto tunnel = *it;
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT ||
|
||||
ts + TUNNEL_EXPIRATION_TIMEOUT < tunnel->GetCreationTime ())
|
||||
{
|
||||
LogPrint (eLogDebug, "Tunnel: Transit tunnel with id ", tunnel->GetTunnelID (), " expired");
|
||||
m_Tunnels.erase (tunnel->GetTunnelID ());
|
||||
@@ -970,5 +971,14 @@ namespace tunnel
|
||||
// TODO: locking
|
||||
return m_OutboundTunnels.size();
|
||||
}
|
||||
|
||||
void Tunnels::SetMaxNumTransitTunnels (uint16_t maxNumTransitTunnels)
|
||||
{
|
||||
if (maxNumTransitTunnels > 0 && m_MaxNumTransitTunnels != maxNumTransitTunnels)
|
||||
{
|
||||
LogPrint (eLogDebug, "Tunnel: Max number of transit tunnels set to ", maxNumTransitTunnels);
|
||||
m_MaxNumTransitTunnels = maxNumTransitTunnels;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,11 @@ namespace tunnel
|
||||
const int MAX_NUM_RECORDS = 8;
|
||||
const int HIGH_LATENCY_PER_HOP = 250; // in milliseconds
|
||||
const int MAX_TUNNEL_MSGS_BATCH_SIZE = 100; // handle messages without interrupt
|
||||
const uint16_t DEFAULT_MAX_NUM_TRANSIT_TUNNELS = 5000;
|
||||
const int TUNNEL_MANAGE_INTERVAL = 15; // in seconds
|
||||
const int TUNNEL_POOLS_MANAGE_INTERVAL = 5; // in seconds
|
||||
const int TUNNEL_MEMORY_POOL_MANAGE_INTERVAL = 120; // in seconds
|
||||
|
||||
|
||||
const size_t I2NP_TUNNEL_MESSAGE_SIZE = TUNNEL_DATA_MSG_SIZE + I2NP_HEADER_SIZE + 34; // reserved for alignment and NTCP 16 + 6 + 12
|
||||
const size_t I2NP_TUNNEL_ENPOINT_MESSAGE_SIZE = 2*TUNNEL_DATA_MSG_SIZE + I2NP_HEADER_SIZE + TUNNEL_GATEWAY_HEADER_SIZE + 28; // reserved for alignment and NTCP 16 + 6 + 6
|
||||
|
||||
@@ -229,6 +230,10 @@ namespace tunnel
|
||||
|
||||
std::shared_ptr<I2NPMessage> NewI2NPTunnelMessage (bool endpoint);
|
||||
|
||||
void SetMaxNumTransitTunnels (uint16_t maxNumTransitTunnels);
|
||||
uint16_t GetMaxNumTransitTunnels () const { return m_MaxNumTransitTunnels; };
|
||||
bool IsTooManyTransitTunnels () const { return m_TransitTunnels.size () >= m_MaxNumTransitTunnels; };
|
||||
|
||||
private:
|
||||
|
||||
template<class TTunnel>
|
||||
@@ -241,18 +246,36 @@ namespace tunnel
|
||||
void HandleTunnelGatewayMsg (std::shared_ptr<TunnelBase> tunnel, std::shared_ptr<I2NPMessage> msg);
|
||||
|
||||
void Run ();
|
||||
void ManageTunnels ();
|
||||
void ManageOutboundTunnels ();
|
||||
void ManageInboundTunnels ();
|
||||
void ManageTransitTunnels ();
|
||||
void ManagePendingTunnels ();
|
||||
void ManageTunnels (uint64_t ts);
|
||||
void ManageOutboundTunnels (uint64_t ts);
|
||||
void ManageInboundTunnels (uint64_t ts);
|
||||
void ManageTransitTunnels (uint64_t ts);
|
||||
void ManagePendingTunnels (uint64_t ts);
|
||||
template<class PendingTunnels>
|
||||
void ManagePendingTunnels (PendingTunnels& pendingTunnels);
|
||||
void ManagePendingTunnels (PendingTunnels& pendingTunnels, uint64_t ts);
|
||||
void ManageTunnelPools (uint64_t ts);
|
||||
|
||||
std::shared_ptr<ZeroHopsInboundTunnel> CreateZeroHopsInboundTunnel (std::shared_ptr<TunnelPool> pool);
|
||||
std::shared_ptr<ZeroHopsOutboundTunnel> CreateZeroHopsOutboundTunnel (std::shared_ptr<TunnelPool> pool);
|
||||
|
||||
// Calculating of tunnel creation success rate
|
||||
void SuccesiveTunnelCreation()
|
||||
{
|
||||
// total TCSR
|
||||
m_TotalNumSuccesiveTunnelCreations++;
|
||||
// A modified version of the EWMA algorithm, where alpha is increased at the beginning to accelerate similarity
|
||||
double alpha = TCSR_SMOOTHING_CONSTANT + (1 - TCSR_SMOOTHING_CONSTANT)/++m_TunnelCreationAttemptsNum;
|
||||
m_TunnelCreationSuccessRate = alpha * 1 + (1 - alpha) * m_TunnelCreationSuccessRate;
|
||||
|
||||
}
|
||||
void FailedTunnelCreation()
|
||||
{
|
||||
m_TotalNumFailedTunnelCreations++;
|
||||
|
||||
double alpha = TCSR_SMOOTHING_CONSTANT + (1 - TCSR_SMOOTHING_CONSTANT)/++m_TunnelCreationAttemptsNum;
|
||||
m_TunnelCreationSuccessRate = alpha * 0 + (1 - alpha) * m_TunnelCreationSuccessRate;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool m_IsRunning;
|
||||
@@ -269,18 +292,9 @@ namespace tunnel
|
||||
i2p::util::Queue<std::shared_ptr<I2NPMessage> > m_Queue;
|
||||
i2p::util::MemoryPoolMt<I2NPMessageBuffer<I2NP_TUNNEL_ENPOINT_MESSAGE_SIZE> > m_I2NPTunnelEndpointMessagesMemoryPool;
|
||||
i2p::util::MemoryPoolMt<I2NPMessageBuffer<I2NP_TUNNEL_MESSAGE_SIZE> > m_I2NPTunnelMessagesMemoryPool;
|
||||
|
||||
// Calculating of tunnel creation success rate
|
||||
// A modified version of the EWMA algorithm, where alpha is increased at the beginning to accelerate similarity
|
||||
void SuccesiveTunnelCreation() {
|
||||
double alpha = TCSR_SMOOTHING_CONSTANT + (1 - TCSR_SMOOTHING_CONSTANT)/++m_TunnelCreationAttemptsNum;
|
||||
m_TunnelCreationSuccessRate = alpha * 1 + (1 - alpha) * m_TunnelCreationSuccessRate;
|
||||
|
||||
};
|
||||
void FailedTunnelCreation() {
|
||||
double alpha = TCSR_SMOOTHING_CONSTANT + (1 - TCSR_SMOOTHING_CONSTANT)/++m_TunnelCreationAttemptsNum;
|
||||
m_TunnelCreationSuccessRate = alpha * 0 + (1 - alpha) * m_TunnelCreationSuccessRate;
|
||||
};
|
||||
uint16_t m_MaxNumTransitTunnels;
|
||||
// count of tunnels for total TCSR algorithm
|
||||
int m_TotalNumSuccesiveTunnelCreations, m_TotalNumFailedTunnelCreations;
|
||||
double m_TunnelCreationSuccessRate;
|
||||
int m_TunnelCreationAttemptsNum;
|
||||
|
||||
@@ -297,6 +311,11 @@ namespace tunnel
|
||||
|
||||
int GetQueueSize () { return m_Queue.GetSize (); };
|
||||
int GetTunnelCreationSuccessRate () const { return std::round(m_TunnelCreationSuccessRate * 100); } // in percents
|
||||
int GetTotalTunnelCreationSuccessRate () const // in percents
|
||||
{
|
||||
int totalNum = m_TotalNumSuccesiveTunnelCreations + m_TotalNumFailedTunnelCreations;
|
||||
return totalNum ? m_TotalNumSuccesiveTunnelCreations*100/totalNum : 0;
|
||||
}
|
||||
};
|
||||
|
||||
extern Tunnels tunnels;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -480,7 +480,7 @@ namespace tunnel
|
||||
return hop;
|
||||
}
|
||||
|
||||
bool StandardSelectPeers(Path & path, int numHops, bool inbound, SelectHopFunc nextHop)
|
||||
bool TunnelPool::StandardSelectPeers(Path & path, int numHops, bool inbound, SelectHopFunc nextHop)
|
||||
{
|
||||
int start = 0;
|
||||
std::shared_ptr<const i2p::data::RouterInfo> prevHop = i2p::context.GetSharedRouterInfo ();
|
||||
@@ -496,7 +496,7 @@ namespace tunnel
|
||||
else if (i2p::transport::transports.GetNumPeers () > 100 ||
|
||||
(inbound && i2p::transport::transports.GetNumPeers () > 25))
|
||||
{
|
||||
auto r = i2p::transport::transports.GetRandomPeer ();
|
||||
auto r = i2p::transport::transports.GetRandomPeer (!IsExploratory ());
|
||||
if (r && r->IsECIES () && !r->GetProfile ()->IsBad () &&
|
||||
(numHops > 1 || (r->IsV4 () && (!inbound || r->IsReachable ())))) // first inbound must be reachable
|
||||
{
|
||||
@@ -512,7 +512,7 @@ namespace tunnel
|
||||
if (!hop && !i) // if no suitable peer found for first hop, try already connected
|
||||
{
|
||||
LogPrint (eLogInfo, "Tunnels: Can't select first hop for a tunnel. Trying already connected");
|
||||
hop = i2p::transport::transports.GetRandomPeer ();
|
||||
hop = i2p::transport::transports.GetRandomPeer (false);
|
||||
if (hop && !hop->IsECIES ()) hop = nullptr;
|
||||
}
|
||||
if (!hop)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -54,12 +54,9 @@ namespace tunnel
|
||||
virtual bool SelectPeers(Path & peers, int hops, bool isInbound) = 0;
|
||||
};
|
||||
|
||||
|
||||
typedef std::function<std::shared_ptr<const i2p::data::RouterInfo>(std::shared_ptr<const i2p::data::RouterInfo>, bool)> SelectHopFunc;
|
||||
bool StandardSelectPeers(Path & path, int numHops, bool inbound, SelectHopFunc nextHop);
|
||||
|
||||
class TunnelPool: public std::enable_shared_from_this<TunnelPool> // per local destination
|
||||
{
|
||||
typedef std::function<std::shared_ptr<const i2p::data::RouterInfo>(std::shared_ptr<const i2p::data::RouterInfo>, bool)> SelectHopFunc;
|
||||
public:
|
||||
|
||||
TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels,
|
||||
@@ -116,6 +113,7 @@ namespace tunnel
|
||||
|
||||
// for overriding tunnel peer selection
|
||||
std::shared_ptr<const i2p::data::RouterInfo> SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop, bool reverse) const;
|
||||
bool StandardSelectPeers(Path & path, int numHops, bool inbound, SelectHopFunc nextHop);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -67,11 +67,15 @@ namespace api
|
||||
i2p::transport::transports.Start();
|
||||
LogPrint(eLogInfo, "API: Starting Tunnels");
|
||||
i2p::tunnel::tunnels.Start();
|
||||
LogPrint(eLogInfo, "API: Starting Router context");
|
||||
i2p::context.Start();
|
||||
}
|
||||
|
||||
void StopI2P ()
|
||||
{
|
||||
LogPrint(eLogInfo, "API: Shutting down");
|
||||
LogPrint(eLogInfo, "API: Stopping Router context");
|
||||
i2p::context.Stop();
|
||||
LogPrint(eLogInfo, "API: Stopping Tunnels");
|
||||
i2p::tunnel::tunnels.Stop();
|
||||
LogPrint(eLogInfo, "API: Stopping Transports");
|
||||
|
||||
119
libi2pd/util.cpp
119
libi2pd/util.cpp
@@ -8,13 +8,14 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
#include "util.h"
|
||||
#include "Log.h"
|
||||
#include "I2PEndian.h"
|
||||
|
||||
#if not defined (__FreeBSD__)
|
||||
#if !defined (__FreeBSD__) && !defined(_MSC_VER)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
@@ -36,6 +37,19 @@
|
||||
#include <iphlpapi.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
||||
#pragma pack(push,8)
|
||||
typedef struct tagTHREADNAME_INFO
|
||||
{
|
||||
DWORD dwType;
|
||||
LPCSTR szName;
|
||||
DWORD dwThreadID;
|
||||
DWORD dwFlags;
|
||||
} THREADNAME_INFO;
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
||||
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
|
||||
@@ -74,7 +88,8 @@ const char *inet_ntop_xp(int af, const void *src, char *dst, socklen_t size)
|
||||
ZeroMemory(&ss, sizeof(ss));
|
||||
ss.ss_family = af;
|
||||
|
||||
switch(af) {
|
||||
switch (af)
|
||||
{
|
||||
case AF_INET:
|
||||
((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
|
||||
break;
|
||||
@@ -160,7 +175,23 @@ namespace util
|
||||
#elif defined(__NetBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", (void *)name);
|
||||
#elif !defined(__gnu_hurd__)
|
||||
#if defined(_MSC_VER)
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = name;
|
||||
info.dwThreadID = -1;
|
||||
info.dwFlags = 0;
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 6320 6322)
|
||||
__try {
|
||||
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
}
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
pthread_setname_np(pthread_self(), name);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -178,7 +209,7 @@ namespace net
|
||||
PIP_ADAPTER_ADDRESSES pCurrAddresses = nullptr;
|
||||
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = nullptr;
|
||||
|
||||
if(GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen)
|
||||
if (GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen)
|
||||
== ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
FREE(pAddresses);
|
||||
@@ -189,7 +220,7 @@ namespace net
|
||||
AF_INET, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen
|
||||
);
|
||||
|
||||
if(dwRetVal != NO_ERROR)
|
||||
if (dwRetVal != NO_ERROR)
|
||||
{
|
||||
LogPrint(eLogError, "NetIface: GetMTU: Enclosed GetAdaptersAddresses() call has failed");
|
||||
FREE(pAddresses);
|
||||
@@ -197,19 +228,17 @@ namespace net
|
||||
}
|
||||
|
||||
pCurrAddresses = pAddresses;
|
||||
while(pCurrAddresses)
|
||||
while (pCurrAddresses)
|
||||
{
|
||||
PIP_ADAPTER_UNICAST_ADDRESS firstUnicastAddress = pCurrAddresses->FirstUnicastAddress;
|
||||
|
||||
pUnicast = pCurrAddresses->FirstUnicastAddress;
|
||||
if(pUnicast == nullptr)
|
||||
if (pUnicast == nullptr)
|
||||
LogPrint(eLogError, "NetIface: GetMTU: Not a unicast IPv4 address, this is not supported");
|
||||
|
||||
for(int i = 0; pUnicast != nullptr; ++i)
|
||||
while (pUnicast != nullptr)
|
||||
{
|
||||
LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr;
|
||||
sockaddr_in* localInterfaceAddress = (sockaddr_in*) lpAddr;
|
||||
if(localInterfaceAddress->sin_addr.S_un.S_addr == inputAddress.sin_addr.S_un.S_addr)
|
||||
if (localInterfaceAddress->sin_addr.S_un.S_addr == inputAddress.sin_addr.S_un.S_addr)
|
||||
{
|
||||
char addr[INET_ADDRSTRLEN];
|
||||
inetntop(AF_INET, &(((struct sockaddr_in *)localInterfaceAddress)->sin_addr), addr, INET_ADDRSTRLEN);
|
||||
@@ -263,12 +292,11 @@ namespace net
|
||||
pCurrAddresses = pAddresses;
|
||||
while (pCurrAddresses)
|
||||
{
|
||||
PIP_ADAPTER_UNICAST_ADDRESS firstUnicastAddress = pCurrAddresses->FirstUnicastAddress;
|
||||
pUnicast = pCurrAddresses->FirstUnicastAddress;
|
||||
if (pUnicast == nullptr)
|
||||
LogPrint(eLogError, "NetIface: GetMTU: Not a unicast IPv6 address, this is not supported");
|
||||
|
||||
for (int i = 0; pUnicast != nullptr; ++i)
|
||||
while (pUnicast != nullptr)
|
||||
{
|
||||
LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr;
|
||||
sockaddr_in6 *localInterfaceAddress = (sockaddr_in6*) lpAddr;
|
||||
@@ -316,13 +344,13 @@ namespace net
|
||||
IPN inetpton = (IPN)GetProcAddress (GetModuleHandle ("ws2_32.dll"), "InetPton");
|
||||
if (!inetpton) inetpton = inet_pton_xp; // use own implementation if not found
|
||||
|
||||
if(localAddress.is_v4())
|
||||
if (localAddress.is_v4())
|
||||
{
|
||||
sockaddr_in inputAddress;
|
||||
inetpton(AF_INET, localAddressUniversal.c_str(), &(inputAddress.sin_addr));
|
||||
return GetMTUWindowsIpv4(inputAddress, fallback);
|
||||
}
|
||||
else if(localAddress.is_v6())
|
||||
else if (localAddress.is_v6())
|
||||
{
|
||||
sockaddr_in6 inputAddress;
|
||||
inetpton(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
|
||||
@@ -338,7 +366,7 @@ namespace net
|
||||
int GetMTUUnix (const boost::asio::ip::address& localAddress, int fallback)
|
||||
{
|
||||
ifaddrs* ifaddr, *ifa = nullptr;
|
||||
if(getifaddrs(&ifaddr) == -1)
|
||||
if (getifaddrs(&ifaddr) == -1)
|
||||
{
|
||||
LogPrint(eLogError, "NetIface: Can't call getifaddrs(): ", strerror(errno));
|
||||
return fallback;
|
||||
@@ -346,34 +374,34 @@ namespace net
|
||||
|
||||
int family = 0;
|
||||
// look for interface matching local address
|
||||
for(ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next)
|
||||
for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next)
|
||||
{
|
||||
if(!ifa->ifa_addr)
|
||||
if (!ifa->ifa_addr)
|
||||
continue;
|
||||
|
||||
family = ifa->ifa_addr->sa_family;
|
||||
if(family == AF_INET && localAddress.is_v4())
|
||||
if (family == AF_INET && localAddress.is_v4())
|
||||
{
|
||||
sockaddr_in* sa = (sockaddr_in*) ifa->ifa_addr;
|
||||
if(!memcmp(&sa->sin_addr, localAddress.to_v4().to_bytes().data(), 4))
|
||||
if (!memcmp(&sa->sin_addr, localAddress.to_v4().to_bytes().data(), 4))
|
||||
break; // address matches
|
||||
}
|
||||
else if(family == AF_INET6 && localAddress.is_v6())
|
||||
else if (family == AF_INET6 && localAddress.is_v6())
|
||||
{
|
||||
sockaddr_in6* sa = (sockaddr_in6*) ifa->ifa_addr;
|
||||
if(!memcmp(&sa->sin6_addr, localAddress.to_v6().to_bytes().data(), 16))
|
||||
if (!memcmp(&sa->sin6_addr, localAddress.to_v6().to_bytes().data(), 16))
|
||||
break; // address matches
|
||||
}
|
||||
}
|
||||
int mtu = fallback;
|
||||
if(ifa && family)
|
||||
if (ifa && family)
|
||||
{ // interface found?
|
||||
int fd = socket(family, SOCK_DGRAM, 0);
|
||||
if(fd > 0)
|
||||
if (fd > 0)
|
||||
{
|
||||
ifreq ifr;
|
||||
strncpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ-1); // set interface for query
|
||||
if(ioctl(fd, SIOCGIFMTU, &ifr) >= 0)
|
||||
if (ioctl(fd, SIOCGIFMTU, &ifr) >= 0)
|
||||
mtu = ifr.ifr_mtu; // MTU
|
||||
else
|
||||
LogPrint (eLogError, "NetIface: Failed to run ioctl: ", strerror(errno));
|
||||
@@ -406,7 +434,7 @@ namespace net
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LogPrint(eLogError, "NetIface: Cannot get address by interface name, not implemented on WIN32");
|
||||
if(ipv6)
|
||||
if (ipv6)
|
||||
return boost::asio::ip::address::from_string("::1");
|
||||
else
|
||||
return boost::asio::ip::address::from_string("127.0.0.1");
|
||||
@@ -425,7 +453,7 @@ namespace net
|
||||
// match
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
memset (addr, 0, INET6_ADDRSTRLEN);
|
||||
if(af == AF_INET)
|
||||
if (af == AF_INET)
|
||||
inet_ntop(af, &((sockaddr_in *)cur->ifa_addr)->sin_addr, addr, INET6_ADDRSTRLEN);
|
||||
else
|
||||
inet_ntop(af, &((sockaddr_in6 *)cur->ifa_addr)->sin6_addr, addr, INET6_ADDRSTRLEN);
|
||||
@@ -441,9 +469,9 @@ namespace net
|
||||
LogPrint(eLogError, "NetIface: Exception while searching address using ifaddr: ", ex.what());
|
||||
}
|
||||
|
||||
if(addrs) freeifaddrs(addrs);
|
||||
if (addrs) freeifaddrs(addrs);
|
||||
std::string fallback;
|
||||
if(ipv6)
|
||||
if (ipv6)
|
||||
{
|
||||
fallback = "::1";
|
||||
LogPrint(eLogWarning, "NetIface: Cannot find IPv6 address for interface ", ifname);
|
||||
@@ -487,6 +515,22 @@ namespace net
|
||||
return IsYggdrasilAddress (addr.to_v6 ().to_bytes ().data ());
|
||||
}
|
||||
|
||||
bool IsPortInReservedRange (const uint16_t port) noexcept
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers (Feb. 3, 2023) + Tor browser (9150)
|
||||
static const std::unordered_set<uint16_t> reservedPorts{
|
||||
9119,9150,9306,9312,9389,9418,9535,9536,9695,
|
||||
9800,9899,10000,10050,10051,10110,10212,
|
||||
10933,11001,11112,11235,11371,12222,12223,
|
||||
13075,13400,13720,13721,13724,13782,13783,
|
||||
13785,13786,15345,17224,17225,17500,18104,
|
||||
19788,19812,19813,19814,19999,20000,24465,
|
||||
24554,26000,27000,27001,27002,27003,27004,
|
||||
27005,27006,27007,27008,27009,28000};
|
||||
|
||||
return (reservedPorts.find(port) != reservedPorts.end());
|
||||
}
|
||||
|
||||
boost::asio::ip::address_v6 GetYggdrasilAddress ()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
@@ -495,7 +539,7 @@ namespace net
|
||||
PIP_ADAPTER_ADDRESSES pCurrAddresses = nullptr;
|
||||
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = nullptr;
|
||||
|
||||
if(GetAdaptersAddresses(AF_INET6, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen)
|
||||
if (GetAdaptersAddresses(AF_INET6, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen)
|
||||
== ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
FREE(pAddresses);
|
||||
@@ -506,7 +550,7 @@ namespace net
|
||||
AF_INET6, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen
|
||||
);
|
||||
|
||||
if(dwRetVal != NO_ERROR)
|
||||
if (dwRetVal != NO_ERROR)
|
||||
{
|
||||
LogPrint(eLogError, "NetIface: GetYggdrasilAddress(): enclosed GetAdaptersAddresses() call has failed");
|
||||
FREE(pAddresses);
|
||||
@@ -514,12 +558,11 @@ namespace net
|
||||
}
|
||||
|
||||
pCurrAddresses = pAddresses;
|
||||
while(pCurrAddresses)
|
||||
while (pCurrAddresses)
|
||||
{
|
||||
PIP_ADAPTER_UNICAST_ADDRESS firstUnicastAddress = pCurrAddresses->FirstUnicastAddress;
|
||||
pUnicast = pCurrAddresses->FirstUnicastAddress;
|
||||
|
||||
for(int i = 0; pUnicast != nullptr; ++i)
|
||||
while (pUnicast != nullptr)
|
||||
{
|
||||
LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr;
|
||||
sockaddr_in6 *localInterfaceAddress = (sockaddr_in6*) lpAddr;
|
||||
@@ -563,7 +606,7 @@ namespace net
|
||||
LogPrint(eLogError, "NetIface: Exception while searching Yggdrasill address using ifaddr: ", ex.what());
|
||||
}
|
||||
LogPrint(eLogWarning, "NetIface: Interface with Yggdrasil network address not found");
|
||||
if(addrs) freeifaddrs(addrs);
|
||||
if (addrs) freeifaddrs(addrs);
|
||||
return boost::asio::ip::address_v6 ();
|
||||
#endif
|
||||
}
|
||||
@@ -583,7 +626,7 @@ namespace net
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
|
||||
if (host.is_unspecified ()) return false;
|
||||
if(host.is_v4())
|
||||
if (host.is_v4())
|
||||
{
|
||||
static const std::vector< std::pair<uint32_t, uint32_t> > reservedIPv4Ranges {
|
||||
address_pair_v4("0.0.0.0", "0.255.255.255"),
|
||||
@@ -603,12 +646,12 @@ namespace net
|
||||
};
|
||||
|
||||
uint32_t ipv4_address = host.to_v4 ().to_ulong ();
|
||||
for(const auto& it : reservedIPv4Ranges) {
|
||||
for (const auto& it : reservedIPv4Ranges) {
|
||||
if (ipv4_address >= it.first && ipv4_address <= it.second)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(host.is_v6())
|
||||
if (host.is_v6())
|
||||
{
|
||||
static const std::vector< std::pair<boost::asio::ip::address_v6::bytes_type, boost::asio::ip::address_v6::bytes_type> > reservedIPv6Ranges {
|
||||
address_pair_v6("2001:db8::", "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff"),
|
||||
@@ -620,7 +663,7 @@ namespace net
|
||||
};
|
||||
|
||||
boost::asio::ip::address_v6::bytes_type ipv6_address = host.to_v6 ().to_bytes ();
|
||||
for(const auto& it : reservedIPv6Ranges) {
|
||||
for (const auto& it : reservedIPv6Ranges) {
|
||||
if (ipv6_address >= it.first && ipv6_address <= it.second)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -224,6 +224,7 @@ namespace util
|
||||
bool IsLocalAddress (const boost::asio::ip::address& addr);
|
||||
bool IsInReservedRange (const boost::asio::ip::address& host);
|
||||
bool IsYggdrasilAddress (const boost::asio::ip::address& addr);
|
||||
bool IsPortInReservedRange (const uint16_t port) noexcept;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,16 +11,18 @@
|
||||
|
||||
#define CODENAME "Purple"
|
||||
|
||||
#define XSTRINGIZE(x) STRINGIZE(x)
|
||||
#define STRINGIZE(x) #x
|
||||
|
||||
#define MAKE_VERSION(a,b,c) STRINGIZE(a) "." STRINGIZE(b) "." STRINGIZE(c)
|
||||
#define MAKE_VERSION_NUMBER(a,b,c) ((a*100+b)*100+c)
|
||||
|
||||
#define I2PD_VERSION_MAJOR 2
|
||||
#define I2PD_VERSION_MINOR 45
|
||||
#define I2PD_VERSION_MICRO 1
|
||||
#define I2PD_VERSION_MINOR 47
|
||||
#define I2PD_VERSION_MICRO 0
|
||||
#define I2PD_VERSION_PATCH 0
|
||||
#ifdef GITVER
|
||||
#define I2PD_VERSION GITVER
|
||||
#define I2PD_VERSION XSTRINGIZE(GITVER)
|
||||
#else
|
||||
#define I2PD_VERSION MAKE_VERSION(I2PD_VERSION_MAJOR, I2PD_VERSION_MINOR, I2PD_VERSION_MICRO)
|
||||
#endif
|
||||
@@ -31,7 +33,7 @@
|
||||
|
||||
#define I2P_VERSION_MAJOR 0
|
||||
#define I2P_VERSION_MINOR 9
|
||||
#define I2P_VERSION_MICRO 57
|
||||
#define I2P_VERSION_MICRO 58
|
||||
#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)
|
||||
|
||||
@@ -63,18 +63,19 @@ namespace client
|
||||
if (sam)
|
||||
{
|
||||
std::string samAddr; i2p::config::GetOption("sam.address", samAddr);
|
||||
uint16_t samPort; i2p::config::GetOption("sam.port", samPort);
|
||||
uint16_t samPortTCP; i2p::config::GetOption("sam.port", samPortTCP);
|
||||
uint16_t samPortUDP; i2p::config::GetOption("sam.portudp", samPortUDP);
|
||||
bool singleThread; i2p::config::GetOption("sam.singlethread", singleThread);
|
||||
LogPrint(eLogInfo, "Clients: Starting SAM bridge at ", samAddr, ":", samPort);
|
||||
LogPrint(eLogInfo, "Clients: Starting SAM bridge at ", samAddr, ":[", samPortTCP, "|", samPortUDP, "]");
|
||||
try
|
||||
{
|
||||
m_SamBridge = new SAMBridge (samAddr, samPort, singleThread);
|
||||
m_SamBridge = new SAMBridge (samAddr, samPortTCP, samPortUDP, singleThread);
|
||||
m_SamBridge->Start ();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LogPrint(eLogError, "Clients: Exception in SAM bridge: ", e.what());
|
||||
ThrowFatal ("Unable to start SAM bridge at ", samAddr, ":", samPort, ": ", e.what ());
|
||||
ThrowFatal ("Unable to start SAM bridge at ", samAddr, ":[", samPortTCP, "|", samPortUDP,"]: ", e.what ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace proxy {
|
||||
i2p::http::URL m_ProxyURL;
|
||||
i2p::http::URL m_RequestURL;
|
||||
uint8_t m_socks_buf[255+8]; // for socks request/response
|
||||
ssize_t m_req_len;
|
||||
int m_req_len;
|
||||
i2p::http::URL m_ClientRequestURL;
|
||||
i2p::http::HTTPReq m_ClientRequest;
|
||||
i2p::http::HTTPRes m_ClientResponse;
|
||||
@@ -238,9 +238,33 @@ namespace proxy {
|
||||
std::string value = params["i2paddresshelper"];
|
||||
len += value.length();
|
||||
b64 = i2p::http::UrlDecode(value);
|
||||
|
||||
// if we need update exists, request formed with update param
|
||||
if (params["update"] == "true") { len += std::strlen("&update=true"); confirm = true; }
|
||||
if (pos != 0 && url.query[pos-1] == '&') { pos--; len++; } // if helper is not only one query option
|
||||
if (params["update"] == "true")
|
||||
{
|
||||
len += std::strlen("&update=true");
|
||||
confirm = true;
|
||||
}
|
||||
|
||||
// if helper is not only one query option and it placed after user's query
|
||||
if (pos != 0 && url.query[pos-1] == '&')
|
||||
{
|
||||
pos--;
|
||||
len++;
|
||||
}
|
||||
// if helper is not only one query option and it placed before user's query
|
||||
else if (pos == 0 && url.query.length () > len && url.query[len] == '&')
|
||||
{
|
||||
// we don't touch the '?' but remove the trailing '&'
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is no more query options, resetting hasquery flag
|
||||
url.hasquery = false;
|
||||
}
|
||||
|
||||
// reset hasquery flag and remove addresshelper from URL
|
||||
url.query.replace(pos, len, "");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -72,7 +72,7 @@ namespace client
|
||||
bool MatchedTunnelDestination::SelectPeers(i2p::tunnel::Path & path, int hops, bool inbound)
|
||||
{
|
||||
auto pool = GetTunnelPool();
|
||||
if(!i2p::tunnel::StandardSelectPeers(path, hops, inbound,
|
||||
if(!pool || !pool->StandardSelectPeers(path, hops, inbound,
|
||||
std::bind(&i2p::tunnel::TunnelPool::SelectNextHop, pool, std::placeholders::_1, std::placeholders::_2)))
|
||||
return false;
|
||||
// more here for outbound tunnels
|
||||
|
||||
@@ -1244,10 +1244,10 @@ namespace client
|
||||
// TODO: implement datagrams
|
||||
}
|
||||
|
||||
SAMBridge::SAMBridge (const std::string& address, int port, bool singleThread):
|
||||
SAMBridge::SAMBridge (const std::string& address, int portTCP, int portUDP, bool singleThread):
|
||||
RunnableService ("SAM"), m_IsSingleThread (singleThread),
|
||||
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), port)),
|
||||
m_DatagramEndpoint (boost::asio::ip::address::from_string(address), port-1), m_DatagramSocket (GetIOService (), m_DatagramEndpoint),
|
||||
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), portTCP)),
|
||||
m_DatagramEndpoint (boost::asio::ip::address::from_string(address), (!portUDP) ? portTCP-1 : portUDP), m_DatagramSocket (GetIOService (), m_DatagramEndpoint),
|
||||
m_SignatureTypes
|
||||
{
|
||||
{"DSA_SHA1", i2p::data::SIGNING_KEY_TYPE_DSA_SHA1},
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace client
|
||||
{
|
||||
public:
|
||||
|
||||
SAMBridge (const std::string& address, int port, bool singleThread);
|
||||
SAMBridge (const std::string& address, int portTCP, int portUDP, bool singleThread);
|
||||
~SAMBridge ();
|
||||
|
||||
void Start ();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user