Skip to content

Conversation

@wltechblog
Copy link
Contributor

I've successfully implemented support for overriding the ONVIF discovery network via environment variable for container deployments. Here's what was done:

Changes Made

  1. Core Configuration (src/core/config.c)
    Added ONVIF default settings initialization
    Added [onvif] section parsing for INI config files
    Settings: discovery_enabled, discovery_interval, discovery_network
  2. ONVIF Discovery Logic (src/video/onvif_discovery.c)
    Added LIGHTNVR_ONVIF_NETWORK environment variable check
    Implemented priority-based network selection
  3. Configuration Files
    config/lightnvr.ini - Added [onvif] section with examples
    docker-entrypoint.sh - Added ONVIF section to default config template
  4. Documentation
    docs/DOCKER.md - Comprehensive documentation with examples
    docker-compose.yml - Added commented example
    ONVIF_NETWORK_OVERRIDE_IMPLEMENTATION.md - Full implementation guide
    Priority Order for Network Selection
    Explicit parameter - Network passed to discover_onvif_devices() function
    Environment variable - LIGHTNVR_ONVIF_NETWORK ⭐ NEW
    Config file - [onvif] section discovery_network setting ⭐ NEW
    Auto-detection - Existing behavior (skips Docker interfaces)
    Usage Example

docker-compose.yml

services:
lightnvr:
environment:
- LIGHTNVR_ONVIF_NETWORK=192.168.1.0/24
Or:

docker run -e LIGHTNVR_ONVIF_NETWORK=192.168.1.0/24
-p 8080:8080
ghcr.io/opensensor/lightnvr:latest
Key Benefits
✅ Container-friendly - Easy environment variable configuration

✅ Flexible - Multiple configuration methods

✅ Backward compatible - Existing auto-detection still works

✅ Well-documented - Clear examples for users

✅ No breaking changes - All existing functionality preserved

The implementation is complete and ready for testing. Users running LightNVR in containers can now easily specify which network to scan for ONVIF cameras by setting the LIGHTNVR_ONVIF_NETWORK environment variable!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for overriding the ONVIF discovery network via environment variable to enable ONVIF camera discovery in containerized deployments where auto-detection skips Docker bridge interfaces.

Changes:

  • Added LIGHTNVR_ONVIF_NETWORK environment variable support in onvif_discovery.c
  • Added [onvif] configuration section parsing in config.c with validation
  • Updated documentation and configuration examples for Docker deployments

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/video/onvif_discovery.c Added environment variable check for network override before auto-detection
src/core/config.c Added ONVIF config section parsing with discovery_enabled, discovery_interval, and discovery_network settings
config/lightnvr.ini Added [onvif] section with discovery settings and documentation
config/lightnvr-test.ini New test configuration file (missing ONVIF section)
config/go2rtc/go2rtc-test.yaml New go2rtc test configuration with virtual test streams
docs/DOCKER.md Added ONVIF environment variable documentation with usage examples
docker-compose.yml Added commented example for LIGHTNVR_ONVIF_NETWORK variable
docker-entrypoint.sh Added [onvif] section to default configuration template
ONVIF_NETWORK_OVERRIDE_IMPLEMENTATION.md New implementation documentation describing the feature
test_onvif_env.sh New test script documenting expected behavior (not an automated test)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matteius matteius merged commit a5ac6a8 into opensensor:main Jan 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants