From 0a876219ad58584bd8c509fb561edfcc02e752a5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 20 Oct 2018 19:18:07 +0200 Subject: [PATCH 1/2] Add a registeredToDyndns boolean If it's false it registers to dyndns immediately when the static IP is disabled --- build/src/src/calls/setStaticIp.js | 2 +- build/src/src/dyndnsClient/updateIp.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build/src/src/calls/setStaticIp.js b/build/src/src/calls/setStaticIp.js index bc5c5b08..eb09f557 100644 --- a/build/src/src/calls/setStaticIp.js +++ b/build/src/src/calls/setStaticIp.js @@ -12,7 +12,7 @@ async function setStaticIp({staticIp}) { } else if (oldStaticIp && !staticIp) { message = `Disabled static IP`; // If the staticIp is being disabled but there is no keypair: register to dyndns - if (!db.get('keypair').value()) { + if (!db.get('registeredToDyndns').value()) { await dyndnsClient.updateIp(); message += `, and registered to dyndns: ${db.get('domain').value()}`; } diff --git a/build/src/src/dyndnsClient/updateIp.js b/build/src/src/dyndnsClient/updateIp.js index c0f0f09b..d82576c2 100644 --- a/build/src/src/dyndnsClient/updateIp.js +++ b/build/src/src/dyndnsClient/updateIp.js @@ -80,6 +80,7 @@ function updateIp() { }) .then((domain) => { db.set('domain', domain).write(); + db.set('registeredToDyndns', true).write(); }) .catch((err) => { logs.error(`httpGetRequest error: ${err.stack || err.message}`); From 78bde400d0a152601c8cc3e3cdc7777cf9bb96ba Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 20 Oct 2018 19:18:45 +0200 Subject: [PATCH 2/2] On getParams return staticIp OR domain Not both --- build/src/src/calls/getParams.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/build/src/src/calls/getParams.js b/build/src/src/calls/getParams.js index 535b5931..a57e2b04 100644 --- a/build/src/src/calls/getParams.js +++ b/build/src/src/calls/getParams.js @@ -1,13 +1,19 @@ const db = require('../db'); async function getParams() { + const result = { + ip: db.get('ip').value(), + name: db.get('name').value(), + }; + const staticIp = db.get('staticIp').value(); + const domain = db.get('domain').value(); + if (staticIp) { + result.staticIp = staticIp; + } else { + result.domain = domain; + } return { - result: { - ip: db.get('ip').value(), - name: db.get('name').value(), - staticIp: db.get('staticIp').value(), - domain: db.get('domain').value(), - }, + result, }; }