Skip to content
Snippets Groups Projects
Commit 9d234d02 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Fix: regular UPnP was not triggered

parent c65a9de9
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,9 @@ var Synchroniser = require('../lib/sync'); ...@@ -23,7 +23,9 @@ var Synchroniser = require('../lib/sync');
var multicaster = require('../lib/streams/multicaster'); var multicaster = require('../lib/streams/multicaster');
var logger = require('../lib/logger')('webmin'); var logger = require('../lib/logger')('webmin');
module.exports = (dbConf, overConf) => new WebAdmin(dbConf, overConf); module.exports = (dbConf, overConf) => {
return new WebAdmin(dbConf, overConf);
};
function WebAdmin (dbConf, overConf) { function WebAdmin (dbConf, overConf) {
...@@ -88,6 +90,16 @@ function WebAdmin (dbConf, overConf) { ...@@ -88,6 +90,16 @@ function WebAdmin (dbConf, overConf) {
return upnp(server.conf.port, server.conf.remoteport); return upnp(server.conf.port, server.conf.remoteport);
}); });
this.regularUPnP = () => co(function *() {
yield pluggedDALP;
if (server.upnpAPI) {
server.upnpAPI.stopRegular();
}
server.upnpAPI = yield upnp(server.conf.port, server.conf.remoteport);
server.upnpAPI.startRegular();
return {};
});
this.stopHTTP = () => co(function *() { this.stopHTTP = () => co(function *() {
yield pluggedDALP; yield pluggedDALP;
return bmapi.closeConnections(); return bmapi.closeConnections();
......
...@@ -22,6 +22,7 @@ module.exports = function(dbConf, overConf, interfaces, httpLogs) { ...@@ -22,6 +22,7 @@ module.exports = function(dbConf, overConf, interfaces, httpLogs) {
httpMethods.httpGET( '/webmin/server/http/start', webminCtrl.startHTTP, dtos.Boolean); httpMethods.httpGET( '/webmin/server/http/start', webminCtrl.startHTTP, dtos.Boolean);
httpMethods.httpGET( '/webmin/server/http/stop', webminCtrl.stopHTTP, dtos.Boolean); httpMethods.httpGET( '/webmin/server/http/stop', webminCtrl.stopHTTP, dtos.Boolean);
httpMethods.httpGET( '/webmin/server/http/upnp/open', webminCtrl.openUPnP, dtos.Boolean); httpMethods.httpGET( '/webmin/server/http/upnp/open', webminCtrl.openUPnP, dtos.Boolean);
httpMethods.httpGET( '/webmin/server/http/upnp/regular', webminCtrl.regularUPnP, dtos.Boolean);
httpMethods.httpGET( '/webmin/server/preview_next', webminCtrl.previewNext, dtos.Block); httpMethods.httpGET( '/webmin/server/preview_next', webminCtrl.previewNext, dtos.Block);
httpMethods.httpPOST( '/webmin/server/send_conf', webminCtrl.sendConf, dtos.Identity); httpMethods.httpPOST( '/webmin/server/send_conf', webminCtrl.sendConf, dtos.Identity);
httpMethods.httpPOST( '/webmin/server/net_conf', webminCtrl.applyNetworkConf, dtos.Boolean); httpMethods.httpPOST( '/webmin/server/net_conf', webminCtrl.applyNetworkConf, dtos.Boolean);
......
...@@ -25,13 +25,12 @@ module.exports = function (localPort, remotePort) { ...@@ -25,13 +25,12 @@ module.exports = function (localPort, remotePort) {
client.close(); client.close();
}); });
} }
let interval; let interval, upnpService = {
return {
openPort: () => { openPort: () => {
return openPort(localPort, remotePort); return openPort(localPort, remotePort);
}, },
startRegular: () => { startRegular: () => {
this.stopRegular(); upnpService.stopRegular();
// Update UPnP IGD every INTERVAL seconds // Update UPnP IGD every INTERVAL seconds
interval = setInterval(async.apply(openPort, localPort, remotePort), 1000 * constants.NETWORK.UPNP.INTERVAL); interval = setInterval(async.apply(openPort, localPort, remotePort), 1000 * constants.NETWORK.UPNP.INTERVAL);
}, },
...@@ -41,6 +40,7 @@ module.exports = function (localPort, remotePort) { ...@@ -41,6 +40,7 @@ module.exports = function (localPort, remotePort) {
} }
} }
}; };
return upnpService;
}); });
}); });
}; };
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"test": "mocha --growl --timeout 20000 test test/fast test/fast/block test/integration test/", "test": "mocha --growl --timeout 20000 test test/fast test/fast/block test/integration test/",
"start": "node bin/ucoind start", "start": "node bin/ucoind start",
"test-travis": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --timeout 20000 test test/fast test/fast/block test/integration test/", "test-travis": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --timeout 20000 test test/fast test/fast/block test/integration test/",
"postinstall": "mkdir ui -p && cd ui && npm pack ucoin-ui@0.1.11 && tar xzf ucoin-ui-0.1.11.tgz && cd package && npm install && cd .. && rm ucoin-ui-0.1.11.tgz" "postinstall": "mkdir ui -p && cd ui && npm pack ucoin-ui@0.1.12 && tar xzf ucoin-ui-0.1.12.tgz && cd package && npm install && cd .. && rm ucoin-ui-0.1.12.tgz"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment