Commit 3d54e3fd authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] WS2P: UPnP local host interface can be forced (in case of UPnP fail for example)

parent 097d1d7a
......@@ -32,6 +32,7 @@ export class UpnpProvider {
private upnpInterval = 300,
private ttl = 600,
private logger?:any,
private host = ''
) {}
async checkUPnPisAvailable() {
......@@ -72,7 +73,10 @@ export class UpnpProvider {
const client = upnp.createClient()
client.portMapping({
'public': this.currentConfig.port,
'private': this.currentConfig.port,
'private': {
host: this.currentConfig.host,
port: this.currentConfig.port,
},
'ttl': this.ttl,
'description': this.getUpnpDescription()
}, (err:any) => {
......@@ -123,7 +127,7 @@ export class UpnpProvider {
}
private async getAvailablePort(client:any) {
const localIP = await UpnpProvider.getLocalIP(client)
const localIP = this.host || await UpnpProvider.getLocalIP(client)
const remoteIP = await UpnpProvider.getRemoteIP(client)
const mappings:{
private: {
......
......@@ -243,7 +243,8 @@ export class WS2PAPI extends stream.Transform {
':ws2p:' + suffix,
WS2PConstants.WS2P_UPNP_INTERVAL,
WS2PConstants.WS2P_UPNP_TTL,
logger)
logger,
this.conf.ws2p.host)
const { host, port, available } = await this.upnpAPI.startRegular()
if (available) {
// Defaults UPnP to true if not defined and available
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment