fix: persist empty POST in TR-069 trace when CPE uses a new TCP port
Build & Deploy / build (push) Successful in 38s
Build & Deploy / docker (push) Successful in 1m5s
Build & Deploy / deploy (push) Successful in 23s

When a CPE sends an empty POST (polling) on a new TCP connection, the
remoteKey (IP:port) differs from the one registered during Inform.
Add StateMachineManager.getHashIdForRemoteIp() to find the device by
IP alone as a fallback, so cwmpDeviceId is resolved and the exchange
is properly stored in the trace (cwmpMethod: Empty, dashed arrow).
This commit is contained in:
Kevin L'Hereec committed 2026-07-17 14:24:44 +02:00
1 parent 3bb85d9031
commit d44d896556
2 files changed
+28

No files matched your search

@@ -248,6 +248,31 @@ export class StateMachineManager extends EventEmitter {
}
}
/**
* Fallback lookup: returns the hash identifier for any active device whose
* last known remote IP matches the given IP (ignoring port).
* Used when a CPE opens a new TCP connection for an empty POST and the
* exact remoteKey (IP:port) is not in the map.
*/
getHashIdForRemoteIp(remoteIp: string): string | undefined {
for (const [key, deviceKeyJson] of this.remoteToDevice.entries()) {
const keyIp = key.split(':').slice(0, -1).join(':') // strip port (handles IPv6 too)
if (keyIp !== remoteIp) continue
try {
const deviceId = JSON.parse(deviceKeyJson)
return getDeviceHashIdentifier({
manufacturer: deviceId.manufacturer ?? '',
oui: deviceId.oui,
productClass: deviceId.productClass,
serialNumber: deviceId.serialNumber,
})
} catch {
return undefined
}
}
return undefined
}
/**
* Ensure session is bound when TCP connection changes
*/