From 85e7b9937e31918f9bdabd5e84ef4c9b24b9e2ea Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 1 Nov 2026 16:30:42 +0200 Subject: [PATCH] After configuring the domain name3 --- prediqo_mobile/README.md | 7 +- prediqo_mobile/dart_defines.dev.example.json | 2 +- prediqo_mobile/dart_defines.prod.example.json | 2 +- .../lib/core/config/app_config.dart | 2 +- scripts/check-ssl-expiry.sh | 108 ++++++++++++++++++ 5 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 scripts/check-ssl-expiry.sh diff --git a/prediqo_mobile/README.md b/prediqo_mobile/README.md index f94abf90..715fc542 100644 --- a/prediqo_mobile/README.md +++ b/prediqo_mobile/README.md @@ -6,13 +6,13 @@ | Build | Default without dart-define | |-------|-----------------------------| -| **Release** (`flutter build apk --release`) | `http://prediqo.redirectme.net:9080` | +| **Release** (`flutter build apk --release`) | `https://tloto.net` | | **Debug / emulator** | `http://10.0.2.2:9080` | ### Local device / custom host 1. Copy `dart_defines.dev.example.json` → `dart_defines.dev.json` -2. Set your API base, e.g. `http://prediqo.redirectme.net:9080` or `http://:9080` +2. Set your API base, e.g. `https://tloto.net` or `http://:9080` ```bash flutter run --dart-define-from-file=dart_defines.dev.json @@ -21,10 +21,9 @@ flutter run --dart-define-from-file=dart_defines.dev.json ### Release APK (production) ```bash -# Uses built-in production default, or pin explicitly: flutter build apk --release --dart-define-from-file=dart_defines.prod.example.json ``` Output: `build/app/outputs/flutter-apk/app-release.apk` -An older APK built with only the emulator default (`10.0.2.2`) **cannot** reach the VPS — rebuild and reinstall. +Older APKs built with `redirectme`, `:9443`, or `10.0.2.2` must be rebuilt for `https://tloto.net`. diff --git a/prediqo_mobile/dart_defines.dev.example.json b/prediqo_mobile/dart_defines.dev.example.json index 8266bcb7..9ace1e5c 100644 --- a/prediqo_mobile/dart_defines.dev.example.json +++ b/prediqo_mobile/dart_defines.dev.example.json @@ -1,3 +1,3 @@ { - "API_BASE_URL": "http://YOUR_PC_WIFI_IP:9080" + "API_BASE_URL": "https://tloto.net" } diff --git a/prediqo_mobile/dart_defines.prod.example.json b/prediqo_mobile/dart_defines.prod.example.json index 0956c1db..893cdf54 100644 --- a/prediqo_mobile/dart_defines.prod.example.json +++ b/prediqo_mobile/dart_defines.prod.example.json @@ -1,5 +1,5 @@ { - "API_BASE_URL": "https://tloto.net:9443", + "API_BASE_URL": "https://tloto.net", "APP_ENV": "production", "WS_ENABLED": "true" } diff --git a/prediqo_mobile/lib/core/config/app_config.dart b/prediqo_mobile/lib/core/config/app_config.dart index e1ec70d9..c1b4cc9f 100644 --- a/prediqo_mobile/lib/core/config/app_config.dart +++ b/prediqo_mobile/lib/core/config/app_config.dart @@ -74,7 +74,7 @@ class AppConfig { } /// Production API reached by release APKs on real devices (override with dart-define). - static const String defaultProductionApiBaseUrl = 'https://tloto.net:9443'; + static const String defaultProductionApiBaseUrl = 'https://tloto.net'; /// Emulator-only loopback to the host machine's Docker nginx. static const String defaultEmulatorApiBaseUrl = 'http://10.0.2.2:9080'; diff --git a/scripts/check-ssl-expiry.sh b/scripts/check-ssl-expiry.sh new file mode 100644 index 00000000..ff91a6a1 --- /dev/null +++ b/scripts/check-ssl-expiry.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +# Vérifie l'expiration des certificats Let's Encrypt et alerte si proche. +# +# Usage (VPS) : +# export NTFY_TOPIC=tloto-certs-CHOISIS-UN-SECRET # app ntfy (téléphone) +# export ALERT_EMAIL=admin@tloto.net # optionnel si `mail` est dispo +# export WARN_DAYS=30 +# ./scripts/check-ssl-expiry.sh +# +# Crontab (tous les jours à 09:00) : +# 0 9 * * * WARN_DAYS=30 NTFY_TOPIC=tloto-certs-XXX \ +# /home/projects/projects_repository/games-project/scripts/check-ssl-expiry.sh \ +# >> /var/log/tloto-cert-check.log 2>&1 +# +set -euo pipefail + +WARN_DAYS="${WARN_DAYS:-30}" +CRITICAL_DAYS="${CRITICAL_DAYS:-7}" +NTFY_TOPIC="${NTFY_TOPIC:-}" +ALERT_EMAIL="${ALERT_EMAIL:-}" + +# volume:chemin_pem relatif sous /etc/letsencrypt/live/... +CHECKS=( + "games-project_letsencrypt:tloto.net/fullchain.pem" + "salon-management-full-project_letsencrypt:business-mgt.redirectme.net/fullchain.pem" +) + +need_alert=0 +report="" + +days_left_for() { + local volume="$1" + local rel="$2" + docker run --rm -v "${volume}:/etc/letsencrypt:ro" alpine:3.20 \ + sh -c " + apk add --no-cache openssl >/dev/null 2>&1 + pem=/etc/letsencrypt/live/${rel} + if [ ! -f \"\$pem\" ]; then echo MISSING; exit 0; fi + end=\$(openssl x509 -in \"\$pem\" -noout -enddate | cut -d= -f2) + end_ts=\$(date -d \"\$end\" +%s) + now=\$(date +%s) + echo \$(( (end_ts - now) / 86400 )) + " +} + +send_alert() { + local subject="$1" + local body="$2" + echo "ALERT: $subject" + echo "$body" + + if [ -n "$NTFY_TOPIC" ]; then + curl -fsS -H "Title: $subject" -H "Priority: high" \ + -d "$body" "https://ntfy.sh/${NTFY_TOPIC}" >/dev/null || true + fi + + if [ -n "$ALERT_EMAIL" ] && command -v mail >/dev/null 2>&1; then + printf '%s\n' "$body" | mail -s "$subject" "$ALERT_EMAIL" || true + fi +} + +for item in "${CHECKS[@]}"; do + vol="${item%%:*}" + rel="${item#*:}" + name="${rel%%/*}" + + if ! docker volume inspect "$vol" >/dev/null 2>&1; then + line="SKIP $name — volume $vol introuvable" + report+="$line"$'\n' + echo "$line" + continue + fi + + left="$(days_left_for "$vol" "$rel" | tr -d '\r' | tail -n1)" + if [ "$left" = "MISSING" ] || ! [[ "$left" =~ ^-?[0-9]+$ ]]; then + line="ERROR $name — certificat illisible ($left)" + report+="$line"$'\n' + echo "$line" + need_alert=1 + continue + fi + + line="$name : ${left} jour(s) restant(s)" + report+="$line"$'\n' + echo "$line" + + if [ "$left" -lt "$CRITICAL_DAYS" ]; then + need_alert=1 + elif [ "$left" -lt "$WARN_DAYS" ]; then + need_alert=1 + fi +done + +if [ "$need_alert" -eq 1 ]; then + send_alert "Tloto/Salon — certificat SSL à renouveler" \ + "Au moins un certificat expire bientôt (< ${WARN_DAYS} jours). + +${report} +Action VPS Tloto : + cd ~/projects_repository/games-project && npm run ssl:dns-renew +(Puis TXT GoDaddy, Entrée seulement quand Dig/8.8.8.8 est OK.) + +Date check : $(date -u +%Y-%m-%dT%H:%M:%SZ)" + exit 2 +fi + +echo "OK — aucun certificat sous le seuil ${WARN_DAYS} jours." +exit 0