Accès tablette : vérification du pare-feu sous Linux (ufw, firewalld)
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 43s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 48s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 51s

- Choix de l'accès au pare-feu selon le système (HostNetworkAccessConfig) :
  Windows (PowerShell, UAC), Linux, sinon pas de diagnostic.
- Linux, sans droits root : ufw détecté via /etc/ufw/ufw.conf, firewalld via
  systemctl ; firewalld dit si le port est ouvert (firewall-cmd
  --query-port). Règles ufw illisibles sans root : port « inconnu », jamais
  de faux « prêt ».
- Vérification du réseau : état du pare-feu Linux et commande exacte à lancer
  sur la machine (sudo ufw allow <port>/tcp, ou firewall-cmd), avec bouton
  « Copier ». Pas d'autorisation en un clic (serveur sans écran).
- Le diagnostic reçoit le port réglé de l'accès distant.

Vérifié : core clean verify (1228 tests, dont lecture de ufw.conf,
interprétation de firewall-cmd et verdicts Linux), web build + 342 vitest,
lint sans erreur.
À redéployer : core + web (mode bureau ; aucune migration).
This commit is contained in:
2026-10-17 15:41:50 +02:00
parent 2e9632de49
commit d9a90f8412
19 changed files with 412 additions and 21 deletions
@@ -39,7 +39,32 @@
@if (network?.supported) {
<div class="remote-block network-check" [class.ok]="allClear">
<h3>{{ 'remoteAccess.network.title' | translate }}</h3>
@if (network!.ready) {
@if (isLinux) {
<!-- Linux : état du pare-feu lisible sans root, sinon commande à lancer sur la machine. -->
@if (network!.ready) {
<p class="check-ok">
<lucide-icon [img]="CheckCircle2" [size]="16"></lucide-icon>
{{ (network!.linuxFirewall === 'none' ? 'remoteAccess.network.linuxNone' : 'remoteAccess.network.linuxOpen')
| translate: { fw: network!.linuxFirewall, port: s.port } }}
</p>
} @else {
<div class="check-item">
<p class="check-problem">
{{ (network!.portOpen === false ? 'remoteAccess.network.linuxClosed' : 'remoteAccess.network.linuxUnknown')
| translate: { fw: network!.linuxFirewall, port: s.port } }}
</p>
@if (network!.fixCommand) {
<div class="command-row">
<code class="command">{{ network!.fixCommand }}</code>
<button type="button" class="btn-secondary" (click)="copyFixCommand()">
<lucide-icon [img]="Copy" [size]="14"></lucide-icon>
{{ (copied ? 'remoteAccess.network.copied' : 'remoteAccess.network.copy') | translate }}
</button>
</div>
}
</div>
}
} @else if (network!.ready) {
<p class="check-ok">
<lucide-icon [img]="CheckCircle2" [size]="16"></lucide-icon>
{{ (thirdPartyFirewalls.length > 0 ? 'remoteAccess.network.windowsReady' : 'remoteAccess.network.ready') | translate }}
@@ -231,3 +231,25 @@
&:disabled { opacity: 0.6; cursor: wait; }
&:focus-visible { outline: 2px solid #6c63ff; border-radius: 4px; }
}
// Linux : commande d'ouverture du port, sélectionnable et copiable.
.command-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
max-width: 100%;
}
.command {
flex: 1 1 260px;
min-width: 0;
padding: 0.55rem 0.75rem;
border-radius: 6px;
background: #0b0b16;
border: 1px solid #2a2a45;
color: #c7d2fe;
font-size: 0.85rem;
overflow-wrap: anywhere;
user-select: all;
}
@@ -3,7 +3,7 @@ import { FormsModule } from '@angular/forms';
import { HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute } from '@angular/router';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { LucideAngularModule, Tablet, Trash2, RefreshCw, AlertCircle, ShieldCheck, CheckCircle2, Settings2 } from 'lucide-angular';
import { LucideAngularModule, Tablet, Trash2, RefreshCw, AlertCircle, ShieldCheck, CheckCircle2, Settings2, Copy } from 'lucide-angular';
import QRCode from 'qrcode';
import {
@@ -30,6 +30,8 @@ export class RemoteAccessSectionComponent implements OnInit, OnDestroy {
readonly ShieldCheck = ShieldCheck;
readonly CheckCircle2 = CheckCircle2;
readonly Settings2 = Settings2;
readonly Copy = Copy;
copied = false;
private readonly remoteAccess = inject(RemoteAccessService);
private readonly translate = inject(TranslateService);
@@ -197,8 +199,25 @@ export class RemoteAccessSectionComponent implements OnInit, OnDestroy {
return this.network?.thirdPartyFirewalls ?? [];
}
get isLinux(): boolean {
return this.network?.platform === 'linux';
}
get firewallNeedsFix(): boolean {
return !!this.network && (!this.network.firewallAllowed || this.network.firewallBlocked);
return !!this.network && !this.isLinux && (!this.network.firewallAllowed || this.network.firewallBlocked);
}
/** Linux : copie la commande d'ouverture du port (à lancer sur le serveur). */
async copyFixCommand(): Promise<void> {
const command = this.network?.fixCommand;
if (!command) return;
try {
await navigator.clipboard.writeText(command);
this.copied = true;
setTimeout(() => this.copied = false, 2000);
} catch {
this.copied = false; // presse-papiers indisponible : la commande reste lisible et sélectionnable
}
}
/** Le QR code ouvre directement l'écran d'appairage avec le code pré-rempli. */