Skip to content

Commit

Permalink
Bugfix for connection errors and change config file import logic
Browse files Browse the repository at this point in the history
When going from apiport, routerIP config to just upnp in config file,
It was wiping the old mappings as it detected a port change when there
wasn't. Upon further reflection, there isn't really a good way to
implement this without impacting any existing api / app connections. So
Have removed.

Fixes a logic error with the config file import - on every config
reload, the computed properties were being overwritten. There could have
been edgecases where these properties were needed during the time they
were being re-evaluted. Now only import the initial values and don't
wipe the computed before they are recalculated.
  • Loading branch information
David White committed Jan 27, 2024
1 parent 7ef15df commit 69528f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ZelBack/src/services/fluxportControllerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ async function startGossipServer() {
if (ip && ip !== routerIp) {
log.info(`Gossip server got new routerIp: ${ip}, updating`);
await upnpService.ufwRemoveAllowSsdpforInit();
// This is just good hygiene
await upnpService.cleanOldMappings(ip);
// removed this. Regarding control plane / data plane. If Flux
// control plane goes down, it shouldn't interfere with the data plane.
// This was more aimed at if we have mappings that don't belong to this node.
// Maybe look up the descriptions? or just let them time out...
// await upnpService.cleanOldMappings(ip);
routerIp = ip;
}
});
Expand Down
1 change: 1 addition & 0 deletions ZelBack/src/services/upnpService.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async function ufwRemoveAllowSsdpforInit() {
await cmdAsync(removeAllowSsdpCmd);
return true;
} catch (error) {
// above rule returns 0 for non existent rule so this shouldn't fire unless actual error
log.error(error);
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions apiServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function loadUpnpIfSupported(autoUpnp) {
}

async function SetupPortsUpnpAndComputed() {
userconfig.computed = {};
if (!userconfig.computed) userconfig.computed = {};

const tags = validateTags();
const autoUpnp = userconfig.initial.upnp || false;
Expand Down Expand Up @@ -167,8 +167,10 @@ async function configReload() {
initialHash = hashCurrent;
log.info(`Config file changed, reloading ${event.filename}...`);
delete require.cache[require.resolve('./config/userconfig')];
// only reimport initial - so we don't overwrite computed as other
//routines may be using this
// eslint-disable-next-line
userconfig = require('./config/userconfig');
userconfig.initial = require('./config/userconfig').initial;
await SetupPortsUpnpAndComputed();
}
}
Expand Down

0 comments on commit 69528f8

Please sign in to comment.