diff --git a/core/src/main/java/com/loremind/application/remoteaccess/NetworkReadiness.java b/core/src/main/java/com/loremind/application/remoteaccess/NetworkReadiness.java index cfcb72b..a93e722 100644 --- a/core/src/main/java/com/loremind/application/remoteaccess/NetworkReadiness.java +++ b/core/src/main/java/com/loremind/application/remoteaccess/NetworkReadiness.java @@ -15,6 +15,8 @@ import java.util.Locale; * @param publicNetworks réseaux connectés classés « Public » que le pare-feu ne laisse pas passer * @param firewallAllowed une règle active autorise l'application sur les réseaux privés * @param firewallBlocked une règle active BLOQUE l'application (ex. « Annuler » dans la fenêtre Windows) + * @param thirdPartyFirewalls pare-feu tiers présents : leurs réglages ne sont pas lisibles, donc {@code ready} + * ne peut pas être garanti — le front avertit l'utilisateur de les régler lui-même * @param program exécutable concerné */ public record NetworkReadiness( @@ -23,6 +25,7 @@ public record NetworkReadiness( List publicNetworks, boolean firewallAllowed, boolean firewallBlocked, + List thirdPartyFirewalls, String program ) { @@ -31,7 +34,7 @@ public record NetworkReadiness( public static NetworkReadiness evaluate(NetworkSnapshot snapshot) { if (snapshot == null || !snapshot.supported()) { - return new NetworkReadiness(false, false, List.of(), false, false, null); + return new NetworkReadiness(false, false, List.of(), false, false, List.of(), null); } List rules = snapshot.rules() == null ? List.of() : snapshot.rules(); boolean allowedPrivate = covers(rules, "Allow", PRIVATE); @@ -46,8 +49,11 @@ public record NetworkReadiness( // Un réseau public n'est un obstacle que si le pare-feu ne l'ouvre pas explicitement. List blockingPublic = publicOpen ? List.of() : publicNetworks; + // « ready » ne porte que sur ce qui est lisible (Windows) ; un pare-feu tiers est signalé à part. boolean ready = allowedPrivate && !blockedPrivate && blockingPublic.isEmpty(); - return new NetworkReadiness(true, ready, blockingPublic, allowedPrivate, blockedPrivate, snapshot.program()); + List thirdParty = snapshot.thirdPartyFirewalls() == null ? List.of() : snapshot.thirdPartyFirewalls(); + return new NetworkReadiness(true, ready, blockingPublic, allowedPrivate, blockedPrivate, thirdParty, + snapshot.program()); } /** Une règle ACTIVE de cette action couvre-t-elle ce profil (« Any » couvre tout) ? */ diff --git a/core/src/main/java/com/loremind/domain/remoteaccess/NetworkSnapshot.java b/core/src/main/java/com/loremind/domain/remoteaccess/NetworkSnapshot.java index e22e801..857dfc7 100644 --- a/core/src/main/java/com/loremind/domain/remoteaccess/NetworkSnapshot.java +++ b/core/src/main/java/com/loremind/domain/remoteaccess/NetworkSnapshot.java @@ -11,8 +11,11 @@ import java.util.List; * @param program exécutable visé par les règles (DM Loremind.exe en bureau) * @param networks réseaux connectés * @param rules règles entrantes du pare-feu pour ce programme + * @param thirdPartyFirewalls pare-feu tiers déclarés à Windows (Bitdefender, Norton…) : ils filtrent + * EN PLUS du pare-feu Windows, avec leurs propres règles, illisibles d'ici */ -public record NetworkSnapshot(boolean supported, String program, List networks, List rules) { +public record NetworkSnapshot(boolean supported, String program, List networks, List rules, + List thirdPartyFirewalls) { /** Catégorie Windows : {@code Public}, {@code Private} ou {@code DomainAuthenticated}. */ public record Network(String name, String alias, String category) {} @@ -25,6 +28,6 @@ public record NetworkSnapshot(boolean supported, String program, List n public record FirewallRule(String action, String profile, String enabled) {} public static NetworkSnapshot unsupported() { - return new NetworkSnapshot(false, null, List.of(), List.of()); + return new NetworkSnapshot(false, null, List.of(), List.of(), List.of()); } } diff --git a/core/src/main/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccess.java b/core/src/main/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccess.java index 29ed650..69deef8 100644 --- a/core/src/main/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccess.java +++ b/core/src/main/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccess.java @@ -117,7 +117,12 @@ public class WindowsHostNetworkAccess implements HostNetworkAccess { + "([Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p) } | Get-NetFirewallRule | " + "Where-Object { $_.Direction.ToString() -eq 'Inbound' } | ForEach-Object { [pscustomobject]@{ " + "action = $_.Action.ToString(); profile = $_.Profile.ToString(); enabled = $_.Enabled.ToString() } })\n" - + "[pscustomobject]@{ networks = $nets; rules = $rules } | ConvertTo-Json -Depth 4 -Compress\n"; + // Pare-feu TIERS déclarés au Centre de sécurité (le pare-feu Windows n'y figure pas) : + // ils filtrent en plus de Windows, avec des règles qu'on ne peut pas lire. + + "$fw = @(Get-CimInstance -Namespace root/SecurityCenter2 -ClassName FirewallProduct | " + + "ForEach-Object { $_.displayName } | Where-Object { $_ -and $_ -notmatch 'Windows' })\n" + + "[pscustomobject]@{ networks = $nets; rules = $rules; thirdPartyFirewalls = $fw } | " + + "ConvertTo-Json -Depth 4 -Compress\n"; } /** @@ -150,7 +155,11 @@ public class WindowsHostNetworkAccess implements HostNetworkAccess { for (JsonNode r : array(root.path("rules"))) { rules.add(new NetworkSnapshot.FirewallRule(text(r, "action"), text(r, "profile"), text(r, "enabled"))); } - return new NetworkSnapshot(true, program, networks, rules); + List thirdParty = new ArrayList<>(); + for (JsonNode f : array(root.path("thirdPartyFirewalls"))) { + if (f.isTextual() && !f.asText().isBlank()) thirdParty.add(f.asText()); + } + return new NetworkSnapshot(true, program, networks, rules, thirdParty); } /** ConvertTo-Json écrit un objet seul (pas un tableau) quand la liste n'a qu'un élément. */ diff --git a/core/src/test/java/com/loremind/application/remoteaccess/NetworkReadinessTest.java b/core/src/test/java/com/loremind/application/remoteaccess/NetworkReadinessTest.java index 80ca2a5..b571b06 100644 --- a/core/src/test/java/com/loremind/application/remoteaccess/NetworkReadinessTest.java +++ b/core/src/test/java/com/loremind/application/remoteaccess/NetworkReadinessTest.java @@ -17,7 +17,7 @@ class NetworkReadinessTest { private static final FirewallRule ALLOW_PRIVATE = new FirewallRule("Allow", "Private", "True"); private static NetworkReadiness eval(List networks, List rules) { - return NetworkReadiness.evaluate(new NetworkSnapshot(true, "C:\\DM Loremind.exe", networks, rules)); + return NetworkReadiness.evaluate(new NetworkSnapshot(true, "C:\\DM Loremind.exe", networks, rules, List.of())); } @Test @@ -71,6 +71,15 @@ class NetworkReadinessTest { assertTrue(eval(List.of(HOME_PRIVATE), List.of(new FirewallRule("Allow", "Any", "True"))).ready()); } + @Test + void thirdPartyFirewall_isReported_withoutPretendingToKnowItsRules() { + // Cas réel du 2026-10-17 : Windows prêt, mais Bitdefender filtre en plus avec ses propres règles. + NetworkReadiness r = NetworkReadiness.evaluate(new NetworkSnapshot(true, "C:\\DM Loremind.exe", + List.of(HOME_PRIVATE), List.of(ALLOW_PRIVATE), List.of("Bitdefender Pare-feu"))); + assertTrue(r.ready(), "Windows est prêt…"); + assertEquals(List.of("Bitdefender Pare-feu"), r.thirdPartyFirewalls(), "…mais le pare-feu tiers est signalé"); + } + @Test void publicNetwork_withoutName_usesInterfaceAlias() { NetworkReadiness r = eval(List.of(new Network(null, "Wi-Fi", "Public")), List.of(ALLOW_PRIVATE)); diff --git a/core/src/test/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccessTest.java b/core/src/test/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccessTest.java index 67f9bcc..f5199eb 100644 --- a/core/src/test/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccessTest.java +++ b/core/src/test/java/com/loremind/infrastructure/desktop/WindowsHostNetworkAccessTest.java @@ -33,6 +33,18 @@ class WindowsHostNetworkAccessTest { assertEquals("Private", s.networks().get(0).category()); assertEquals(2, s.rules().size()); assertEquals("Block", s.rules().get(1).action()); + assertTrue(s.thirdPartyFirewalls().isEmpty()); + } + + @Test + void parse_readsThirdPartyFirewalls_asSingleValueOrArray() throws Exception { + NetworkSnapshot one = WindowsHostNetworkAccess.parseSnapshot(mapper, "C:\\app.exe", + "{\"networks\":[],\"rules\":[],\"thirdPartyFirewalls\":\"Bitdefender Pare-feu\"}"); + assertEquals(java.util.List.of("Bitdefender Pare-feu"), one.thirdPartyFirewalls()); + + NetworkSnapshot two = WindowsHostNetworkAccess.parseSnapshot(mapper, "C:\\app.exe", + "{\"networks\":[],\"rules\":[],\"thirdPartyFirewalls\":[\"Norton\",\"\"]}"); + assertEquals(java.util.List.of("Norton"), two.thirdPartyFirewalls()); } @Test @@ -55,6 +67,7 @@ class WindowsHostNetworkAccessTest { assertFalse(allow.contains("Public"), "la règle ne doit jamais ouvrir les réseaux publics"); assertTrue(allow.contains("Remove-NetFirewallRule"), "les blocages de CE programme sont retirés"); assertTrue(WindowsHostNetworkAccess.inspectScript(path).contains("ConvertTo-Json")); + assertTrue(WindowsHostNetworkAccess.inspectScript(path).contains("SecurityCenter2")); } @Test @@ -69,5 +82,6 @@ class WindowsHostNetworkAccessTest { NetworkSnapshot s = new WindowsHostNetworkAccess(mapper).inspect(); assertTrue(s.supported(), "PowerShell doit répondre en lecture seule sur Windows"); assertNotNull(s.program()); + assertNotNull(s.thirdPartyFirewalls()); } } diff --git a/web/src/app/services/remote-access.service.ts b/web/src/app/services/remote-access.service.ts index b29e4f7..c030213 100644 --- a/web/src/app/services/remote-access.service.ts +++ b/web/src/app/services/remote-access.service.ts @@ -38,6 +38,8 @@ export interface NetworkReadiness { publicNetworks: string[]; firewallAllowed: boolean; firewallBlocked: boolean; + /** Pare-feu tiers (Bitdefender…) : ils filtrent en plus de Windows, réglages illisibles d'ici. */ + thirdPartyFirewalls: string[]; program?: string | null; } diff --git a/web/src/app/settings/remote-access-section/remote-access-section.component.html b/web/src/app/settings/remote-access-section/remote-access-section.component.html index 925fe75..5a23d7f 100644 --- a/web/src/app/settings/remote-access-section/remote-access-section.component.html +++ b/web/src/app/settings/remote-access-section/remote-access-section.component.html @@ -37,12 +37,12 @@ @if (network?.supported) { -
+

{{ 'remoteAccess.network.title' | translate }}

@if (network!.ready) {

- {{ 'remoteAccess.network.ready' | translate }} + {{ (thirdPartyFirewalls.length > 0 ? 'remoteAccess.network.windowsReady' : 'remoteAccess.network.ready') | translate }}

} @else { @if (network!.publicNetworks.length > 0) { @@ -68,6 +68,15 @@
} } + @if (thirdPartyFirewalls.length > 0) { +
+

{{ 'remoteAccess.network.thirdParty' | translate: { names: thirdPartyFirewalls.join(', ') } }}

+

{{ 'remoteAccess.network.thirdPartyHowTo' | translate }}

+ + {{ 'remoteAccess.network.docLink' | translate }} + +
+ } @if (fixMessage) {

{{ fixMessage }}

} diff --git a/web/src/app/settings/remote-access-section/remote-access-section.component.ts b/web/src/app/settings/remote-access-section/remote-access-section.component.ts index eb80001..7c50b6c 100644 --- a/web/src/app/settings/remote-access-section/remote-access-section.component.ts +++ b/web/src/app/settings/remote-access-section/remote-access-section.component.ts @@ -188,6 +188,15 @@ export class RemoteAccessSectionComponent implements OnInit, OnDestroy { this.remoteAccess.openNetworkSettings().subscribe({ error: () => undefined }); } + /** Vert seulement si rien ne bloque côté Windows ET qu'aucun pare-feu tiers n'échappe à la vérification. */ + get allClear(): boolean { + return !!this.network && this.network.ready && this.thirdPartyFirewalls.length === 0; + } + + get thirdPartyFirewalls(): string[] { + return this.network?.thirdPartyFirewalls ?? []; + } + get firewallNeedsFix(): boolean { return !!this.network && (!this.network.firewallAllowed || this.network.firewallBlocked); } diff --git a/web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json index f30373d..3bb4d8c 100644 --- a/web/src/assets/i18n/en.json +++ b/web/src/assets/i18n/en.json @@ -2453,7 +2453,12 @@ "CANCELLED": "Confirmation cancelled: nothing was changed.", "FAILED": "The permission failed. You can try again, or add it manually (see the documentation).", "UNSUPPORTED": "This check is only available on Windows." - } + }, + "windowsReady": "The Windows firewall and the network type let the tablet through.", + "thirdParty": "{{names}} also filters connections on this PC, with its own rules that DM Loremind can't check. Until it allows it, the tablet will load forever.", + "thirdPartyHowTo": "In that software's firewall settings: classify your Wi-Fi as a home network (not public, stealth mode off), then add a rule allowing incoming connections for DM Loremind.", + "docLink": "See how to fix it", + "docUrl": "https://loremind-docs.igmlcreation.fr/en/docs/configuration/acces-tablette#the-tablet-loads-forever" } }, "mobileShell": { diff --git a/web/src/assets/i18n/fr.json b/web/src/assets/i18n/fr.json index 6487428..639f80b 100644 --- a/web/src/assets/i18n/fr.json +++ b/web/src/assets/i18n/fr.json @@ -2453,7 +2453,12 @@ "CANCELLED": "Confirmation annulée : rien n'a été modifié.", "FAILED": "L'autorisation a échoué. Tu peux réessayer, ou l'ajouter à la main (voir la documentation).", "UNSUPPORTED": "Cette vérification n'est disponible que sur Windows." - } + }, + "windowsReady": "Le pare-feu Windows et le type de réseau laissent passer la tablette.", + "thirdParty": "{{names}} filtre aussi les connexions sur ce PC, avec ses propres règles que DM Loremind ne peut pas vérifier. Tant qu'il ne l'autorise pas, la tablette chargera sans fin.", + "thirdPartyHowTo": "Dans les réglages du pare-feu de ce logiciel : classe ton Wi-Fi en réseau domestique (pas public, sans mode furtif), puis ajoute une règle qui autorise DM Loremind en connexions entrantes.", + "docLink": "Voir la marche à suivre", + "docUrl": "https://loremind-docs.igmlcreation.fr/docs/configuration/acces-tablette#la-tablette-charge-sans-fin" } }, "mobileShell": { diff --git a/web/src/assets/i18n/fragments/remote-access.en.json b/web/src/assets/i18n/fragments/remote-access.en.json index 484cb12..a3b1a93 100644 --- a/web/src/assets/i18n/fragments/remote-access.en.json +++ b/web/src/assets/i18n/fragments/remote-access.en.json @@ -64,7 +64,12 @@ "CANCELLED": "Confirmation cancelled: nothing was changed.", "FAILED": "The permission failed. You can try again, or add it manually (see the documentation).", "UNSUPPORTED": "This check is only available on Windows." - } + }, + "windowsReady": "The Windows firewall and the network type let the tablet through.", + "thirdParty": "{{names}} also filters connections on this PC, with its own rules that DM Loremind can't check. Until it allows it, the tablet will load forever.", + "thirdPartyHowTo": "In that software's firewall settings: classify your Wi-Fi as a home network (not public, stealth mode off), then add a rule allowing incoming connections for DM Loremind.", + "docLink": "See how to fix it", + "docUrl": "https://loremind-docs.igmlcreation.fr/en/docs/configuration/acces-tablette#the-tablet-loads-forever" } } } diff --git a/web/src/assets/i18n/fragments/remote-access.fr.json b/web/src/assets/i18n/fragments/remote-access.fr.json index 39ad606..b0876ad 100644 --- a/web/src/assets/i18n/fragments/remote-access.fr.json +++ b/web/src/assets/i18n/fragments/remote-access.fr.json @@ -64,7 +64,12 @@ "CANCELLED": "Confirmation annulée : rien n'a été modifié.", "FAILED": "L'autorisation a échoué. Tu peux réessayer, ou l'ajouter à la main (voir la documentation).", "UNSUPPORTED": "Cette vérification n'est disponible que sur Windows." - } + }, + "windowsReady": "Le pare-feu Windows et le type de réseau laissent passer la tablette.", + "thirdParty": "{{names}} filtre aussi les connexions sur ce PC, avec ses propres règles que DM Loremind ne peut pas vérifier. Tant qu'il ne l'autorise pas, la tablette chargera sans fin.", + "thirdPartyHowTo": "Dans les réglages du pare-feu de ce logiciel : classe ton Wi-Fi en réseau domestique (pas public, sans mode furtif), puis ajoute une règle qui autorise DM Loremind en connexions entrantes.", + "docLink": "Voir la marche à suivre", + "docUrl": "https://loremind-docs.igmlcreation.fr/docs/configuration/acces-tablette#la-tablette-charge-sans-fin" } } }