mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-26 00:55:08 +01:00
asking for runtime username
This commit is contained in:
@@ -9,6 +9,7 @@ const featureChoices = require(path.join(__dirname, "features.json"));
|
||||
const coinstring = require('coinstring');
|
||||
|
||||
const uaCommentRegexp = /^[a-zA-Z0-9 \.,:_\-\?\/@]+$/; // TODO: look for spec of unsafe chars
|
||||
const userRegexp = /^[a-zA-Z0-9\._\-]+$/;
|
||||
|
||||
const reset = '\u001B8\u001B[u';
|
||||
const clear = '\u001Bc';
|
||||
@@ -75,15 +76,15 @@ module.exports = class extends Generator {
|
||||
if( fs.existsSync(this.destinationPath('config.json')) ) {
|
||||
this.props = require(this.destinationPath('config.json'));
|
||||
} else {
|
||||
this.props = {
|
||||
'derivation_path': '0/n',
|
||||
'installer': 'docker',
|
||||
'devmode': false,
|
||||
'devregistry': false
|
||||
};
|
||||
this.props = {};
|
||||
}
|
||||
|
||||
this.props.derivation_path = this.props.derivation_path || '0/n';
|
||||
this.props.installer = this.props.installer || 'docker';
|
||||
this.props.devmode = this.props.devmode || false;
|
||||
this.props.devregistry = this.props.devregistry || false;
|
||||
this.props.devmode = this.props.devmode || false;
|
||||
this.props.username = this.props.username || 'cyphernode';
|
||||
|
||||
this.featureChoices = featureChoices;
|
||||
for( let c of this.featureChoices ) {
|
||||
@@ -187,6 +188,13 @@ module.exports = class extends Generator {
|
||||
return true;
|
||||
}
|
||||
|
||||
_usernameValidator( user ) {
|
||||
if( !userRegexp.test( user ) ) {
|
||||
throw new Error('Choose a valid username');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
_UACommentValidator( comment ) {
|
||||
if( !uaCommentRegexp.test( comment ) ) {
|
||||
throw new Error('Unsafe characters in UA comment. Please use only a-z, A-Z, 0-9, SPACE and .,:_?@');
|
||||
|
||||
@@ -36,6 +36,14 @@ module.exports = {
|
||||
value: "mainnet"
|
||||
}]
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'username',
|
||||
default: utils._getDefault( 'username' ),
|
||||
message: prefix()+'What username will cyphernode run under?'+'\n',
|
||||
filter: utils._trimFilter,
|
||||
validate: utils._usernameValidator
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'xpub',
|
||||
|
||||
@@ -8,3 +8,4 @@ BITCOIN_DATAPATH=<%= bitcoin_datapath %>
|
||||
LIGHTNING_DATAPATH=<%= lightning_datapath %>
|
||||
PROXY_DATAPATH=<%= proxy_datapath %>
|
||||
DOCKER_MODE=<%= docker_mode %>
|
||||
USERNAME=<%= username %>
|
||||
|
||||
Reference in New Issue
Block a user