Publish camera recovery and stale route cleanup

This commit is contained in:
Andrei Smaliak 2026-10-13 08:02:24 +02:00
parent 2eeffa8b6f
commit 9c96dd14e0
12 changed files with 147 additions and 6 deletions

View File

@ -0,0 +1,11 @@
# stage_env 1.0.4
- Installs a NetworkManager dispatcher that removes stale IPv4 `table local`
routes after interface activation, DHCP lease changes and connection reapply.
- Preserves every address currently assigned to the interface and ignores the
loopback interface. This prevents old Edge DHCP leases from shadowing cameras
and other LAN devices which later receive those addresses.
- Runs the same cleanup once during installation so affected Edge devices recover
immediately without waiting for the next network event.
- Validation covers removal of an obsolete camera address while retaining the
current Edge address, installer ownership and dispatcher event wiring.

View File

@ -0,0 +1,18 @@
# stage_itscreen 1.0.22 — native client 4.410.156
Release date: 2026-10-13.
- Publish client 4.410.156 with automatic ONVIF camera address recovery by
stable endpoint UUID, device serial or MAC address.
- Start active rediscovery after repeated monitor failures and during startup
and periodic background scans. Runtime monitoring switches to the confirmed
address immediately while the server persists it and refreshes Edge config.
- Retain configuration acknowledgements, input emulation and grouped event
Boolean logic delivered in clients 4.410.154 and 4.410.155.
Binary: `stage_itscreen/itscreen` (Linux ARM64).
SHA-256: `ab667af08e008bccdceef12d4f107cf64fbfdf170507e3e407a2e1628107be6a`.
Validation: native Qt 5.15.2 ARM64 release build and live installation on UAE
`g-box-c453df5f`; both Tapo C520WS and TC70 rediscovered at their current IPs;
service active with zero restarts and no inspected QML/JavaScript errors.

View File

