fix: Connection Request fallback to IPv4 when CPE has IPv6-only URL
- device_record.ts: add lastRemoteIp field to store the CPE public IP from each Inform (X-Forwarded-For or TCP remote IP) - cwmp_controller.ts: persist lastRemoteIp on every Inform alongside lastPeriodicInformAt (single operation) - device_service.ts: sendWakeOnWlan() now tries the original URL first (may be IPv6), then falls back to a rebuilt URL using lastRemoteIp (IPv4 public IP) if the ACS server has no IPv6 connectivity
This commit is contained in:
1 parent
c3bc2902f0
commit
7d603da0ca
3 files changed
+67
-52
No files matched your search
@@ -200,13 +200,14 @@ export default class CwmpController {
|
||||
|
||||
logger.info({ events }, 'CWMP Inform events extracted')
|
||||
|
||||
// Track last periodic inform timestamp
|
||||
// Track last periodic inform timestamp + last remote IP (used for Connection Request fallback)
|
||||
const normalizedEvents = events.map((e) => normalizeEventCode(e))
|
||||
const isPeriodic = normalizedEvents.some((e) => e === 'PERIODIC')
|
||||
const isBootstrap = normalizedEvents.some((e) => e === 'BOOTSTRAP')
|
||||
if (isPeriodic || isBootstrap) {
|
||||
await DeviceModel.updateOne({ identifier: hashId }, { $set: { lastPeriodicInformAt: new Date() } }).catch(() => {})
|
||||
}
|
||||
const cpeIpForStorage = (xForwardedFor || '').split(',')[0]?.trim() || remoteKey.split(':')[0]
|
||||
const dbUpdate: Record<string, any> = { lastRemoteIp: cpeIpForStorage }
|
||||
if (isPeriodic || isBootstrap) dbUpdate.lastPeriodicInformAt = new Date()
|
||||
await DeviceModel.updateOne({ identifier: hashId }, { $set: dbUpdate }).catch(() => {})
|
||||
|
||||
// Phase 12: Crash pattern detection
|
||||
const hasBoot = normalizedEvents.some((e) => e === 'BOOT')
|
||||
|
||||
Reference in new issue
Block a user