diff --git a/app/modules/upnp-provider.ts b/app/modules/upnp-provider.ts index cc7a396f936131eccce7fd49a2dcc1a549ca97c1..dcda0a301d70ad5b20833dce330e78f846e8fd7b 100644 --- a/app/modules/upnp-provider.ts +++ b/app/modules/upnp-provider.ts @@ -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: { diff --git a/app/modules/ws2p/index.ts b/app/modules/ws2p/index.ts index 8deb5523c8d8127f66765245dfad7e68dc014ba9..930962bd275c9f3c199fd51d02fe59f0092f087a 100644 --- a/app/modules/ws2p/index.ts +++ b/app/modules/ws2p/index.ts @@ -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