Commit 9d234d02 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Fix: regular UPnP was not triggered

parent c65a9de9
......@@ -23,7 +23,9 @@ var Synchroniser = require('../lib/sync');
var multicaster = require('../lib/streams/multicaster');
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) {
......@@ -88,6 +90,16 @@ function WebAdmin (dbConf, overConf) {
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 *() {
yield pluggedDALP;
return bmapi.closeConnections();
......
......@@ -18,10 +18,11 @@ module.exports = function(dbConf, overConf, interfaces, httpLogs) {
return network.createServersAndListen('uCoin web admin', interfaces, httpLogs, fullPath, (app, httpMethods) => {
httpMethods.httpGET( '/webmin/summary', webminCtrl.summary, dtos.AdminSummary);
httpMethods.httpPOST( '/webmin/key/preview', webminCtrl.previewPubkey, dtos.PreviewPubkey);
httpMethods.httpPOST( '/webmin/key/preview', webminCtrl.previewPubkey, dtos.PreviewPubkey);
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/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.httpPOST( '/webmin/server/send_conf', webminCtrl.sendConf, dtos.Identity);
httpMethods.httpPOST( '/webmin/server/net_conf', webminCtrl.applyNetworkConf, dtos.Boolean);
......
......@@ -25,13 +25,12 @@ module.exports = function (localPort, remotePort) {
client.close();
});
}
let interval;
return {
let interval, upnpService = {
openPort: () => {
return openPort(localPort, remotePort);
},
startRegular: () => {
this.stopRegular();
upnpService.stopRegular();
// Update UPnP IGD every INTERVAL seconds
interval = setInterval(async.apply(openPort, localPort, remotePort), 1000 * constants.NETWORK.UPNP.INTERVAL);
},
......@@ -41,6 +40,7 @@ module.exports = function (localPort, remotePort) {
}
}
};
return upnpService;
});
});
};
......
......@@ -16,7 +16,7 @@
"test": "mocha --growl --timeout 20000 test test/fast test/fast/block test/integration test/",
"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/",
"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": {
"type": "git",
......
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