feat(signer): intégrer sdk_signer (docker-support) via Dockerfile externe; route WSS /signer/ws; tests & docs
Some checks failed
CI - 4NK Node / Code Quality (push) Failing after 1m0s
CI - 4NK Node / Unit Tests (push) Failing after 37s
CI - 4NK Node / Integration Tests (push) Successful in 37s
CI - 4NK Node / Security Tests (push) Failing after 34s
CI - 4NK Node / Docker Build & Test (push) Failing after 16s
CI - 4NK Node / Documentation Tests (push) Successful in 11s
CI - 4NK Node / Performance Tests (push) Successful in 33s
CI - 4NK Node / Notify (push) Failing after 1s

This commit is contained in:
Debian 2025-08-26 10:55:48 +00:00
parent bf07c2de9d
commit 63e1b3acc4
8 changed files with 133 additions and 2 deletions

View File

@ -16,6 +16,8 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Guide de contribution et code de conduite
- Scripts de maintenance et nettoyage automatique
- Reverse proxy central `reverse_proxy` (Nginx) servant `ihm_client` et proxifiant `sdk_relay` (HTTPS/WSS)
- Intégration `sdk_storage` (sous-module, service Docker) et routage `/storage/*` via Nginx (HTTPS)
- Intégration `sdk_signer` (sous-module, service Docker) et routage WSS `/signer/ws/` via Nginx
- Script `scripts/generate_certs.sh` pour certificats auto-signés sécurisés (droits durcis)
- Script `scripts/build_ui_local.sh` pour construire lUI localement (gestion des permissions `dist/`)
- Script `scripts/cleanup_legacy.sh` pour archiver les fichiers devenus obsolètes
@ -34,6 +36,8 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `docker-compose.yml` modernisé (suppression de la clé `version:`) et services internes (ports supprimés)
- Sortie dNginx hors `ihm_client` et centralisation dans `reverse_proxy`
- Documentation mise à jour (Architecture, Configuration, Installation, Usage, Testing)
- `docker-compose.yml` : ajout du service `sdk_storage`, volume `sdk_storage_data`, dépendances proxy
- `docker-compose.yml` : ajout du service `sdk_signer` (runtime ts-node, build wasm intégré), volume `sdk_signer_data`
- `tor/torrc` actualisé (ControlPort local, logs stdout, bridges obfs4 optionnels)
- Activation et test des bridges obfs4 fournis par le Tor Project ; ajout de recommandations de diagnostic (netcat, tests SOCKS, distinction onion public vs pair signet)

View File

@ -258,7 +258,9 @@ services:
# Service interne: aucun port exposé
sdk_signer:
build: ./sdk_signer
build:
context: ./sdk_signer
dockerfile: ../dockerfiles/sdk_signer.Dockerfile
container_name: sdk-signer
restart: unless-stopped
environment:

View File

@ -0,0 +1,32 @@
FROM rust:1 as wasm
WORKDIR /src
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl pkg-config libssl-dev ca-certificates \
clang llvm lld build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSf https://rustwasm.github.io/wasm-pack/installer/init.sh | sh
RUN git clone -b docker-support https://git.4nkweb.com/4nk/sdk_client.git sdk_client
ENV CC=clang \
AR=llvm-ar \
CFLAGS_wasm32_unknown_unknown="--target=wasm32-unknown-unknown" \
TARGET_CC=clang
RUN wasm-pack build --out-dir /out/pkg ./sdk_client --target nodejs --release
FROM node:20-alpine AS deps
ENV NODE_ENV=development
WORKDIR /app
RUN apk add --no-cache python3 make g++
COPY package.json package-lock.json* ./
RUN npm ci
FROM node:20-alpine AS runner
ENV NODE_ENV=production
WORKDIR /app
RUN addgroup -S nodejs && adduser -S nodejs -G nodejs
COPY --from=deps /app/node_modules ./node_modules
COPY --from=wasm /out/pkg ./pkg
COPY tsconfig.json ./
COPY src ./src
EXPOSE 9090
USER nodejs
CMD ["node", "-r", "ts-node/register/transpile-only", "src/index.ts"]

View File

@ -45,6 +45,8 @@ Un reverse proxy dédié assure désormais l'exposition publique unique de l'inf
- `/` → UI statique
- `/api/``sdk_relay_1` (HTTP)
- `/ws/``sdk_relay_1` (WebSocket, upgrade)
- `/storage/``sdk_storage` (HTTP 8081 via proxy)
- `/signer/ws/``sdk_signer` (WebSocket 9090 via proxy)
- Tous les autres services restent strictement internes au réseau Docker `btcnet`
## Composants Principaux
@ -84,6 +86,25 @@ Un reverse proxy dédié assure désormais l'exposition publique unique de l'inf
- Gestion des clés et signatures
### 3. Service SDK Relay
### 4. Service SDK Storage
### 5. Service SDK Signer
**Rôle :** Serveur WebSocket de signature/gestion de processus, connecté aux relais SDK.
**Caractéristiques :**
- Port interne : 9090 (WebSocket)
- Dépendances : `sdk_relay_1` (URL relay `ws://sdk_relay_1:8090`)
- Publication : via reverse proxy en `/signer/ws/`
- Persistance : volume `sdk_signer_data` pour la base locale
**Rôle :** Stockage clé/valeur TTL simple pour échanges temporisés.
**Caractéristiques :**
- Port interne : 8081
- Endpoints : `/store` (POST), `/retrieve/:key` (GET)
- Persistance : volume `sdk_storage_data` mappé sur `/app/storage`
- Publication : uniquement via reverse proxy en `/storage/*`
**Rôle :** Relais pour les interactions SDK avec synchronisation mesh.

