set port on matched upnp record

canary
Marcus 2021-04-01 01:24:54 -04:00
parent 36e9acd7aa
commit e0b837876d
1 changed files with 4 additions and 2 deletions

View File

@ -46,12 +46,14 @@ class Node extends EventEmitter {
const mappings = await upnp.mappings(); const mappings = await upnp.mappings();
const alreadyMapped = mappings.filter(mapping => { const matchingMappings = mappings.filter(mapping => {
return mapping.description === this.name return mapping.description === this.name
}).length > 0; });
const alreadyMapped = matchingMappings.length > 0;
if(alreadyMapped) { if(alreadyMapped) {
console.log('already mapped!'); console.log('already mapped!');
this.port = matchingMappings[0].public.port;
return; return;
} }