- HomeKitMdnsProbe : paquet DNS PTR brut sur 224.0.0.251:5353, écoute 2 s
avec timeout explicite Task.WhenAny (jamais de hang, cf. 491a253)
- Parseur DNS complet : PTR/SRV/TXT/A avec pointeurs de compression, TXT
(ci/id/md/sf), dédup par IP, mapping IP via SRV target
- Filtre catégories 17 (camera) et 18 (doorbell) — Strix pkg/probe/mdns.go
- Intégré au scan broadcast de NetworkCameraScanner ; devices HomeKit avec
HomeKitName/HomeKitDeviceId/HomeKitModel remplis → classés HomeKit côté central
- Les devices HomeKit ne génèrent plus de fausses URLs RTSP (flux HAP)
- Tests : 4 (parseur PTR/SRV/TXT/A, filtrage catégories, dédup, no-hang)
- ResolveHostnameAsync : PTR via Dns.GetHostEntryAsync avec timeout 500 ms,
échec silencieux (le scan n'est jamais bloqué par un DNS lent)
- Fallback uniquement : le hostname ONVIF/DVRIP/mDNS existant est conservé
- Agent : 22 ports probés (ajout 8080/5544/10554/1935/81/88/8090/8001/8081/7070/7447/51826)
- CameraStreamTemplates : port par défaut par schéma (rtsp=554, rtmp=1935, http=80,
dvrip=34567, bubble=80), filtre de compatibilité protocole → les URLs ne portent
plus de ports incohérents (ex. RTSP sur :80) ; plus de forçage de ports[0]
- Nouveaux templates : p:rtmp, b:uniview (bubble), b:reolink, dvrip:// dans p:dvrrip/b:dahua
- ProtocolFromUrl : Dvrip/Bubble/HomeKit reconnus côté central
- Tests : 9 tests unitaires CameraStreamTemplates
Refs #54#55#56
Socket.ReceiveTimeout only applies to synchronous Receive() — the async
ReceiveAsync(ct) on the ONVIF multicast, DVRIP broadcast and unicast
ONVIF probe waited forever when no camera replied, so a scan never
completed (no response → hang). Enforce the listen window explicitly
with Task.WhenAny(receiveTask, Task.Delay(...)):
- WS-Discovery multicast: 5s listen window
- DVRIP broadcast: 2s listen window
- unicast ONVIF probe: OnvifUdpTimeout (500ms)
Also fixed ValueTask→Task (.AsTask()) for the WhenAny overload.
Fixes#56
The agent asks the camera for its REAL stream URLs instead of guessing
from templates: GetProfiles (media service) then GetStreamUri per profile
(RTP-Unicast/RTSP), trying the site credential pool (anonymous → digest →
text). The returned URLs get the probed IP injected (buggy 0.0.0.0 or
different host) and the credentials embedded, so the Central gets a
directly usable main stream.
- Generalized BuildSoapEnvelope/PostSoapAsync for device + media services
- OnvifProbe carries StreamUrls; ProbeHostAsync and the WS-Discovery
multicast enrichment both fill them
- BuildFinalDeviceAsync prioritizes real GetStreamUri URLs over templates
and keeps them even if the stream test fails (camera proven by ONVIF)
- Refactored TestUrlsAsync shared by both paths
Fixes#55
Sends the DVRIP probe (ff00000000000000000000000000fa0500000000) 3x over
UDP broadcast on port 34569 and parses the NetWork.NetCommon JSON replies
(HostIP, HostName, MAC, HttpPort, Ret). Finds Dahua/Imou cameras even
when RTSP/ONVIF are disabled, with MAC/vendor from the reply itself.
- Filter Ret != 100 error replies, require HostIP+HostName
- Devices are created with OpenPorts [37777] (DVRIP) so they pass the
camera-evidence filter and get classified Standard by the Central
- Transposed from go2rtc internal/dvrip
Fixes#54
The agent now sends one UDP multicast probe (239.255.255.250:3702) per
scan and collects ONVIF replies for ~5s, instead of relying solely on the
per-IP TCP port sweep. This finds every ONVIF camera on the LAN — even
those with TCP 3702 closed — in one request, with name/hardware from the
WS-Discovery scopes (and the buggy 0.0.0.0 XAddrs fix).
- ScanAsync runs the broadcast probes in parallel with the TCP sweep and
merges results (dedupe by IP)
- Factorized BuildFinalDeviceAsync (evidence filter + live stream test)
shared by the TCP sweep and the multicast merge
- Transposed from go2rtc pkg/onvif DiscoveryStreamingDevices
- Compose (dev+prod): agent on host network (bridge 172.x was skipped by the
scanner), listen on 8081 (ntfy owns 8080), CentralUrl via host/domain,
healthcheck adapted, no Docker DNS
- Scanner: skip the LAN gateway (NAT router, never a camera); wider camera
ports (+34567/34568 Imou SDK, +8000 Hikvision SDK); 750 ms port timeout;
keep only devices with real camera evidence; RTSP OPTIONS + MJPEG
content-type probes prove live streams from the agent (it is on the LAN)
- Central: drop Unknown devices (nginx/gunicorn/gateway) on submit; classify
37777 DVRIP as Standard camera (not NVR), 8899 alone as NVR; persist
agent-tested stream URLs flagged IsAlive; shared CameraStreamTemplates
with the agent so both build identical candidate URLs
- UI: discoveries popup auto-selects the agent-verified main stream — no
manual stream choice
## What
L'enrichissement ONVIF authentifié est déplacé côté **agent**. Le pool de credentials du site (login/mdp) est exposé à l'agent via `GET /api/settings/agent/{id}` sous forme d'enveloppe AES-256-GCM (`AgentCredentialEnvelope`, clé dérivée du SHA-256 de l'API key) — déchiffrable uniquement côté agent. `NetworkCameraScanner` tente `GetDeviceInformation` avec chaque couple du pool (PasswordDigest puis PasswordText) et remonte des devices **déjà identifiés** (fabricant/modèle ONVIF + `CredentialLabel`). Le central persiste et marque le credential utilisé (`LastUsedAt`) — plus aucun appel réseau ONVIF côté central.
## Why
Le central n'est généralement **pas** sur le réseau des caméras : les appels ONVIF authentifiés qu'il faisait après réception des devices bruts échouaient. L'agent, lui, est sur le sous-réseau des caméras — c'est lui qui doit porter l'auth. Enrichissement et identification se font au moment du scan, avant la remontée.
## How
- `AgentCredentialEnvelope` (Application/Security) : AES-256-GCM, clé = SHA-256 de l'API key ; central chiffre (via l'`ApiKeyHash` stocké), agent déchiffre (via sa clé en clair).
- `GetEffectiveAgentConfigQuery` : ajoute `discovery.credentials` (pool chiffré) au dict de config.
- `SettingsController.GetEffectiveConfig` : accepte l'API key agent (vérification par site) en plus du JWT admin — corrige au passage un 403 latent sur cet endpoint.
- `NetworkCameraScanner` : probe ONVIF authentifié avec le pool (anonyme d'abord, puis chaque couple).
- `AgentCredentialStore` (mémoire, jamais sur disque) : reçoit le pool déchiffré par `ConfigReceiverService`, lu par `AgentDiscoveryService`.
- `CameraDiscoveryService` : suppression de l'enrichissement réseau ; persistance + `MarkUsed` via `CredentialLabel` ; vendor déduit du fabricant ONVIF remonté.
- `SitesController` : broadcast `ConfigReload` après add/delete credential pour que les agents re-fetch leur pool.
- Multi-agents : inchangé — upsert par (site, IP) et anti-doublon IP/MAC à la confirmation évitent les caméras en double même si un agent est éteint.
## Testing
- `dotnet build Heimdall.slnx` : 0 erreur / 0 warning.
- Application 346 verts, Agent 108 verts, Infrastructure 143 verts (hors Testcontainers).
- Web.Tests 213 verts — nouveaux bUnit : DiscoveriesPage (5) + SiteDetail credentials (4).
## Breaking Changes
Aucun changement de schéma (pas de migration). Comportement API : `GET /api/settings/agent/{id}` accepte désormais l'API key agent (accès élargi au cas d'usage prévu).
Related to #48
Co-authored-by: nonobis <nonobis@tordais.cc>
Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/49