Skip to content
Snippets Groups Projects
Commit 8d7326d9 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Refactor the get_pw() and get_ticpw() methods

First look for a linked node matching the node address string as passed,
then look for a match using the normalized address (removing .0 and @domain).
The "ALL" wildcard should not be used for password lookups.

This should fix reported issue 240.
parent db78a985
No related branches found
No related tags found
No related merge requests found
...@@ -80,36 +80,24 @@ function SBBSEchoCfg (fname) ...@@ -80,36 +80,24 @@ function SBBSEchoCfg (fname)
} }
SBBSEchoCfg.prototype.get_ticpw = function(node) SBBSEchoCfg.prototype.get_ticpw = function(node)
{ {
if (!fidoaddr.is_valid(node)) throw 'get_ticpw: Invalid address ' + node; var addr = fidoaddr.parse(node);
var n = node; if (!addr) throw new Error('get_ticpw: Invalid address ' + node);
while(n) { if (this.ticpass[node] !== undefined)
if (this.ticpass[n] !== undefined) return this.ticpass[node];
return this.ticpass[n]; node = fidoaddr.to_str(addr);
if (n === 'ALL') if (this.ticpass[node] !== undefined)
break; return this.ticpass[node];
if (n.indexOf('@') !== -1)
n = n.replace(/@.*$/,'');
if (n.indexOf('ALL') !== -1)
n = n.replace(/[0-9]+[^0-9]ALL$/, 'ALL');
else
n = n.replace(/[0-9]+$/, 'ALL');
}
return undefined; return undefined;
}; };
SBBSEchoCfg.prototype.get_pw = function(node) SBBSEchoCfg.prototype.get_pw = function(node)
{ {
if (!fidoaddr.is_valid(node)) throw 'get_pw: Invalid address ' + node; var addr = fidoaddr.parse(node);
var n = node; if (!addr) throw new Error('get_pw: Invalid address ' + node);
while(n) { if (this.pktpass[node] !== undefined)
if (this.pktpass[n] !== undefined) return this.pktpass[node];
return this.pktpass[n]; node = fidoaddr.to_str(addr);
if (n === 'ALL') if (this.pktpass[node] !== undefined)
break; return this.pktpass[node];
if (n.indexOf('ALL') !== -1)
n = n.replace(/[0-9]+[^0-9]ALL$/, 'ALL');
else
n = n.replace(/[0-9]+$/, 'ALL');
}
return undefined; return undefined;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment