hosts in validator can now be ip address or fully qualified domain names

This commit is contained in:
jash
2018-10-06 23:01:39 +02:00
committed by kexkey
parent 2bd641285b
commit e205dfa7dc
3 changed files with 11 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ module.exports = {
type: 'input',
name: 'bitcoin_node_ip',
default: utils._getDefault( 'bitcoin_node_ip' ),
validate: utils._ipValidator,
validate: utils._ipOrFQDNValidator,
message: 'What is your full node ip address?'+'\n',
},
{

View File

@@ -30,7 +30,7 @@ module.exports = {
type: 'input',
name: 'lightning_external_ip',
default: utils._getDefault( 'lightning_external_ip' ),
validate: utils._ipValidator,
validate: utils._ipOrFQDNValidator,
message: 'What external ip does your lightning node have?'+'\n',
}];
},

View File

@@ -73,8 +73,15 @@ module.exports = class extends Generator {
return this.props && this.props[name];
}
_ipValidator( ip ) {
return validator.isIP((ip+"").trim());
_ipOrFQDNValidator( host ) {
host = (host+"").trim();
if( !(validator.isIP(host) ||
validator.isFQDN(host)) ) {
throw new Error( 'No IP address or fully qualified domain name' )
}
return true;
}
_xkeyValidator( xpub ) {