View File

@ -106,6 +106,7 @@ Options disponibles :
- `test_connectivity.sh` : Test de connectivité des services
- `test_websocket_messages.py` : Test des messages WebSocket
- `test_storage_proxy.sh` : Test de lAPI sdk_storage via le reverse proxy (`/storage/*`)
- `test_signer_proxy.sh` : Test de la connectivité sdk_signer (port 9090 + WSS via `/signer/ws/`)
- Tests externes reverse proxy :
```bash
curl -kI https://<IP_VM>/

View File

@ -110,6 +110,8 @@ Les accès externes se font via le reverse proxy unique :
- UI : `https://<IP_VM>/`
- API : `https://<IP_VM>/api/`
- WebSocket : `wss://<IP_VM>/ws/`
- Signer WS : `wss://<IP_VM>/signer/ws/`
- Storage : `https://<IP_VM>/storage/`
### 2. Test de Connectivité des Relais
@ -127,7 +129,19 @@ python3 test_websocket_messages.py
python3 test_websocket_messages.py --load-test
```
### 3. Surveillance de la Synchronisation
### 3. Utilisation de sdk_storage
```bash
# Stocker une valeur (exemple)
curl -k -H 'Content-Type: application/json' \
-X POST https://<IP_VM>/storage/store \
-d '{"key":"<64 hex>","value":"<hex>","ttl":120}'
# Récupérer une valeur
curl -k https://<IP_VM>/storage/retrieve/<64 hex>
```
### 4. Surveillance de la Synchronisation
```bash
# Surveillance en temps réel

View File

@ -0,0 +1,28 @@
#!/bin/sh
# Test de connectivité sdk_signer: port interne et route WSS du reverse proxy
set -eu
HOST="${HOST:-localhost}"
LOG_DIR="$(cd "$(dirname "$0")"/.. && pwd)/logs"
TS="$(date +%Y-%m-%d_%H-%M-%S)"
LOG_FILE="$LOG_DIR/signer_proxy_${TS}.log"
mkdir -p "$LOG_DIR"
log() { printf "%s %s\n" "[$(date +%H:%M:%S)]" "$*" | tee -a "$LOG_FILE"; }
log "Vérification du port interne 9090 (tcp)"
if sudo docker run --rm --network 4nk_node_btcnet alpine:3.19 sh -lc "apk add --no-cache netcat-openbsd >/dev/null; nc -z sdk_signer 9090"; then
log "OK: sdk_signer écoute en 9090"
else
log "ECHEC: sdk_signer n'écoute pas en 9090"; exit 1
fi
log "Test Upgrade HTTP->WS via le reverse proxy (/signer/ws)"
code=$(curl -skI --http1.1 -H "Connection: Upgrade" -H "Upgrade: websocket" https://$HOST/signer/ws/ | awk 'NR==1{print $2}') || true
log "Statut proxy: ${code:-inconnu} (attendu: 101/400/426; éviter 502)"
if [ "${code:-}" = "502" ] || [ -z "${code:-}" ]; then
log "ECHEC: reverse proxy retourne 502"; exit 1
fi
log "Succès: connectivité sdk_signer OK"
exit 0

View File

@ -206,6 +206,35 @@ run_connectivity_tests() {
log "WARNING" "Test test_storage_proxy.sh non trouvé"
fi
# Test signer via reverse proxy
if [ -f "test_signer_proxy.sh" ]; then
total_tests=$((total_tests + 1))
log "INFO" "Exécution de test_signer_proxy.sh"
if [ "$VERBOSE" = true ]; then
if HOST=localhost ./test_signer_proxy.sh 2>&1 | tee -a "$LOG_FILE"; then
connectivity_results+=("test_signer_proxy.sh:SUCCESS")
successful_tests=$((successful_tests + 1))
log "SUCCESS" "test_signer_proxy.sh terminé avec succès"
else
connectivity_results+=("test_signer_proxy.sh:FAILED")
failed_tests=$((failed_tests + 1))
log "ERROR" "test_signer_proxy.sh a échoué"
fi
else
if HOST=localhost ./test_signer_proxy.sh >> "$LOG_FILE" 2>&1; then
connectivity_results+=("test_signer_proxy.sh:SUCCESS")
successful_tests=$((successful_tests + 1))
log "SUCCESS" "test_signer_proxy.sh terminé avec succès"
else
connectivity_results+=("test_signer_proxy.sh:FAILED")
failed_tests=$((failed_tests + 1))
log "ERROR" "test_signer_proxy.sh a échoué"
fi
fi
else
log "WARNING" "Test test_signer_proxy.sh non trouvé"
fi
# Afficher le résumé des tests de connectivité
log "INFO" "=== Résumé des tests de connectivité ==="
log "INFO" "Total: $total_tests, Succès: $successful_tests, Échecs: $failed_tests"