From 62485cf0df94789c61ccf397e1aeee6bd9bab973 Mon Sep 17 00:00:00 2001 From: Ross Tyler Date: Wed, 18 Sep 2019 09:42:40 -0700 Subject: [PATCH] handleSubscribeEvent checks for request sid (renew) and succeeds if already subscribed --- lib/peer-upnp.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/peer-upnp.js b/lib/peer-upnp.js index fdc4894..1ac1337 100644 --- a/lib/peer-upnp.js +++ b/lib/peer-upnp.js @@ -801,12 +801,19 @@ var handleSubscribeEvent = function(req,rsp,peer){ var device = peer.devices[udn]; var service = device && device.services[serviceType]; if (service) { - var sid = "uuid:"+UUID.v4(); - var callbacks = req.headers.callback && req.headers.callback.replace(/[<|>]/g,"").split(","); - service.subscriptions[sid] = { - callbacks: callbacks, - seq: 0 - }; + var sid = req.headers.sid; + if (sid) { + if (!(sid in service.subscriptions)) { + rsp.statusCode = 404; + } + } else { + var sid = "uuid:"+UUID.v4(); + var callbacks = req.headers.callback && req.headers.callback.replace(/[<|>]/g,"").split(","); + service.subscriptions[sid] = { + callbacks: callbacks, + seq: 0 + }; + } var timeout = req.headers.timeout || "Second-1800"; rsp.setHeader('DATE',new Date().toUTCString()); rsp.setHeader('SERVER',"win/5.1 UPnP/1.1 famium/0.0.1");