Fix TIC node config lookup when wildcards are present

This commit is contained in:
Bryan Ashby 2018-02-10 10:54:04 -07:00
parent 8c7c20862c
commit c26a8872e6
1 changed files with 7 additions and 2 deletions

View File

@ -91,8 +91,13 @@ module.exports = class TicFileInfo {
return callback(Errors.Invalid(`No local area for "Area" of ${area}`)); return callback(Errors.Invalid(`No local area for "Area" of ${area}`));
} }
const from = self.getAsString('From'); const from = Address.fromString(self.getAsString('From'));
localInfo.node = Object.keys(config.nodes).find( nodeAddr => Address.fromString(nodeAddr).isPatternMatch(from) ); if(!from.isValid()) {
return callback(Errors.Invalid(`Invalid "From" address: ${self.getAsString('From')}`));
}
// note that our config may have wildcards, such as "80:774/*"
localInfo.node = Object.keys(config.nodes).find( nodeAddrWildcard => from.isPatternMatch(nodeAddrWildcard) );
if(!localInfo.node) { if(!localInfo.node) {
return callback(Errors.Invalid('TIC is not from a known node')); return callback(Errors.Invalid('TIC is not from a known node'));