-
-
Notifications
You must be signed in to change notification settings - Fork 26
override local network for onvif scan in containers #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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_NETWORKenvironment variable support inonvif_discovery.c - Added
[onvif]configuration section parsing inconfig.cwith 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.
…new onvif network feature
I've successfully implemented support for overriding the ONVIF discovery network via environment variable for container deployments. Here's what was done:
Changes Made
Added ONVIF default settings initialization
Added [onvif] section parsing for INI config files
Settings: discovery_enabled, discovery_interval, discovery_network
Added LIGHTNVR_ONVIF_NETWORK environment variable check
Implemented priority-based network selection
config/lightnvr.ini - Added [onvif] section with examples
docker-entrypoint.sh - Added ONVIF section to default config template
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!