mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2026-08-13 12:33:07 +02:00
Add defensive config handling for multi-node settings
This commit is contained in:
parent
bd0f515a6e
commit
df52b9b77f
4 changed files with 36 additions and 36 deletions
|
|
@ -197,26 +197,26 @@ export const getConfig = (req, res, next) => {
|
|||
export const updateNodeSettings = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Node Settings..' });
|
||||
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
|
||||
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
|
||||
const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index));
|
||||
if (node && node.settings) {
|
||||
node.settings = { ...node.settings, ...req.body.settings };
|
||||
if (node.authentication && req.body.authentication) {
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.swapMacaroonPath;
|
||||
try {
|
||||
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
|
||||
const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index));
|
||||
if (node && node.settings) {
|
||||
node.settings = { ...node.settings, ...req.body.settings };
|
||||
if (node.authentication && req.body.authentication) {
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.swapMacaroonPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
|
||||
const selectedNode = common.findNode(req.session.selectedNode.index);
|
||||
if (selectedNode && selectedNode.settings) {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export class CommonService {
|
|||
config.secret2FA = this.appConfig.secret2FA;
|
||||
}
|
||||
const appConfigNodes = new Map(this.appConfig.nodes?.map((node) => [node.index, node]));
|
||||
config.nodes.forEach((node) => {
|
||||
config.nodes?.forEach((node) => {
|
||||
const appConfigNode = appConfigNodes.get(node.index);
|
||||
if (appConfigNode?.authentication) {
|
||||
if (appConfigNode.authentication.macaroonPath) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue