Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ export class UpnpProvider { ...@@ -32,6 +32,7 @@ export class UpnpProvider {
private upnpInterval = 300, private upnpInterval = 300,
private ttl = 600, private ttl = 600,
private logger?:any, private logger?:any,
private host = ''
) {} ) {}
async checkUPnPisAvailable() { async checkUPnPisAvailable() {
...@@ -72,7 +73,10 @@ export class UpnpProvider { ...@@ -72,7 +73,10 @@ export class UpnpProvider {
const client = upnp.createClient() const client = upnp.createClient()
client.portMapping({ client.portMapping({
'public': this.currentConfig.port, 'public': this.currentConfig.port,
'private': this.currentConfig.port, 'private': {
host: this.currentConfig.host,
port: this.currentConfig.port,
},
'ttl': this.ttl, 'ttl': this.ttl,
'description': this.getUpnpDescription() 'description': this.getUpnpDescription()
}, (err:any) => { }, (err:any) => {
...@@ -123,7 +127,7 @@ export class UpnpProvider { ...@@ -123,7 +127,7 @@ export class UpnpProvider {
} }
private async getAvailablePort(client:any) { 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 remoteIP = await UpnpProvider.getRemoteIP(client)
const mappings:{ const mappings:{
private: { private: {
......
...@@ -243,7 +243,8 @@ export class WS2PAPI extends stream.Transform { ...@@ -243,7 +243,8 @@ export class WS2PAPI extends stream.Transform {
':ws2p:' + suffix, ':ws2p:' + suffix,
WS2PConstants.WS2P_UPNP_INTERVAL, WS2PConstants.WS2P_UPNP_INTERVAL,
WS2PConstants.WS2P_UPNP_TTL, WS2PConstants.WS2P_UPNP_TTL,
logger) logger,
this.conf.ws2p.host)
const { host, port, available } = await this.upnpAPI.startRegular() const { host, port, available } = await this.upnpAPI.startRegular()
if (available) { if (available) {
// Defaults UPnP to true if not defined and available // Defaults UPnP to true if not defined and available
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment