diff --git a/CHANGELOG.md b/CHANGELOG.md index 6004b09d..a9ff3096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 l’UI 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 d’Nginx 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) diff --git a/docker-compose.yml b/docker-compose.yml index 36f083fb..6968a349 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/dockerfiles/sdk_signer.Dockerfile b/dockerfiles/sdk_signer.Dockerfile new file mode 100644 index 00000000..dfbe28af --- /dev/null +++ b/dockerfiles/sdk_signer.Dockerfile @@ -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"] diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 6ac8403d..5523d408 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -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. diff --git a/docs/TESTING.md b/docs/TESTING.md index ba4e1c21..2d0acd76 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -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 l’API 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:/// diff --git a/docs/USAGE.md b/docs/USAGE.md index a70fb69a..24b78229 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -110,6 +110,8 @@ Les accès externes se font via le reverse proxy unique : - UI : `https:///` - API : `https:///api/` - WebSocket : `wss:///ws/` + - Signer WS : `wss:///signer/ws/` + - Storage : `https:///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:///storage/store \ + -d '{"key":"<64 hex>","value":"","ttl":120}' + +# Récupérer une valeur +curl -k https:///storage/retrieve/<64 hex> +``` + +### 4. Surveillance de la Synchronisation ```bash # Surveillance en temps réel diff --git a/tests/connectivity/test_signer_proxy.sh b/tests/connectivity/test_signer_proxy.sh new file mode 100755 index 00000000..33064d49 --- /dev/null +++ b/tests/connectivity/test_signer_proxy.sh @@ -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 diff --git a/tests/run_connectivity_tests.sh b/tests/run_connectivity_tests.sh index 42a569af..b8bc092e 100755 --- a/tests/run_connectivity_tests.sh +++ b/tests/run_connectivity_tests.sh @@ -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"