Embed credentials in ONVIF device service URL when provided

This commit is contained in:
eduard256
2025-11-07 18:31:19 +03:00
parent 7fd1d78ffa
commit 292d5f8049
+10
View File
@@ -127,6 +127,16 @@ func (o *ONVIFDiscovery) discoverViaONVIF(ctx context.Context, ip, username, pas
if len(profileStreams) > 0 {
// Add ONVIF device service endpoint
deviceServiceURL := fmt.Sprintf("http://%s/onvif/device_service", xaddr)
// Embed credentials in URL if provided
if username != "" && password != "" {
u, err := url.Parse(deviceServiceURL)
if err == nil {
u.User = url.UserPassword(username, password)
deviceServiceURL = u.String()
}
}
streams = append(streams, models.DiscoveredStream{
URL: deviceServiceURL,
Type: "ONVIF",