Fix HTTP camera authentication: generate all auth variants for comprehensive testing

This commit addresses the issue where HTTP-based cameras (JPEG/MJPEG) were not being
discovered due to incomplete authentication variant generation.

Changes:
- Builder now generates 4 authentication variants for each HTTP/HTTPS URL:
  1. No authentication (for open cameras)
  2. Basic Auth only (embedded credentials in URL)
  3. Query parameters only (user=X&pwd=Y)
  4. Basic Auth + Query parameters (combined approach)

- Scanner updated to use BuildURLsFromEntry instead of BuildURL for popular patterns,
  ensuring all authentication variants are tested

- Preserved existing query parameter values (e.g., channel=1 remains unchanged)

This fix enables discovery of cameras that require different authentication methods,
including those that only accept Basic Auth headers, query parameters, or combinations.

Tested with ZOSI ZG23213M camera - increased discovery from 0 to 9 working streams.
This commit is contained in:
eduard256
2025-11-07 21:33:47 +03:00
parent 88e76eadb5
commit 18aaf07eca
2 changed files with 85 additions and 47 deletions
+10 -7
View File
@@ -362,17 +362,20 @@ func (s *Scanner) collectStreams(ctx context.Context, req models.StreamDiscovery
buildCtx.Port = pattern.Port
buildCtx.Protocol = pattern.Protocol
url := s.builder.BuildURL(entry, buildCtx)
if !urlMap[url] {
allStreams = append(allStreams, models.DiscoveredStream{
URL: url,
Type: pattern.Type,
// Generate all URL variants for this pattern
urls := s.builder.BuildURLsFromEntry(entry, buildCtx)
for _, url := range urls {
if !urlMap[url] {
allStreams = append(allStreams, models.DiscoveredStream{
URL: url,
Type: pattern.Type,
Protocol: pattern.Protocol,
Port: pattern.Port,
Working: false, // Will be tested
})
urlMap[url] = true
popularCount++
urlMap[url] = true
popularCount++
}
}
}
}