pOnvif: use the reached address for services reported on the LAN side of a NAT #25

Merged
ClaudeAI merged 1 commits from fix/onvif-nat-xaddr into master 34 minutes ago
Collaborator

Summary

A camera reached through NAT / port forwarding (2.54.237.28:8080) failed in la_mojo with media_GetVideoSources _send_request Failure!, then pOnvif CREATE FAILURE!, then PTZ FAILED (PTZ protocol initialisation failed) with a re-init every 40 s.

GetCapabilities reports the camera's services at its LAN address (http://192.168.200.118:8080/onvif/...), which can't be reached from outside, and pOnvif used those addresses.

Change (lib/data/ponvif/ponvif.cpp/.h)

  • Rewrite: pOnvif::reachableXAddr() rewrites a service XAddr (PTZ, Media, Device, Imaging, Events) whose host differs from the address the device was reached at (m_pIpAddress). It becomes http://<reached host:port> + its path, rewritten in place, and is logged as Service address ... -> ... (device reached at another address: NAT).
  • Same host: a service on the same host is unchanged, so services on other ports keep working.
  • Where: it is called in _getOnvifVersion(), before the service URIs are taken.

The web UI got the same fix in gagua/Mojo_Web#2 (merged).

Testing

  • Real camera, read-only calls: create and GetStatus. The camera was reached through a local forwarder, i.e. at another address than it reports.
    • Old code: GetVideoSources failure and CREATE FAILURE, as in the field.
    • New code: the 5 services are moved, the PTZ profile is found, MoveStatus and Position support and the speed spaces are read, and the GetStatus probe succeeds.
  • AddressSanitizer: clean.
  • Field test: the user confirmed that la_mojo works with the camera.
  • Build: la_mojo Debug86 builds. The only error is videoLive555AVLibSource.cpp:818, caused by the newer live555 headers in the check environment, not by this change.

Generated with Claude Code

https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16

## Summary A camera reached through NAT / port forwarding (2.54.237.28:8080) failed in la_mojo with `media_GetVideoSources _send_request Failure!`, then `pOnvif CREATE FAILURE!`, then `PTZ FAILED (PTZ protocol initialisation failed)` with a re-init every 40 s. GetCapabilities reports the camera's services at its LAN address (`http://192.168.200.118:8080/onvif/...`), which can't be reached from outside, and `pOnvif` used those addresses. ### Change (`lib/data/ponvif/ponvif.cpp/.h`) - **Rewrite:** `pOnvif::reachableXAddr()` rewrites a service XAddr (PTZ, Media, Device, Imaging, Events) whose host differs from the address the device was reached at (`m_pIpAddress`). It becomes `http://<reached host:port>` + its path, rewritten in place, and is logged as `Service address ... -> ... (device reached at another address: NAT)`. - **Same host:** a service on the same host is unchanged, so services on other ports keep working. - **Where:** it is called in `_getOnvifVersion()`, before the service URIs are taken. The web UI got the same fix in gagua/Mojo_Web#2 (merged). ## Testing - **Real camera, read-only calls:** create and GetStatus. The camera was reached through a local forwarder, i.e. at another address than it reports. - Old code: GetVideoSources failure and CREATE FAILURE, as in the field. - New code: the 5 services are moved, the PTZ profile is found, MoveStatus and Position support and the speed spaces are read, and the GetStatus probe succeeds. - **AddressSanitizer:** clean. - **Field test:** the user confirmed that la_mojo works with the camera. - **Build:** la_mojo Debug86 builds. The only error is `videoLive555AVLibSource.cpp:818`, caused by the newer live555 headers in the check environment, not by this change. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
ClaudeAI added 1 commit 34 minutes ago
072af48fd6
pOnvif: use the reached address for services reported on the LAN side of a NAT
ClaudeAI merged commit 48020dba7e into master 34 minutes ago
The pull request has been merged as 48020dba7e.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.