diff --git a/upnpMapper.js b/upnpMapper.js index c00db7e..f2b79cb 100644 --- a/upnpMapper.js +++ b/upnpMapper.js @@ -97,7 +97,6 @@ async function main() { const upnpPortList = run('upnpc -l'); // console.log(upnpPortList); - for (const instance of JSON.parse(instancesJSON)) { if (instance.DeploymentArgs['GenericModule.App.Ports'] != undefined) { // 0 - TCP; 1 = UDP; 2 - Both @@ -147,8 +146,22 @@ async function main() { } } } - } + if (instance.DeploymentArgs['FileManagerPlugin.SFTP.SFTPPortNumber'] != undefined) { + let Name = `AMP ${instance.FriendlyName} SFTP`; + let Number = instance.DeploymentArgs['FileManagerPlugin.SFTP.SFTPPortNumber']; + instancesPorts += `${Name}\n`; + + if (!upnpPortList.includes(Name)) { + try { + run(`upnpc -e "${Name}" -a ${config.ip} ${Number} ${Number} TCP`); + console.log(`Port added: "${Name}" ${Number} TCP`); + } catch (error) { + console.log(`Port failed: "${Name}" ${Number} TCP`); + } + } + } + } // Delete all AMP // for (const portMap of upnpPortList.split('\n')) { // if (portMap.includes("AMP")) {