[ref] some improvements

This commit is contained in:
oldnick85
2025-10-24 21:36:27 +03:00
parent f65c329ce9
commit 82f003e327
11 changed files with 252 additions and 234 deletions
+56 -23
View File
@@ -1,37 +1,70 @@
# I2PD_YGGDRASIL_DOCKER
# 🌐🔒 I2P over Yggdrasil Network
## Description
## 📝 Description
This project is a set of tools for building [I2PD](https://i2pd.website/) over [YGGDRASIL](https://yggdrasil-network.github.io/) docker images.
No clearnet for i2p, only yggdrasil!
A Docker container that runs [I2PD](https://i2pd.website/) over the [Yggdrasil](https://yggdrasil-network.github.io/) encrypted mesh network, providing enhanced anonymity and network resilience.
No clearnet for I2P (Invisible Internet Project), only Yggdrasil!
## 🎯 Overview
This project creates a privacy-focused networking stack that combines:
- **I2P (Invisible Internet Project)**: An anonymous overlay network that focuses on secure and anonymous communication
- **Yggdrasil Network**: An early-stage implementation of an encrypted IPv6 routing network for mesh and point-to-point connectivity
### ✨ Key Features
- **Double Encryption** 🔒🔒: Traffic is encrypted through both Yggdrasil and I2P layers
- **Mesh Networking** 🕸️: Operates over Yggdrasil's peer-to-peer mesh network
- **Enhanced Anonymity** 🎭: I2P's anonymity features combined with Yggdrasil's encryption
- **Automatic Peer Discovery** 🔍: Automatically finds and connects to optimal Yggdrasil peers
- **Strong Cryptography** 🛡️: Generates cryptographically strong Yggdrasil addresses
## 🏗️ Architecture
At startup, the script searches YGGDRASIL public peers and chooses several best of them.
Then it generates YGGDRASIL *PublicKey* and *PrivateKey* unless the keys not set in environment variables.
## Preparations
+-------------------------+
| I2P Applications |
+-------------------------+
| I2P Routing Layer |
+-------------------------+
| Yggdrasil Network Layer |
+-------------------------+
| Physical Network |
+-------------------------+
Before building and deploying i2pd_yggdrasil docker image, you need to run the script
## 📋 Prerequisites
> bash support/requirements.sh
- Docker Engine 20.10+
- Docker Compose 2.0+
- Linux host (for TUN device access)
- IPv6 support enabled
## Building
## 🚀 Quick Start
You can build docker image by simply run script *make_i2pd_yggdrasil_docker_image.sh*.
1. **Clone and build** 📥:
```bash
chmod +x make_docker_image.sh
./make_docker_image.sh
```
> bash support/make_docker_image.sh
2. **Run with Docker Compose** 🏃‍♂️:
```bash
docker-compose up -d
```
Feel free to modify it with your own building arguments.
3. **Access (I2P web console)[http://localhost:7070] to check I2P router state** 🌐:
```bash
# View I2P status
curl http://localhost:7070
```
## Running
## Security Considerations 🔒
To run docker container just use docker-compose like this
> docker-compose -f src/docker-compose.yml up -d
## Deploy
To deploy built image to your host use script
> bash support/docker_deploy.sh
Note, this script takes parameters from *secrets/settings.json*, look *secrets/settings_pattern.json* for example.
- The container runs with NET_ADMIN capabilities for TUN device access
- Yggdrasil keys are generated automatically on first run
- I2P is configured in floodfill mode by default (can be disabled)
- Both networks use strong encryption by default
-50
View File
@@ -1,50 +0,0 @@
#!/bin/bash
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y gcc
sudo apt-get install -y \
git \
make \
cmake \
debhelper
sudo apt-get install -y \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libssl-dev \
zlib1g-dev
sudo apt-get install -y \
libminiupnpc-dev
mkdir /tmp/BUILD_I2PD/
cd /tmp/BUILD_I2PD/
git clone --depth 1 --branch 2.58.0 https://github.com/PurpleI2P/i2pd.git
cd /tmp/BUILD_I2PD/i2pd/build
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_AESNI=ON -DWITH_UPNP=ON .
make
sudo apt-get install -y golang
mkdir /tmp/BUILD_YGGDRASIL/
cd /tmp/BUILD_YGGDRASIL/
git clone --depth 1 --branch $YGGDRASIL_VERSION https://github.com/yggdrasil-network/yggdrasil-go.git
ENV CGO_ENABLED=0
cd /tmp/BUILD_YGGDRASIL/yggdrasil-go
sed -i -e 's/yggdrasil yggdrasilctl/yggdrasil yggdrasilctl genkeys/g' build
./build
sudo apt-get install -y \
libminiupnpc17 \
git python3 python3-pip iputils-ping
mkdir /opt/I2PD/
cd /opt/I2PD/
cp /opt/BUILD_I2PD/i2pd/build/i2pd .
cp /opt/BUILD_I2PD/i2pd/contrib/certificates ./certificates
cp /tmp/i2pd_yggdrasil_docker/i2pd.conf .
ulimit -n 4096
mkdir /opt/YGGDRASIL/
cd /opt/YGGDRASIL/
cp /tmp/BUILD_YGGDRASIL/yggdrasil-go/yggdrasil .
cp /tmp/BUILD_YGGDRASIL/yggdrasil-go/yggdrasilctl .
cp /tmp/BUILD_YGGDRASIL/yggdrasil-go/genkeys .
cp /tmp/i2pd_yggdrasil_docker/yggdrasil.conf .
-25
View File
@@ -1,25 +0,0 @@
#!/bin/bash
git config --global advice.detachedHead false
git clone --depth 1 --branch v0 https://github.com/oldnick85/yggdrasil_get_keys.git /tmp/yggdrasil_get_keys
python3 -m pip install -r /tmp/yggdrasil_get_keys/requirements.txt
python3 /tmp/yggdrasil_get_keys/yggdrasil_get_keys.py \
--genkeys="/opt/YGGDRASIL/genkeys" \
--yggdrasil-conf="/opt/YGGDRASIL/yggdrasil.conf" \
--timeout=60 \
--environment
rm -rf /tmp/yggdrasil_get_keys
git clone --depth 1 --branch v3 https://github.com/oldnick85/yggdrasil_find_public_peers.git /tmp/yggdrasil_find_public_peers
python3 -m pip install -r /tmp/yggdrasil_find_public_peers/requirements.txt
python3 /tmp/yggdrasil_find_public_peers/yggdrasil_find_public_peers.py \
--yggdrasil-conf="/opt/YGGDRASIL/yggdrasil.conf" \
--parallel=4 \
--pings=10 \
--best=5 \
--ping-interval=0.5
rm -rf yggdrasil_find_public_peers
sysctl net.ipv6.conf.all.disable_ipv6=0 || true
/opt/YGGDRASIL/yggdrasil -useconffile /opt/YGGDRASIL/yggdrasil.conf &
sleep 1m
/opt/I2PD/i2pd --datadir /opt/I2PD --conf /opt/I2PD/i2pd.conf &
wait -n
exit $?
-8
View File
@@ -1,8 +0,0 @@
{
"deploy" :
{
"host" : "0.0.0.0",
"user" : "root",
"path" : "/opt"
}
}
+100 -82
View File
@@ -1,120 +1,138 @@
# syntax=docker/dockerfile:1
ARG UBUNTU_VERSION=24.04
# I2P build stage
FROM ubuntu:${UBUNTU_VERSION} AS builder_i2pd
ARG I2PD_VERSION=2.58.0
ARG I2PD_COMPILER=gcc
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update &&\
apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y $I2PD_COMPILER
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
git \
make \
cmake \
debhelper
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libssl-dev \
zlib1g-dev
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
libminiupnpc-dev
WORKDIR /BUILD_I2PD/
RUN git config --global advice.detachedHead false
RUN git clone --depth 1 --branch $I2PD_VERSION https://github.com/PurpleI2P/i2pd.git
WORKDIR /BUILD_I2PD/i2pd/build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DWITH_AESNI=ON -DWITH_UPNP=ON .
RUN make
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get -y upgrade && \
apt-get install -y \
$I2PD_COMPILER \
git make cmake debhelper \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libssl-dev \
zlib1g-dev \
libminiupnpc-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /BUILD_I2PD/
RUN git config --global advice.detachedHead false && \
git clone --depth 1 --branch $I2PD_VERSION https://github.com/PurpleI2P/i2pd.git
WORKDIR /BUILD_I2PD/i2pd/build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DWITH_AESNI=ON -DWITH_UPNP=ON . && \
make -j$(nproc)
# Yggdrasil build stage
FROM ubuntu:${UBUNTU_VERSION} as builder_yggdrasil
ARG YGGDRASIL_VERSION=v0.5.12
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y git golang
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get -y upgrade && \
apt-get install -y git golang && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /BUILD_YGGDRASIL/
RUN git config --global advice.detachedHead false
RUN git clone --depth 1 --branch $YGGDRASIL_VERSION https://github.com/yggdrasil-network/yggdrasil-go.git
RUN git config --global advice.detachedHead false && \
git clone --depth 1 --branch $YGGDRASIL_VERSION https://github.com/yggdrasil-network/yggdrasil-go.git
ENV CGO_ENABLED=0
WORKDIR /BUILD_YGGDRASIL/yggdrasil-go
# add genkeys to build
RUN sed -i -e 's/yggdrasil yggdrasilctl/yggdrasil yggdrasilctl genkeys/g' build
RUN ./build
# script to get strong yggdrasil address (https://yggdrasil-network.github.io/configuration.html#generating-stronger-addresses-and-prefixes)
RUN git clone --depth 1 --branch v0 https://github.com/oldnick85/yggdrasil_get_keys.git /UTILS/yggdrasil_get_keys
RUN rm -rf /UTILS/yggdrasil_get_keys/.git
# script to find yggdrasil public peers
RUN git clone --depth 1 --branch v4 https://github.com/oldnick85/yggdrasil_find_public_peers.git /UTILS/yggdrasil_find_public_peers
RUN rm -rf /UTILS/yggdrasil_find_public_peers/.git
# Add genkeys to build and build binaries
RUN sed -i 's/yggdrasil yggdrasilctl/yggdrasil yggdrasilctl genkeys/g' build && \
./build
# Utility scripts for enhanced Yggdrasil functionality
RUN git clone --depth 1 --branch v0 https://github.com/oldnick85/yggdrasil_get_keys.git /UTILS/yggdrasil_get_keys && \
git clone --depth 1 --branch v4 https://github.com/oldnick85/yggdrasil_find_public_peers.git /UTILS/yggdrasil_find_public_peers && \
rm -rf /UTILS/yggdrasil_get_keys/.git /UTILS/yggdrasil_find_public_peers/.git
# Final runtime image
FROM ubuntu:${UBUNTU_VERSION}
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get -y upgrade && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libssl3 \
zlib1g \
libminiupnpc17 \
git \
python3 python3-pip iputils-ping && \
apt-get clean -y
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libssl3 \
zlib1g \
libminiupnpc17 \
git \
python3 \
python3-pip \
iputils-ping \
ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
update-ca-certificates
# ==== UTILS ====
WORKDIR /UTILS/
COPY --from=builder_yggdrasil /UTILS/yggdrasil_get_keys /UTILS/yggdrasil_get_keys
COPY --from=builder_yggdrasil /UTILS/yggdrasil_find_public_peers /UTILS/yggdrasil_find_public_peers
RUN python3 -m pip install --break-system-packages -r /UTILS/yggdrasil_get_keys/requirements.txt && \
python3 -m pip install --break-system-packages -r /UTILS/yggdrasil_find_public_peers/requirements.txt && \
python3 -m pip cache purge
# save peers to use in case of unavailable repository
COPY --from=builder_yggdrasil /UTILS/ /UTILS/
# Install Python dependencies securely
RUN python3 -m pip install --no-cache-dir --break-system-packages \
-r /UTILS/yggdrasil_get_keys/requirements.txt \
-r /UTILS/yggdrasil_find_public_peers/requirements.txt
# Cache public peers during build for fallback
RUN python3 /UTILS/yggdrasil_find_public_peers/yggdrasil_find_public_peers.py \
--yggdrasil-conf="" \
--yggdrasil-peers-json="/UTILS/yggdrasil_find_public_peers/public_peers.json"
# ==== I2P ====
# Ports Used by I2P
# Webconsole
--yggdrasil-peers-json="/UTILS/yggdrasil_find_public_peers/public_peers.json" || true
# ==== I2P CONFIGURATION ====
# I2P Service Ports
# Web console
EXPOSE 7070
# HTTP Proxy
# HTTP proxy
EXPOSE 4444
# SOCKS Proxy
# SOCKS proxy
EXPOSE 4447
# SAM Bridge (TCP)
# SAM bridge
EXPOSE 7656
# BOB Bridge
# BOB bridge
EXPOSE 2827
# I2CP
# I2CP
EXPOSE 7654
# I2PControl
# I2PControl
EXPOSE 7650
# Port to listen for connections
# Main listener
EXPOSE 10765
WORKDIR /I2PD/
COPY --from=builder_i2pd /BUILD_I2PD/i2pd/build/i2pd .
COPY --from=builder_i2pd /BUILD_I2PD/i2pd/contrib/certificates ./certificates
COPY ./src/i2pd.conf .
COPY ./i2pd.conf .
# Increase file descriptor limit for better performance
RUN ulimit -n 4096
# ==== YGGDRASIL ====
# Ports used by YGGDRASIL
# Listen
# ==== YGGDRASIL CONFIGURATION ====
# Yggdrasil listener
EXPOSE 10654
# Default yggdrasil port
EXPOSE 9001
WORKDIR /YGGDRASIL/
COPY --from=builder_yggdrasil /BUILD_YGGDRASIL/yggdrasil-go/yggdrasil .
COPY --from=builder_yggdrasil /BUILD_YGGDRASIL/yggdrasil-go/yggdrasilctl .
COPY --from=builder_yggdrasil /BUILD_YGGDRASIL/yggdrasil-go/genkeys .
COPY ./src/yggdrasil.conf .
COPY ./yggdrasil.conf .
# ==== FINAL SETUP ====
WORKDIR /
COPY ./src/entrypoint.sh .
COPY ./entrypoint.sh .
RUN chmod +x /entrypoint.sh
# Health check to ensure services are running
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD bash -c 'pgrep i2pd && pgrep yggdrasil'
CMD ["bash", "/entrypoint.sh"]
+22 -13
View File
@@ -1,7 +1,6 @@
version: "3.3"
version: "3.8"
services:
# I2PD_YGGDRASIL
i2pd_yggdrasil:
image: i2pd_yggdrasil:${APP_VERSION:-latest}
container_name: i2pd_yggdrasil
@@ -11,14 +10,24 @@ services:
devices:
- /dev/net/tun:/dev/net/tun
ports:
- "2827:2827"
- "4444:4444"
- "4447:4447"
- "7070:7070"
- "7650:7650"
- "7654:7654"
- "7656:7656"
- "10765:10765"
- "10654:10654"
- "9001:9001"
restart: always
# I2P Service Ports
- "2827:2827" # BOB Bridge
- "4444:4444" # HTTP Proxy
- "4447:4447" # SOCKS Proxy
- "7070:7070" # Web Console
- "7650:7650" # I2PControl
- "7654:7654" # I2CP
- "7656:7656" # SAM Bridge
- "10765:10765" # Main I2P Listener
# Yggdrasil Ports
- "10654:10654" # Yggdrasil Listener
environment:
- TZ=UTC
restart: unless-stopped
healthcheck:
test: ["CMD", "bash", "-c", "pgrep i2pd && pgrep yggdrasil"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
+47 -6
View File
@@ -1,11 +1,29 @@
#!/bin/bash
# get strong yggdrasil address (https://yggdrasil-network.github.io/configuration.html#generating-stronger-addresses-and-prefixes)
set -e # Exit on any error
echo "Starting I2P over Yggdrasil setup..."
# Function to handle graceful shutdown
cleanup() {
echo "Received shutdown signal, stopping services..."
kill -TERM $i2pd_pid $yggdrasil_pid 2>/dev/null
wait
echo "Services stopped gracefully."
exit 0
}
trap cleanup SIGTERM SIGINT
# Generate strong Yggdrasil address (https://yggdrasil-network.github.io/configuration.html#generating-stronger-addresses-and-prefixes)
echo "Generating Yggdrasil keys..."
python3 /UTILS/yggdrasil_get_keys/yggdrasil_get_keys.py \
--genkeys="/YGGDRASIL/genkeys" \
--yggdrasil-conf="/YGGDRASIL/yggdrasil.conf" \
--timeout=60 \
--environment
# find yggdrasil public peers
# Find and configure public Yggdrasil peers
echo "Discovering Yggdrasil public peers..."
python3 /UTILS/yggdrasil_find_public_peers/yggdrasil_find_public_peers.py \
--yggdrasil-conf="/YGGDRASIL/yggdrasil.conf" \
--yggdrasil-peers-json="/UTILS/yggdrasil_find_public_peers/public_peers.json" \
@@ -14,11 +32,34 @@ python3 /UTILS/yggdrasil_find_public_peers/yggdrasil_find_public_peers.py \
--best=6 \
--max-from-country=2 \
--ping-interval=0.5
# Enable IPv6 (required for Yggdrasil)
echo "Enabling IPv6..."
sysctl net.ipv6.conf.all.disable_ipv6=0 || true
# start YGGDRASIL
# Start Yggdrasil in background
echo "Starting Yggdrasil..."
/YGGDRASIL/yggdrasil -useconffile /YGGDRASIL/yggdrasil.conf &
sleep 1m
# start I2PD
yggdrasil_pid=$!
# Wait for Yggdrasil to establish connections
echo "Waiting for Yggdrasil network connectivity (60 seconds)..."
sleep 60
# Start I2P in background
echo "Starting I2P..."
/I2PD/i2pd --datadir /I2PD --conf /I2PD/i2pd.conf &
i2pd_pid=$!
echo "Both services started successfully!"
echo "I2P Web Console: http://localhost:7070"
echo "Yggdrasil status: check container logs"
# Wait for any process to exit and handle restart if needed
wait -n
exit $?
# If we reach here, one process died
echo "One of the services stopped unexpectedly, shutting down..."
kill -TERM $i2pd_pid $yggdrasil_pid 2>/dev/null
wait
exit 1
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
set -e # Exit on error
# Get version from git tags or use default
TAG_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
echo "Building I2P over Yggdrasil Docker image..."
echo "Version: $TAG_VERSION"
echo "Commit: $COMMIT_HASH"
# Build the Docker image with build args and tags
docker build --file="Dockerfile" \
--build-arg UBUNTU_VERSION=24.04 \
--build-arg I2PD_VERSION=2.58.0 \
--build-arg I2PD_COMPILER=gcc \
--build-arg YGGDRASIL_VERSION=v0.5.12 \
--label "org.label-schema.version=$TAG_VERSION" \
--label "org.label-schema.vcs-ref=$COMMIT_HASH" \
--label "org.label-schema.build-date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--tag i2pd_yggdrasil:${TAG_VERSION} \
--tag i2pd_yggdrasil:latest \
.
echo "Build completed successfully!"
echo "Images: i2pd_yggdrasil:${TAG_VERSION}, i2pd_yggdrasil:latest"
-15
View File
@@ -1,15 +0,0 @@
#!/bin/bash
echo "Deploy i2pd yggdrasil"
host=$(cat secrets/settings.json | jq -r .deploy.host)
user=$(cat secrets/settings.json | jq -r .deploy.user)
path=$(cat secrets/settings.json | jq -r .deploy.path)
echo " stop docker container"
ssh -l ${user} ${host} "cd ${path} ; docker-compose down"
echo " upload docker images"
ssh ${user}@${host} "mkdir -p ${path}"
docker save i2pd_yggdrasil:latest | bzip2 | pv | ssh ${user}@${host} docker load
echo " upload docker compose"
scp src/docker-compose.yml ${user}@${host}:${path}
echo " start docker container"
ssh -l ${user} ${host} "cd ${path} ; docker-compose up -d"
echo " all done"
-10
View File
@@ -1,10 +0,0 @@
#!/bin/bash
TAG_VERSION=$(git describe --tags || echo "unknown")
docker build --file="src/Dockerfile" \
--build-arg UBUNTU_VERSION=24.04 \
--build-arg I2PD_VERSION=2.58.0 \
--build-arg I2PD_COMPILER=gcc \
--build-arg YGGDRASIL_VERSION=v0.5.12 \
--tag i2pd_yggdrasil:${TAG_VERSION} \
--tag i2pd_yggdrasil:latest \
.
-1
View File
@@ -1 +0,0 @@
sudo apt install pv jq