fix: persist empty POST in TR-069 trace when CPE uses a new TCP port
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:
1 parent
3bb85d9031
commit
d44d896556
2 files changed
+28
No files matched your search
@@ -40,7 +40,10 @@ export default class CwmpController {
|
||||
try {
|
||||
if (isEmpty) {
|
||||
const rebound = manager.ensureSessionForRemote(remoteKey, sessionId)
|
||||
// Try exact remoteKey first (same TCP connection), then fall back to IP-only
|
||||
// (CPE may open a new TCP port for the empty POST)
|
||||
const hashId = manager.getHashIdForRemote(remoteKey)
|
||||
?? manager.getHashIdForRemoteIp(request.ip())
|
||||
if (hashId) ctx.cwmpDeviceId = hashId
|
||||
|
||||
logger.debug(
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user