@ -2,7 +2,7 @@
"schema": 1,
"stages": {
"stage_env": {
"version": "1.0.3"
"version": "1.0.4"
},
"stage_wifi": {
"version": "1.0.0"
@ -23,7 +23,7 @@
"version": "1.0.0"
},
"stage_itscreen": {
"version": "1.0.21"
"version": "1.0.22"
},
"stage_reverse_tunnels": {
"version": "1.0.1"

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
interface="${1:-}"
action="${2:-}"
case "$action" in
up|dhcp4-change|reapply)
/usr/local/sbin/iomatex-network-local-route-cleanup "$interface"
;;
esac

View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
interface="${1:-}"
ip_bin="${IOMATEX_IP_BIN:-/usr/sbin/ip}"
logger_bin="${IOMATEX_LOGGER_BIN:-/usr/bin/logger}"
if [ -z "$interface" ] || [ "$interface" = "lo" ]; then
exit 0
fi
if ! "$ip_bin" link show dev "$interface" >/dev/null 2>&1; then
exit 0
fi
declare -A assigned=()
while read -r address; do
[ -n "$address" ] && assigned["$address"]=1
done < <("$ip_bin" -o -4 address show dev "$interface" | awk '{split($4, value, "/"); print value[1]}')
while read -r address; do
[ -n "$address" ] || continue
if [ -n "${assigned[$address]:-}" ]; then
continue
fi
if "$ip_bin" -4 route del local "$address" dev "$interface" table local; then
"$logger_bin" -t iomatex-network "removed stale local route ${address} from ${interface}" || true
fi
done < <("$ip_bin" -4 route show table local type local dev "$interface" | awk '$1 == "local" {print $2}')

View File

@ -371,6 +371,22 @@ EOF
fi
}
configure_networkmanager_route_cleanup() {
install -D -o root -g root -m 0755 \
"$SCRIPT_DIR/iomatex-network-local-route-cleanup" \
/usr/local/sbin/iomatex-network-local-route-cleanup
install -D -o root -g root -m 0755 \
"$SCRIPT_DIR/30-iomatex-local-route-cleanup" \
/etc/NetworkManager/dispatcher.d/30-iomatex-local-route-cleanup
local interface
while read -r interface; do
[ -n "$interface" ] || continue
/usr/local/sbin/iomatex-network-local-route-cleanup "$interface" || \
log "WARN: stale local route cleanup failed for ${interface}"
done < <(ip -o link show up 2>/dev/null | awk -F': ' '$2 != "lo" {print $2}' | cut -d@ -f1)
}
userdata_has_journal() {
local device
device="$(readlink -f /dev/disk/by-partlabel/userdata 2>/dev/null || true)"
@ -1171,6 +1187,7 @@ fi
keep_pcp_logs_on_root
systemctl_enable_now_safe NetworkManager
configure_networkmanager_dns
configure_networkmanager_route_cleanup
IP_MAIN="$(main_ipv4)"
[ -n "${IP_MAIN:-}" ] || IP_MAIN="<device-ip>"

View File

@ -0,0 +1,56 @@
#!/usr/bin/env python3
import os
import pathlib
import subprocess
import tempfile
import unittest
ROOT = pathlib.Path(__file__).parent
SCRIPT = ROOT / "iomatex-network-local-route-cleanup"
DISPATCHER = ROOT / "30-iomatex-local-route-cleanup"
INSTALLER = ROOT / "stage_env_install_no_pulse.sh"
class NetworkLocalRouteCleanupTest(unittest.TestCase):
def test_removes_only_routes_without_assigned_addresses(self):
with tempfile.TemporaryDirectory() as directory:
directory = pathlib.Path(directory)
calls = directory / "calls"
fake_ip = directory / "ip"
fake_ip.write_text(f"""#!/usr/bin/env bash
echo "$*" >> {calls}
case "$*" in
"link show dev eth0") exit 0 ;;
"-o -4 address show dev eth0")
echo '2: eth0 inet 192.168.70.100/24 brd 192.168.70.255 scope global eth0'
;;
"-4 route show table local type local dev eth0")
echo 'local 192.168.70.100 dev eth0 proto kernel scope host src 192.168.70.100'
echo 'local 192.168.70.161 dev eth0 proto kernel scope host src 192.168.70.161'
;;
esac
""")
fake_ip.chmod(0o755)
result = subprocess.run(
[str(SCRIPT), "eth0"],
text=True,
capture_output=True,
env={**os.environ, "IOMATEX_IP_BIN": str(fake_ip), "IOMATEX_LOGGER_BIN": "/bin/true"},
)
self.assertEqual(0, result.returncode, result.stderr)
command_log = calls.read_text()
self.assertIn("route del local 192.168.70.161 dev eth0 table local", command_log)
self.assertNotIn("route del local 192.168.70.100 dev eth0 table local", command_log)
def test_dispatcher_and_installer_own_the_cleanup_contract(self):
dispatcher = DISPATCHER.read_text()
installer = INSTALLER.read_text()
self.assertIn("up|dhcp4-change|reapply", dispatcher)
self.assertIn("/usr/local/sbin/iomatex-network-local-route-cleanup", dispatcher)
self.assertIn("/etc/NetworkManager/dispatcher.d/30-iomatex-local-route-cleanup", installer)
self.assertIn("iomatex-network-local-route-cleanup", installer)
if __name__ == "__main__":
unittest.main()

View File

@ -1,3 +1,3 @@
{
"version": "1.0.3"
"version": "1.0.4"
}

Binary file not shown.

View File

@ -1 +1 @@
972bf083e967c086eab1d3b4d9eb08fa2f4ef572c15f3d3ae250d95ff35a4b1f itscreen
ab667af08e008bccdceef12d4f107cf64fbfdf170507e3e407a2e1628107be6a itscreen

View File

@ -1 +1 @@
4.410.153
4.410.156

View File

@ -1,3 +1,3 @@
{
"version": "1.0.21"
"version": "1.0.22"
}