this.logger.trace('WS2P: mapping external port %s to local %s using UPnP...',this.currentConfig.port,[this.currentConfig.host,this.currentConfig.port].join(':'))
constclient=upnp.createClient()
constclient=upnp.createClient()
client.portMapping({
client.portMapping({
'public':upnpBinding.port,
'public':this.currentConfig.port,
'private':upnpBinding.port,
'private':this.currentConfig.port,
'ttl':WS2PConstants.WS2P_UPNP_TTL
'ttl':WS2PConstants.WS2P_UPNP_TTL
},(err:any)=>{
},(err:any)=>{
client.close()
client.close()
...
@@ -46,8 +59,7 @@ export class WS2PUpnp {
...
@@ -46,8 +59,7 @@ export class WS2PUpnp {
this.logger.warn(err)
this.logger.warn(err)
returnreject(err)
returnreject(err)
}
}
this.currentConfig=upnpBinding
resolve(this.currentConfig)
resolve(upnpBinding)
})
})
})
})
}
}
...
@@ -96,14 +108,11 @@ export class WS2PUpnp {
...
@@ -96,14 +108,11 @@ export class WS2PUpnp {
port:number
port:number
}
}
}[]=awaitWS2PUpnp.getUPnPMappings(client)
}[]=awaitWS2PUpnp.getUPnPMappings(client)
constipOfPort:string[]=[]
constexternalPortsUsed=mappings.map((m)=>{
constexternalPortsUsed=mappings.map((m)=>{
ipOfPort.push(m.private.host)
returnm.public.port
returnm.public.port
})
})
letavailablePort=WS2PConstants.WS2P_PORTS_START
letavailablePort=WS2PConstants.WS2P_PORTS_START
while (externalPortsUsed.indexOf(availablePort)!==-1
while (externalPortsUsed.indexOf(availablePort)!==-1