Browse Source

fixed wrong path #2

all-modes
pbca26 8 years ago
parent
commit
f3cdd0ee59
  1. BIN
      assets/bin/linux64/iguana
  2. BIN
      assets/bin/linux64/komodo-cli
  3. BIN
      assets/bin/linux64/komodod
  4. 2
      gui/EasyDEX-GUI
  5. 75
      main.js
  6. 38
      routes/cache.js
  7. 33
      routes/shepherd.js

BIN
assets/bin/linux64/iguana

Binary file not shown.

BIN
assets/bin/linux64/komodo-cli

Binary file not shown.

BIN
assets/bin/linux64/komodod

Binary file not shown.

2
gui/EasyDEX-GUI

@ -1 +1 @@
Subproject commit d48b6500f4eff5e9a1d55490d11e5f1502f647af
Subproject commit 490ddb48a4472dfd9abf8792674a83688fdae0d3

75
main.js

@ -105,7 +105,7 @@ guiapp.use(function(req, res, next) {
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
res.header('Access-Control-Allow-Credentials', 'true');
res.header('Access-Control-Allow-Headers', 'Content-Type');
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS'); // TODO: limit allowed methods
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
next();
});
@ -176,34 +176,6 @@ shepherd.setVar('appBasicInfo', appBasicInfo);
shepherd.setVar('appSessionHash', appSessionHash);
module.exports = guiapp;
// END GUI App Settings
//require('./assets/js/iguana.js'); //below code shall be separated into asset js for public version
/*
// SELECTING IGUANA BUILD TO RUN AS PER OS DETECTED BY DESKTOP APP
var iguanaOSX = path.join(__dirname, '/assets/bin/osx/iguana');
var iguanaLinux = path.join(__dirname, '/assets/bin/linux64/iguana');
var iguanaWin = path.join(__dirname, '/assets/bin/win64/iguana.exe'); iguanaWin = path.normalize(iguanaWin);
var iguanaConfsDirSrc = path.join(__dirname, '/assets/deps/confs');
// SETTING OS DIR TO RUN IGUANA FROM
// SETTING APP ICON FOR LINUX AND WINDOWS
if (os.platform() === 'darwin') {
var iguanaDir = process.env.HOME + '/Library/Application Support/iguana';
var iguanaConfsDir = iguanaDir + '/confs';
}
if (os.platform() === 'linux') {
var iguanaDir = process.env.HOME + '/.iguana'
var iguanaConfsDir = iguanaDir + '/confs';
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon_png/128x128.png')
}
if (os.platform() === 'win32') {
var iguanaDir = process.env.APPDATA + '/iguana'; iguanaDir = path.normalize(iguanaDir)
var iguanaConfsDir = process.env.APPDATA + '/iguana/confs'; iguanaConfsDir = path.normalize(iguanaConfsDir)
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico')
iguanaConfsDirSrc = path.normalize(iguanaConfsDirSrc);
}
*/
if (os.platform() === 'linux') {
var iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png');
@ -212,26 +184,6 @@ if (os.platform() === 'win32') {
var iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico');
}
//console.log(iguanaDir);
/*
// MAKE SURE IGUANA DIR IS THERE FOR USER
mkdirp(iguanaDir, function (err) {
if (err)
console.error(err)
else
fs.readdir(iguanaDir, (err, files) => {
files.forEach(file => {
//console.log(file);
});
})
});
// COPY CONFS DIR WITH PEERS FILE TO IGUANA DIR, AND KEEP IT IN SYNC
fs.copy(iguanaConfsDirSrc, iguanaConfsDir, function (err) {
if (err) return console.error(err)
console.log('confs files copied successfully at: '+ iguanaConfsDir )
})
*/
let mainWindow;
let loadingWindow;
@ -256,7 +208,7 @@ function createLoadingWindow() {
shepherd.writeLog('show loading window');
// DEVTOOLS - only for dev purposes - ca333
//loadingWindow.webContents.openDevTools()
// loadingWindow.webContents.openDevTools()
// if window closed we kill iguana proc
loadingWindow.on('hide', function () {
@ -304,25 +256,6 @@ function createLoadingWindow() {
});
}
});
//ca333 todo - add os detector to use correct binary - so we can use the same bundle on ALL OS platforms
/*if (os.platform() === 'win32') {
process.chdir(iguanaDir);
//exec(iguanaWin, {cwd: iguanaDir}); //specify binary in startup
ig = spawn(iguanaWin);
}
if (os.platform() === 'linux') {
process.chdir(iguanaDir);
ig = spawn(iguanaLinux);
//corsproxy_process = spawn('corsproxy');
}
if (os.platform() === 'darwin') {
//process.chdir(iguanaDir);
//ig = spawn(iguanaOSX);
//corsproxy_process = spawn('corsproxy');
}*/
//if (os.platform() !== 'win32') { ig.stderr.on( 'error: ', data => { console.log( `stderr: ${data}` ); }); }
}
app.on('ready', createLoadingWindow);
@ -365,7 +298,7 @@ function createWindow (status) {
if (appConfig.edexGuiOnly) {
if (appConfig.v2) {
shepherd.writeLog('show edex gui');
// mainWindow.loadURL('http://127.0.0.1:3000');
//mainWindow.loadURL('http://127.0.0.1:3000');
mainWindow.appConfig = appConfig;
mainWindow.appSessionHash = appSessionHash;
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.agamaPort + '/gui/EasyDEX-GUI/react/build');
@ -388,7 +321,7 @@ function createWindow (status) {
});
// DEVTOOLS - only for dev purposes - ca333
//mainWindow.webContents.openDevTools()
// mainWindow.webContents.openDevTools()
function pm2Exit() {
var ConnectToPm2 = function() {

38
routes/cache.js

@ -252,13 +252,6 @@ checkCallStack = function() {
if (total / Object.keys(callStack).length === 1) {
cache.dumpCacheBeforeExit();
/*fs.writeFile(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json', JSON.stringify(inMemCache), function(err) {
if (err) {
return console.log(err);
}
console.log('file ' + cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json is updated');
});*/
cacheCallInProgress = false;
cache.io.emit('messages', {
'message': {
@ -269,8 +262,6 @@ checkCallStack = function() {
}
}
});
// add timestamp to cache file
// writeCache(Date.now());
}
};
@ -279,7 +270,8 @@ checkCallStack = function() {
* params: userpass, pubkey, coin, address, skip
*/
cache.one = function(req, res, next) {
if (req.query.pubkey && !fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + req.query.pubkey + '.json')) {
if (req.query.pubkey &&
!fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + req.query.pubkey + '.json')) {
cacheCallInProgress = false;
}
@ -394,7 +386,8 @@ cache.one = function(req, res, next) {
outObj = fixJSON(_file);
}
if (!outObj || !outObj.basilisk) {
if (!outObj ||
!outObj.basilisk) {
console.log('no local basilisk info');
outObj['basilisk'] = {};
outObj['basilisk'][coin] = {};
@ -503,7 +496,9 @@ cache.one = function(req, res, next) {
url: mock ? 'http://localhost:17777/shepherd/mock?url=' + dexUrl : dexUrl,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
cache.io.emit('messages', {
'message': {
'shepherd': {
@ -542,7 +537,9 @@ cache.one = function(req, res, next) {
writeCache();
}
if (error || !body || !response) {
if (error ||
!body ||
!response) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].data = { 'error': 'request failed' };
outObj.basilisk[coin][address][key].timestamp = 1471620867 // add timestamp
@ -635,12 +632,14 @@ cache.one = function(req, res, next) {
if (addresses) {
parseAddresses(coin, addresses);
} else {
const tempUrl = 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort /*iguanaCorePort*/ + '/api/bitcoinrpc/getaddressesbyaccount?userpass=' + sessionKey + '&coin=' + coin + '&account=*';
const tempUrl = 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/bitcoinrpc/getaddressesbyaccount?userpass=' + sessionKey + '&coin=' + coin + '&account=*';
request({
url: mock ? 'http://localhost:17777/shepherd/mock?url=' + tempUrl : tempUrl,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
parseAddresses(coin, JSON.parse(body).result);
} else {
// TODO: error
@ -666,12 +665,14 @@ cache.one = function(req, res, next) {
});
if (coin === 'all') {
const tempUrl = 'http://' + cache.appConfig.host + ':' + /*iguanaCorePort*/ cache.appConfig.iguanaCorePort + '/api/InstantDEX/allcoins?userpass=' + sessionKey;
const tempUrl = 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/InstantDEX/allcoins?userpass=' + sessionKey;
request({
url: mock ? 'http://localhost:17777/shepherd/mock?url=' + tempUrl : tempUrl,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
console.log(JSON.parse(body).basilisk);
cache.io.emit('messages', {
'message': {
@ -688,7 +689,8 @@ cache.one = function(req, res, next) {
});
body = JSON.parse(body);
// basilisk coins
if (body.basilisk && body.basilisk.length) {
if (body.basilisk &&
body.basilisk.length) {
// get coin addresses
async.each(body.basilisk, function(coin) {
callStack[coin] = 1;

33
routes/shepherd.js

@ -43,20 +43,19 @@ if (os.platform() === 'darwin') {
iguanaConfsDir = iguanaDir + '/confs',
komododBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/osx/komodod'),
komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/osx/komodo-cli'),
komodoDir = process.env.HOME + '/Library/Application Support/Komodo';
komodoDir = process.env.HOME + '/Library/Application Support/Komodo',
zcashdBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcashd',
zcashcliBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcash-cli',
zcashDir = process.env.HOME + '/Library/Application Support/Zcash';
}
if (os.platform() === 'linux') {
var iguanaBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux64/iguana'),
var iguanaBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux/iguana'),
iguanaDir = process.env.HOME + '/.iguana',
iguanaConfsDir = iguanaDir + '/confs',
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png'),
komododBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux64/komodod'),
komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux64/komodo-cli'),
komododBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux/komodod'),
komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/linux/komodo-cli'),
komodoDir = process.env.HOME + '/.komodo';
}
@ -69,7 +68,7 @@ if (os.platform() === 'win32') {
iguanaConfsDir = path.normalize(iguanaConfsDir);
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico'),
iguanaConfsDirSrc = path.normalize(iguanaConfsDirSrc),
komododBin = path.join(__dirname, '../assets/bin/win64/komodod.exe'),
komododBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/komodod.exe'),
komododBin = path.normalize(komododBin),
komodocliBin = path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/komodo-cli.exe'),
komodocliBin = path.normalize(komodocliBin),
@ -478,7 +477,9 @@ shepherd.getSyncOnlyForksInfo = function() {
url: 'http://localhost:' + port + '/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@' + shepherd.appSessionHash,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
// console.log(body);
try {
syncOnlyIguanaInstanceInfo[port].getinfo = JSON.parse(body);
@ -491,7 +492,9 @@ shepherd.getSyncOnlyForksInfo = function() {
url: 'http://localhost:' + port + '/api/SuperNET/activehandle?userpass=' + shepherd.appSessionHash,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
if (response &&
response.statusCode &&
response.statusCode === 200) {
// console.log(body);
try {
syncOnlyIguanaInstanceInfo[port].activehandle = JSON.parse(body);
@ -844,8 +847,10 @@ shepherd.post('/setconf', function(req, res) {
console.log('======= req.body =======');
console.log(req.body);
if (os.platform() === 'win32' && req.body.chain == 'komodod') {
if (os.platform() === 'win32' &&
req.body.chain == 'komodod') {
setkomodoconf = spawn(path.join(__dirname, '../build/artifacts.supernet.org/latest/windows/genkmdconf.bat'));
setkomodoconf = spawn(path.join(__dirname, '../assets/bin/win64/genkmdconf.bat'));
} else {
setConf(req.body.chain);
}
@ -981,7 +986,8 @@ shepherd.get('/kick', function(req, res, next) {
]
};
if (_coin && _type) {
if (_coin &&
_type) {
for (var i = 0; i < kickStartDirs[_type].length; i++) {
var currentKickItem = kickStartDirs[_type][i];
@ -995,7 +1001,8 @@ shepherd.get('/kick', function(req, res, next) {
} else if (currentKickItem.type === 'pattern') {
var dirItems = fs.readdirSync(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin));
if (dirItems && dirItems.length) {
if (dirItems &&
dirItems.length) {
for (var j = 0; j < dirItems.length; j++) {
if (dirItems[j].indexOf(currentKickItem.match) > -1) {
rimraf(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin) + '/' + dirItems[j], function(err) {
@ -1048,7 +1055,7 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) {
};
function herder(flock, data) {
if (data == undefined) {
if (data === undefined) {
data = 'none';
console.log('it is undefined');
}
@ -1295,7 +1302,7 @@ shepherd.setConfKMD = function() {
_fs.access(komodoDir + '/komodo.conf', fs.constants.R_OK, function(err) {
if (err) {
console.log('creating komodo conf');
shepherd.writeLog('creating komodo conf in ' + komodoDir + '/komodo.conf');
shepherd.writeLog('creating komodo conf in ' + komodoDir + '/komodo.conf');
setConf('komodod');
} else {
shepherd.writeLog('komodo conf exists');

Loading…
Cancel
Save