|
@ -107,7 +107,7 @@ shepherd.zcashParamsExist = function() { |
|
|
shepherd.readVersionFile = function() { |
|
|
shepherd.readVersionFile = function() { |
|
|
// read app version
|
|
|
// read app version
|
|
|
const rootLocation = path.join(__dirname, '../'); |
|
|
const rootLocation = path.join(__dirname, '../'); |
|
|
const localVersionFile = fs.readFileSync(rootLocation + 'version', 'utf8'); |
|
|
const localVersionFile = fs.readFileSync(`${rootLocation}version`, 'utf8'); |
|
|
|
|
|
|
|
|
return localVersionFile; |
|
|
return localVersionFile; |
|
|
} |
|
|
} |
|
@ -187,8 +187,6 @@ shepherd.post('/encryptkey', function(req, res, next) { |
|
|
const _pin = req.body.key; |
|
|
const _pin = req.body.key; |
|
|
const _pinTest = _pin.match('^(?=.*[A-Z])(?=.*[^<>{}\"/|;:.,~!?@#$%^=&*\\]\\\\()\\[_+]*$)(?=.*[0-9])(?=.*[a-z]).{8}$'); |
|
|
const _pinTest = _pin.match('^(?=.*[A-Z])(?=.*[^<>{}\"/|;:.,~!?@#$%^=&*\\]\\\\()\\[_+]*$)(?=.*[0-9])(?=.*[a-z]).{8}$'); |
|
|
|
|
|
|
|
|
console.log(_pinTest); |
|
|
|
|
|
|
|
|
|
|
|
fs.writeFile(`${iguanaDir}/shepherd/pin/${req.body.pubkey}.pin`, encryptedString, function (err) { |
|
|
fs.writeFile(`${iguanaDir}/shepherd/pin/${req.body.pubkey}.pin`, encryptedString, function (err) { |
|
|
if (err) { |
|
|
if (err) { |
|
|
console.log('error writing pin file'); |
|
|
console.log('error writing pin file'); |
|
@ -1567,31 +1565,55 @@ shepherd.post('/herd', function(req, res) { |
|
|
console.log('======= req.body ======='); |
|
|
console.log('======= req.body ======='); |
|
|
console.log(req.body); |
|
|
console.log(req.body); |
|
|
|
|
|
|
|
|
herder(req.body.herd, req.body.options); |
|
|
function testCoindPort() { |
|
|
|
|
|
const _port = assetChainPorts[req.body.options.ac_name]; |
|
|
|
|
|
|
|
|
const obj = { |
|
|
portscanner.checkPortStatus(_port, '127.0.0.1', function(error, status) { |
|
|
msg: 'success', |
|
|
// Status is 'open' if currently in use or 'closed' if available
|
|
|
result: 'result', |
|
|
if (status === 'open') { |
|
|
}; |
|
|
console.log(`komodod service start error at port ${_port}, reason: port is closed`); |
|
|
|
|
|
shepherd.writeLog(`komodod service start error at port ${_port}, reason: port is closed`); |
|
|
|
|
|
cache.io.emit('service', { |
|
|
|
|
|
komodod: { |
|
|
|
|
|
error: 'error starting ' + req.body.herd + ' ' + req.body.options.ac_name + ' daemon. Port ' + _port + ' is already taken!', |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
res.end(JSON.stringify(obj)); |
|
|
const obj = { |
|
|
|
|
|
msg: 'error', |
|
|
|
|
|
result: 'error starting ' + req.body.herd + ' ' + req.body.options.ac_name + ' daemon. Port ' + _port + ' is already taken!', |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
res.status(500); |
|
|
|
|
|
res.end(JSON.stringify(obj)); |
|
|
|
|
|
} else { |
|
|
|
|
|
herder(req.body.herd, req.body.options); |
|
|
|
|
|
|
|
|
|
|
|
const obj = { |
|
|
|
|
|
msg: 'success', |
|
|
|
|
|
result: 'result', |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
res.end(JSON.stringify(obj)); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (req.body.herd === 'komodod') { |
|
|
if (req.body.herd === 'komodod') { |
|
|
const _port = assetChainPorts[req.body.options.ac_name]; |
|
|
|
|
|
// check if komodod instance is already running
|
|
|
// check if komodod instance is already running
|
|
|
|
|
|
testCoindPort(); |
|
|
setTimeout(function() { |
|
|
setTimeout(function() { |
|
|
portscanner.checkPortStatus(_port, '127.0.0.1', function(error, status) { |
|
|
testCoindPort(); |
|
|
// Status is 'open' if currently in use or 'closed' if available
|
|
|
|
|
|
if (status === 'closed') { |
|
|
|
|
|
shepherd.writeLog(`komodod service start error at port ${_port}, reason: port is closed`); |
|
|
|
|
|
cache.io.emit('service', { |
|
|
|
|
|
komodod: { |
|
|
|
|
|
error: 'start error', |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, 10000); |
|
|
}, 10000); |
|
|
|
|
|
} else { |
|
|
|
|
|
herder(req.body.herd, req.body.options); |
|
|
|
|
|
|
|
|
|
|
|
const obj = { |
|
|
|
|
|
msg: 'success', |
|
|
|
|
|
result: 'result', |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
res.end(JSON.stringify(obj)); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -1797,7 +1819,7 @@ shepherd.get('/kick', function(req, res, next) { |
|
|
console.log('deleting ' + currentKickItem.type + (currentKickItem.match ? ' ' + currentKickItem.match : '') + ' ' + iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin)); |
|
|
console.log('deleting ' + currentKickItem.type + (currentKickItem.match ? ' ' + currentKickItem.match : '') + ' ' + iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin)); |
|
|
if (currentKickItem.type === 'folder' || |
|
|
if (currentKickItem.type === 'folder' || |
|
|
currentKickItem.type === 'file') { |
|
|
currentKickItem.type === 'file') { |
|
|
rimraf(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin), function(err) { |
|
|
rimraf(`${iguanaDir}/${currentKickItem.name.replace('[coin]', _coin)}`, function(err) { |
|
|
if (err) { |
|
|
if (err) { |
|
|
throw err; |
|
|
throw err; |
|
|
} |
|
|
} |
|
@ -1919,7 +1941,7 @@ function herder(flock, data) { |
|
|
name: 'IGUANA', |
|
|
name: 'IGUANA', |
|
|
exec_mode : 'fork', |
|
|
exec_mode : 'fork', |
|
|
args: [`-port=${shepherd.appConfig.iguanaCorePort}`], |
|
|
args: [`-port=${shepherd.appConfig.iguanaCorePort}`], |
|
|
cwd: iguanaDir //set correct iguana directory
|
|
|
cwd: iguanaDir // set correct iguana directory
|
|
|
}, function(err, apps) { |
|
|
}, function(err, apps) { |
|
|
iguanaInstanceRegistry[shepherd.appConfig.iguanaCorePort] = { |
|
|
iguanaInstanceRegistry[shepherd.appConfig.iguanaCorePort] = { |
|
|
mode: 'main', |
|
|
mode: 'main', |
|
@ -1930,11 +1952,11 @@ function herder(flock, data) { |
|
|
shepherd.writeLog(`iguana core started at port ${shepherd.appConfig.iguanaCorePort} pid ${apps[0].process.pid}`); |
|
|
shepherd.writeLog(`iguana core started at port ${shepherd.appConfig.iguanaCorePort} pid ${apps[0].process.pid}`); |
|
|
|
|
|
|
|
|
pm2.disconnect(); // Disconnect from PM2
|
|
|
pm2.disconnect(); // Disconnect from PM2
|
|
|
if (err) { |
|
|
if (err) { |
|
|
shepherd.writeLog(`iguana core port ${shepherd.appConfig.iguanaCorePort}`); |
|
|
shepherd.writeLog(`iguana core port ${shepherd.appConfig.iguanaCorePort}`); |
|
|
console.log(`iguana fork error: ${err}`); |
|
|
console.log(`iguana fork error: ${err}`); |
|
|
throw err; |
|
|
throw err; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|