Browse Source

Merge branch 'master' of https://github.com/SuperNETorg/Agama

Conflicts:
	assets/BitRock Installer Files/IgaunaApp-Linux.xml
	assets/BitRock Installer Files/IgaunaApp-OSX.xml
	assets/BitRock Installer Files/IgaunaApp-Win.xml
all-modes
Predrag Manojlovic 8 years ago
parent
commit
ece1a012b2
  1. 8
      .gitignore
  2. 3
      .gitmodules
  3. 36
      README.md
  4. 70
      assets/BitRock Installer Files/IgaunaApp-Linux.xml
  5. 22
      assets/BitRock Installer Files/IgaunaApp-OSX.xml
  6. 118
      assets/BitRock Installer Files/IgaunaApp-Win.xml
  7. BIN
      assets/bin/linux64/iguana
  8. BIN
      assets/bin/linux64/komodo-cli
  9. BIN
      assets/bin/linux64/komodod
  10. BIN
      assets/bin/osx/iguana
  11. BIN
      assets/bin/osx/komodo-cli
  12. BIN
      assets/bin/osx/komodod
  13. BIN
      assets/bin/osx/libgcc_s.1.dylib
  14. BIN
      assets/bin/osx/libgomp.1.dylib
  15. BIN
      assets/bin/osx/libstdc++.6.dylib
  16. 19
      assets/bin/win64/genkmdconf.bat
  17. BIN
      assets/bin/win64/iguana.exe
  18. BIN
      assets/bin/win64/komodo-cli.exe
  19. BIN
      assets/bin/win64/komodod.exe
  20. BIN
      assets/bin/win64/libcrypto-1_1.dll
  21. BIN
      assets/bin/win64/libcurl-4.dll
  22. BIN
      assets/bin/win64/libcurl.dll
  23. BIN
      assets/bin/win64/libgcc_s_sjlj-1.dll
  24. BIN
      assets/bin/win64/libnanomsg.dll
  25. BIN
      assets/bin/win64/libssl-1_1.dll
  26. BIN
      assets/bin/win64/libwinpthread-1.dll
  27. 0
      assets/bin/win64/nanomsg.dll
  28. 0
      assets/bin/win64/pthreadvc2.dll
  29. 2
      assets/deps/confs/KMD_peers.txt
  30. BIN
      assets/icons/agama_icons/128x128.png
  31. BIN
      assets/icons/agama_icons/16x16.png
  32. BIN
      assets/icons/agama_icons/24x24.png
  33. BIN
      assets/icons/agama_icons/256x256.png
  34. BIN
      assets/icons/agama_icons/32x32.png
  35. BIN
      assets/icons/agama_icons/48x48.png
  36. BIN
      assets/icons/agama_icons/64x64.png
  37. BIN
      assets/icons/agama_icons/96x96.png
  38. BIN
      assets/icons/agama_icons/agama_app_icon.icns
  39. BIN
      assets/icons/agama_icons/agama_app_icon.ico
  40. BIN
      assets/installer_imgs/Agama_installer_splash_image.png
  41. BIN
      assets/installer_imgs/Agama_installer_wizard_image.png
  42. BIN
      assets/installer_imgs/supernet-agama-logo.png
  43. 17
      buildscripts/electron-build-all.sh
  44. 16
      buildscripts/electron-build-linux.sh
  45. 12
      buildscripts/electron-build-osx.sh
  46. 18
      buildscripts/electron-build-win.sh
  47. 14
      check_submodule.sh
  48. 10
      compile-dev.sh
  49. 1
      gui/EasyDEX-GUI
  50. 2
      gui/init.js
  51. 15
      gui/loading.css
  52. 41
      gui/loading.js
  53. 520
      main.js
  54. 18
      package.json
  55. 9
      private/mainmenu.js
  56. 36
      pull-gui.sh
  57. 589
      routes/cache.js
  58. 39
      routes/mock.js
  59. 635
      routes/shepherd.js

8
.gitignore

@ -47,11 +47,5 @@ genesis
DB
coins
# Ignore all EasyDEX-GUI subfolder files, except README
EasyDEX-GUI
Iguana-GUI
#EasyDEX-GUI/*
#!EasyDEX-GUI/README
# Electron-builder related folders
build
build

3
.gitmodules

@ -0,0 +1,3 @@
[submodule "gui/EasyDEX-GUI"]
path = gui/EasyDEX-GUI
url = https://github.com/SuperNETorg/EasyDEX-GUI.git

36
README.md

@ -1,33 +1,31 @@
# Iguana Desktop App
# Agama Desktop App
Desktop App for SuperNET DAPPs
#### For Developers
You must have `node.js` and `npm` installed on your machine.
Clone Iguana Desktop App
Clone Agama Desktop App with EasyDEX-GUI submodule
```shell
git clone https://github.com/SuperNETorg/iguana.git
git clone --recursive https://github.com/SuperNETorg/Agama.git
cd gui/EasyDEX-GUI/
git checkout master
git pull
cd ../../
```
Please clone EasyDEX-GUI from github repo here.
```shell
cd gui
git clone https://github.com/SuperNETorg/EasyDEX-GUI.git
```
Install Iguana App
Install Agama App
```shell
cd iguana
npm install
```
Then start Iguana App
Then start Agama App
```shell
npm start
```
#### For end users
The instructions to make production build of Iguana App will be updated soon.
The instructions to make production build of Agama App will be updated soon.
To build the production ready app, install `electron-packager` and `electron-prebuilt` packages from npm
```shell
@ -42,7 +40,7 @@ Refer to the original [electron-packager](https://github.com/electron-userland/e
Change directory to iguana and execute the following command to build the Linux app
```shell
cd iguana
electron-packager . --platform=linux --arch=x64 --icon=assets/icons/iguana_app_icon_png/128x128.png --out=build/ --overwrite
electron-packager . --platform=linux --arch=x64 --icon=assets/icons/agama_icons/128x128.png --out=build/ --buildVersion=VERSION_NUMBER_HERE --ignore=assets/bin/win64 --ignore=assets/bin/osx --overwrite
```
change architecture build parameter to ```--arch=x32``` for 32 bit build
@ -50,14 +48,20 @@ change architecture build parameter to ```--arch=x32``` for 32 bit build
Change directory to iguana and execute the following command to build the OSX app
```shell
cd iguana
electron-packager . --platform=darwin --arch=x64 --icon=assets/icons/iguana_app_icon.icns --out=build/ --overwrite
electron-packager . --platform=darwin --arch=x64 --icon=assets/icons/agama_icons/agama_app_icon.icns --out=build/ --buildVersion=VERSION_NUMBER_HERE --ignore=assets/bin/win64 --ignore=assets/bin/linux64 --overwrite
```
##### Windows
Change directory to iguana and execute the following command to build the Windows app
```shell
dir iguana
electron-packager . --platform=win32 --arch=x64 --icon=assets/icons/iguana_app_icon.ico --out=build/ --overwrite
electron-packager . --platform=win32 --arch=x64 --icon=assets/icons/agama_icons/agama_app_icon.ico --out=build/ --buildVersion=VERSION_NUMBER_HERE --ignore=assets/bin/osx --ignore=assets/bin/linux64 --overwrite
# If generating 32bit desktop package
electron-packager . --platform=win32 --arch=ia32 --icon=assets/icons/agama_icons/agama_app_icon.ico --out=build/ --buildVersion=VERSION_NUMBER_HERE --ignore=assets/bin/osx --ignore=assets/bin/linux64 --overwrite
# To build both x64 and x86 desktop package
electron-packager . --platform=win32 --arch=all --icon=assets/icons/agama_icons/agama_app_icon.ico --out=build/ --buildVersion=VERSION_NUMBER_HERE --ignore=assets/bin/osx --ignore=assets/bin/linux64 --overwrite
```
change architecture build parameter to ```--arch=x64``` for 64 bit build
@ -67,4 +71,4 @@ change architecture build parameter to ```--arch=x64``` for 64 bit build
### Windows DLL issues
On Windows it's noticed iguana.exe complains about `VCRUNTIME140D.DLL` and `ucrtbased.dll` file.
Please see **windeps** directory and README file for instructions to install the required DLL files on Windows, and then try again running Iguana App.
Please see **windeps** directory and README file for instructions to install the required DLL files on Windows, and then try again running Agama App.

70
assets/BitRock Installer Files/IgaunaApp-Linux.xml

@ -1,11 +1,11 @@
<project>
<shortName>IguanaApp</shortName>
<shortName>AgamaApp</shortName>
<fullName>iguana</fullName>
<version>0.1.4.1-beta</version>
<version>0.1.6.1e-beta</version>
<licenseFile>../../LICENSE</licenseFile>
<leftImage>../installer_imgs/Iguana_installer_wizard_image.png</leftImage>
<logoImage>../installer_imgs/supernet-iguana-logo.png</logoImage>
<splashImage>../installer_imgs/Iguana_installer_splash_image.png</splashImage>
<leftImage>../installer_imgs/Agama_installer_wizard_image.png</leftImage>
<logoImage>../installer_imgs/supernet-agama-logo.png</logoImage>
<splashImage>../installer_imgs/Agama_installer_splash_image.png</splashImage>
<allowLanguageSelection>1</allowLanguageSelection>
<componentList>
<component>
@ -17,10 +17,10 @@
<show>1</show>
<desktopShortcutList>
<shortcut>
<comment>Iguana Desktop</comment>
<exec>${installdir}/Iguana</exec>
<icon>${installdir}/resources/app/assets/icons/iguana_app_icon_png/96x96.png</icon>
<name>Iguana Desktop</name>
<comment>Agama Desktop</comment>
<exec>${installdir}/Agama</exec>
<icon>${installdir}/resources/app/assets/icons/agama_icons/96x96.png</icon>
<name>Agama Desktop</name>
<path>${installdir}</path>
<platforms>all</platforms>
<runAsAdmin>0</runAsAdmin>
@ -39,52 +39,52 @@
<platforms>all</platforms>
<distributionFileList>
<distributionDirectory>
<origin>../../build/Iguana-linux-x64/locales</origin>
<origin>../../build/Agama-linux-x64/locales</origin>
</distributionDirectory>
<distributionDirectory>
<origin>../../build/Iguana-linux-x64/resources</origin>
<origin>../../build/Agama-linux-x64/resources</origin>
</distributionDirectory>
<distributionFile>
<origin>../../build/Iguana-linux-x64/version</origin>
<origin>../../build/Agama-linux-x64/version</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/content_resources_200_percent.pak</origin>
<origin>../../build/Agama-linux-x64/content_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/LICENSE</origin>
<origin>../../build/Agama-linux-x64/LICENSE</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/blink_image_resources_200_percent.pak</origin>
<origin>../../build/Agama-linux-x64/blink_image_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/views_resources_200_percent.pak</origin>
<origin>../../build/Agama-linux-x64/views_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/ui_resources_200_percent.pak</origin>
<origin>../../build/Agama-linux-x64/ui_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/natives_blob.bin</origin>
<origin>../../build/Agama-linux-x64/natives_blob.bin</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/snapshot_blob.bin</origin>
<origin>../../build/Agama-linux-x64/snapshot_blob.bin</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/LICENSES.chromium.html</origin>
<origin>../../build/Agama-linux-x64/LICENSES.chromium.html</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/libffmpeg.so</origin>
<origin>../../build/Agama-linux-x64/libffmpeg.so</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/content_shell.pak</origin>
<origin>../../build/Agama-linux-x64/content_shell.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/icudtl.dat</origin>
<origin>../../build/Agama-linux-x64/icudtl.dat</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/libnode.so</origin>
<origin>../../build/Agama-linux-x64/libnode.so</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-linux-x64/Iguana</origin>
<origin>../../build/Agama-linux-x64/Agama</origin>
</distributionFile>
</distributionFileList>
</folder>
@ -293,23 +293,23 @@
<postInstallationActionList>
<createSymLink>
<abortOnError>0</abortOnError>
<linkName>/bin/Iguana</linkName>
<target>${installdir}/Iguana</target>
<linkName>/bin/Agama</linkName>
<target>${installdir}/Agama</target>
</createSymLink>
<iniFileSet>
<file>/root/Desktop/Iguana Desktop.desktop</file>
<file>${user_home_directory}/Desktop/Agama Desktop.desktop</file>
<key>Categories</key>
<section>Desktop Entry</section>
<value>Office;</value>
</iniFileSet>
<changeOwnerAndGroup>
<files>${user_home_directory}/Desktop/Iguana Desktop.desktop</files>
<files>${user_home_directory}/Desktop/Agama Desktop.desktop</files>
<group>users</group>
<owner>nobody</owner>
</changeOwnerAndGroup>
<copyFile>
<destination>/usr/share/applications/Iguana Desktop.desktop</destination>
<origin>/root/Desktop/Iguana Desktop.desktop</origin>
<destination>/usr/share/applications/Agama Desktop.desktop</destination>
<origin>${user_home_directory}/Desktop/Agama Desktop.desktop</origin>
</copyFile>
<!-- Store values of current installer in etc folder so we can find for uninstal -->
@ -333,7 +333,7 @@
<postUninstallationActionList>
<deleteFile>
<abortOnError>0</abortOnError>
<path>/bin/Iguana</path>
<path>/bin/Agama</path>
</deleteFile>
</postUninstallationActionList>
<allowComponentSelection>1</allowComponentSelection>
@ -344,11 +344,11 @@
<enableTimestamp>1</enableTimestamp>
<requireInstallationByRootUser>1</requireInstallationByRootUser>
<saveRelativePaths>1</saveRelativePaths>
<uninstallerName>Uninstall-Iguana</uninstallerName>
<uninstallerName>Uninstall-Agama</uninstallerName>
<vendor>SuperNETOrg</vendor>
<finalPageActionList>
<runProgram>
<program>/bin/Iguana</program>
<program>/bin/Agama</program>
<programArguments>&amp;</programArguments>
<progressText>Do you want to launch ${project.fullName} now?</progressText>
<runAs>$USER</runAs>
@ -360,7 +360,7 @@
<description>Installer.Parameter.installdir.description</description>
<explanation>Installer.Parameter.installdir.explanation</explanation>
<value></value>
<default>/opt/IguanaApp</default>
<default>/opt/AgamaApp</default>
<allowEmptyValue>0</allowEmptyValue>
<cliOptionName>prefix</cliOptionName>
<mustBeWritable>1</mustBeWritable>

22
assets/BitRock Installer Files/IgaunaApp-OSX.xml

@ -1,11 +1,11 @@
<project>
<shortName>IguanaApp</shortName>
<shortName>AgamaApp</shortName>
<fullName>iguana</fullName>
<version>0.1.4-beta</version>
<version>0.1.6.0e-beta</version>
<licenseFile>../../LICENSE</licenseFile>
<leftImage>../installer_imgs/Iguana_installer_wizard_image.png</leftImage>
<logoImage>../installer_imgs/supernet-iguana-logo.png</logoImage>
<splashImage>../installer_imgs/Iguana_installer_splash_image.png</splashImage>
<leftImage>../installer_imgs/Agama_installer_wizard_image.png</leftImage>
<logoImage>../installer_imgs/supernet-agama-logo.png</logoImage>
<splashImage>../installer_imgs/Agama_installer_splash_image.png</splashImage>
<allowLanguageSelection>1</allowLanguageSelection>
<componentList>
<component>
@ -41,7 +41,7 @@
<platforms>osx</platforms>
<distributionFileList>
<distributionFile>
<origin>../../build/Iguana-darwin-x64/Iguana.app</origin>
<origin>../../build/Agama-darwin-x64/Agama.app</origin>
</distributionFile>
</distributionFileList>
</folder>
@ -96,7 +96,7 @@
</runProgram>
<deleteFile>
<explanation>Deleting user data</explanation>
<path>${user_home_directory}/.iguana</path>
<path>${user_home_directory}/Library/Application Support/Iguana</path>
<progressText>Deleting user data</progressText>
<ruleList>
<compareValues>
@ -140,7 +140,7 @@
</deleteFile>
<deleteFile>
<explanation>Deleting user settngs</explanation>
<path>${user_home_directory}/.config/Iguana</path>
<path>${user_home_directory}/Library/Application Support/Agama</path>
<progressText>Deleting user settngs</progressText>
<ruleList>
<compareValues>
@ -254,13 +254,13 @@
<enableTimestamp>1</enableTimestamp>
<requireInstallationByRootUser>1</requireInstallationByRootUser>
<saveRelativePaths>1</saveRelativePaths>
<uninstallerDirectory>${installdir}/Iguana/</uninstallerDirectory>
<uninstallerName>Uninstall-Iguana</uninstallerName>
<uninstallerDirectory>${installdir}/Agama/</uninstallerDirectory>
<uninstallerName>Uninstall-Agama.app</uninstallerName>
<vendor>SuperNETOrg</vendor>
<finalPageActionList>
<runProgram>
<program>open</program>
<programArguments>/Applications/Iguana.app</programArguments>
<programArguments>/Applications/Agama.app</programArguments>
<progressText>Do you want to launch ${project.fullName} now?</progressText>
</runProgram>
</finalPageActionList>

118
assets/BitRock Installer Files/IgaunaApp-Win.xml

@ -1,11 +1,11 @@
<project>
<shortName>IguanaApp</shortName>
<shortName>AgamaApp</shortName>
<fullName>iguana</fullName>
<version>0.1.4-beta</version>
<version>0.1.6e-beta</version>
<licenseFile>../../LICENSE</licenseFile>
<leftImage>../installer_imgs/Iguana_installer_wizard_image.png</leftImage>
<logoImage>../installer_imgs/supernet-iguana-logo.png</logoImage>
<splashImage>../installer_imgs/Iguana_installer_splash_image.png</splashImage>
<leftImage>../installer_imgs/Agama_installer_wizard_image.png</leftImage>
<logoImage>../installer_imgs/supernet-agama-logo.png</logoImage>
<splashImage>../installer_imgs/Agama_installer_splash_image.png</splashImage>
<allowLanguageSelection>1</allowLanguageSelection>
<componentList>
<component>
@ -17,15 +17,15 @@
<show>1</show>
<desktopShortcutList>
<shortcut>
<comment>Start Iguana App</comment>
<comment>Start Agama App</comment>
<exec></exec>
<icon></icon>
<name>Iguana App</name>
<name>Agama App</name>
<path></path>
<platforms>all</platforms>
<runAsAdmin>0</runAsAdmin>
<runInTerminal>0</runInTerminal>
<windowsExec>${installdir}/Iguana.exe</windowsExec>
<windowsExec>${installdir}/Agama.exe</windowsExec>
<windowsExecArgs></windowsExecArgs>
<windowsIcon></windowsIcon>
<windowsPath>${installdir}/</windowsPath>
@ -67,64 +67,64 @@
<platforms>windows</platforms>
<distributionFileList>
<distributionDirectory>
<origin>../../build/Iguana-win32-x64/locales</origin>
<origin>../../build/Agama-win32-x64/locales</origin>
</distributionDirectory>
<distributionDirectory>
<origin>../../build/Iguana-win32-x64/resources</origin>
<origin>../../build/Agama-win32-x64/resources</origin>
</distributionDirectory>
<distributionFile>
<origin>../../build/Iguana-win32-x64/blink_image_resources_200_percent.pak</origin>
<origin>../../build/Agama-win32-x64/blink_image_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/content_resources_200_percent.pak</origin>
<origin>../../build/Agama-win32-x64/content_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/content_shell.pak</origin>
<origin>../../build/Agama-win32-x64/content_shell.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/ui_resources_200_percent.pak</origin>
<origin>../../build/Agama-win32-x64/ui_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/views_resources_200_percent.pak</origin>
<origin>../../build/Agama-win32-x64/views_resources_200_percent.pak</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/icudtl.dat</origin>
<origin>../../build/Agama-win32-x64/icudtl.dat</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/LICENSES.chromium.html</origin>
<origin>../../build/Agama-win32-x64/LICENSES.chromium.html</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/natives_blob.bin</origin>
<origin>../../build/Agama-win32-x64/natives_blob.bin</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/snapshot_blob.bin</origin>
<origin>../../build/Agama-win32-x64/snapshot_blob.bin</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/d3dcompiler_47.dll</origin>
<origin>../../build/Agama-win32-x64/d3dcompiler_47.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/ffmpeg.dll</origin>
<origin>../../build/Agama-win32-x64/ffmpeg.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/libEGL.dll</origin>
<origin>../../build/Agama-win32-x64/libEGL.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/libGLESv2.dll</origin>
<origin>../../build/Agama-win32-x64/libGLESv2.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/node.dll</origin>
<origin>../../build/Agama-win32-x64/node.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/xinput1_3.dll</origin>
<origin>../../build/Agama-win32-x64/xinput1_3.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/LICENSE</origin>
<origin>../../build/Agama-win32-x64/LICENSE</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/version</origin>
<origin>../../build/Agama-win32-x64/version</origin>
</distributionFile>
<distributionFile>
<origin>../../build/Iguana-win32-x64/Iguana.exe</origin>
<origin>../../build/Agama-win32-x64/Agama.exe</origin>
</distributionFile>
</distributionFileList>
</folder>
@ -138,7 +138,7 @@
<startMenuShortcutList>
<startMenuShortcut>
<comment>Uninstall ${product_fullname}</comment>
<name>Uninstall Iguana App</name>
<name>Uninstall Agama App</name>
<runAsAdmin>0</runAsAdmin>
<runInTerminal>0</runInTerminal>
<windowsExec>${installdir}/${uninstallerName}.exe</windowsExec>
@ -147,11 +147,11 @@
<windowsPath>${installdir}/</windowsPath>
</startMenuShortcut>
<startMenuShortcut>
<comment>Start Iguana App</comment>
<name>Iguana App</name>
<comment>Start Agama App</comment>
<name>Agama App</name>
<runAsAdmin>0</runAsAdmin>
<runInTerminal>0</runInTerminal>
<windowsExec>${installdir}/Iguana.exe</windowsExec>
<windowsExec>${installdir}/Agama.exe</windowsExec>
<windowsExecArgs></windowsExecArgs>
<windowsIcon></windowsIcon>
<windowsPath>${installdir}/</windowsPath>
@ -287,6 +287,58 @@
<progressText>Downloading Visual C++ Redistributable for Visual Studio 2015</progressText>
<showMessageOnError>0</showMessageOnError>
</runProgram>
<createDirectory>
<abortOnError>0</abortOnError>
<explanation>Creating ZcashParam directory</explanation>
<path>${windows_folder_appdata}/ZcashParams/</path>
<progressText>Creating ZcashParam directory</progressText>
<showMessageOnError>0</showMessageOnError>
</createDirectory>
<showProgressDialog>
<abortOnError>0</abortOnError>
<explanation>Zcash Params file: sprout-proving.key</explanation>
<progressText>Zcash Params file: sprout-proving.key</progressText>
<showMessageOnError>0</showMessageOnError>
<title>Downloading Zcash Params file</title>
<actionList>
<httpGet>
<abortOnError>0</abortOnError>
<explanation>Zcash Params file: sprout-proving.key</explanation>
<filename>${windows_folder_appdata}/ZcashParams/sprout-proving.key</filename>
<progressText>Zcash Params file: sprout-proving.key</progressText>
<showMessageOnError>0</showMessageOnError>
<url>https://z.cash/downloads/sprout-proving.key</url>
</httpGet>
</actionList>
<ruleList>
<fileExists>
<negate>1</negate>
<path>${windows_folder_appdata}/ZcashParams/sprout-proving.key</path>
</fileExists>
</ruleList>
</showProgressDialog>
<showProgressDialog>
<abortOnError>0</abortOnError>
<explanation>Zcash Params file: sprout-verifying.key</explanation>
<progressText>Zcash Params file: sprout-verifying.key</progressText>
<title>Downloading Zcash Params files</title>
<actionList>
<httpGet>
<abortOnError>0</abortOnError>
<explanation>Zcash Params file: sprout-verifying.key</explanation>
<filename>${windows_folder_appdata}/ZcashParams/sprout-verifying.key</filename>
<progressText>Zcash Params file: sprout-verifying.key</progressText>
<showMessageOnError>0</showMessageOnError>
<url>https://z.cash/downloads/sprout-verifying.key</url>
</httpGet>
</actionList>
<ruleList>
<fileExists>
<negate>1</negate>
<path>${windows_folder_appdata}/ZcashParams/sprout-verifying.key</path>
</fileExists>
</ruleList>
</showProgressDialog>
</readyToInstallActionList>
<postInstallationActionList>
<registrySet>
@ -362,7 +414,7 @@
<windows64bitMode>1</windows64bitMode>
<finalPageActionList>
<runProgram>
<program>${installdir}/Iguana.exe</program>
<program>${installdir}/Agama.exe</program>
<programArguments>&amp;</programArguments>
<progressText>Do you want to launch ${project.fullName} now?</progressText>
</runProgram>

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.

BIN
assets/bin/osx/iguana

Binary file not shown.

BIN
assets/bin/osx/komodo-cli

Binary file not shown.

BIN
assets/bin/osx/komodod

Binary file not shown.

BIN
assets/bin/osx/libgcc_s.1.dylib

Binary file not shown.

BIN
assets/bin/osx/libgomp.1.dylib

Binary file not shown.

BIN
assets/bin/osx/libstdc++.6.dylib

Binary file not shown.

19
assets/bin/win64/genkmdconf.bat

@ -0,0 +1,19 @@
mkdir %AppData%\Komodo
@echo off
IF NOT EXIST %AppData%\Komodo\komodo.conf (
(
echo rpcuser=kmdusr%random%%random%
echo rpcpassword=kmdpass%random%%random%
echo rpcbind=127.0.0.1
echo txindex=1
echo server=1
echo addnode=5.9.102.210
echo addnode=78.47.196.146
echo addnode=178.63.69.164
echo addnode=88.198.65.74
echo addnode=5.9.122.241
echo addnode=144.76.94.38
) > %AppData%\Komodo\komodo.conf
)

BIN
assets/bin/win64/iguana.exe

Binary file not shown.

BIN
assets/bin/win64/komodo-cli.exe

Binary file not shown.

BIN
assets/bin/win64/komodod.exe

Binary file not shown.

BIN
assets/bin/win64/libcrypto-1_1.dll

Binary file not shown.

BIN
assets/bin/win64/libcurl-4.dll

Binary file not shown.

BIN
assets/bin/win64/libcurl.dll

Binary file not shown.

BIN
assets/bin/win64/libgcc_s_sjlj-1.dll

Binary file not shown.

BIN
assets/bin/win64/libnanomsg.dll

Binary file not shown.

BIN
assets/bin/win64/libssl-1_1.dll

Binary file not shown.

BIN
assets/bin/win64/libwinpthread-1.dll

Binary file not shown.

0
assets/bin/win64/nanomsg.dll

0
assets/bin/win64/pthreadvc2.dll

2
assets/deps/confs/KMD_peers.txt

@ -12,4 +12,4 @@
103.18.58.146
213.202.253.10
185.106.121.32
27.100.36.201
27.100.36.201

BIN
assets/icons/agama_icons/128x128.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
assets/icons/agama_icons/16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

BIN
assets/icons/agama_icons/24x24.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/icons/agama_icons/256x256.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
assets/icons/agama_icons/32x32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
assets/icons/agama_icons/48x48.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
assets/icons/agama_icons/64x64.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
assets/icons/agama_icons/96x96.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
assets/icons/agama_icons/agama_app_icon.icns

Binary file not shown.

BIN
assets/icons/agama_icons/agama_app_icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

BIN
assets/installer_imgs/Agama_installer_splash_image.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
assets/installer_imgs/Agama_installer_wizard_image.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
assets/installer_imgs/supernet-agama-logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

17
buildscripts/electron-build-all.sh

@ -0,0 +1,17 @@
#!/bin/bash
### Build script for Iguana application for Linux x32 and x64 platform.
### Created by mmaxian, 3/2017
[ -z $IGUANA_VERSION ] && echo "IGUANA_VERSION variable is not set." && exit 0
echo "Preparing electron package $IGUANA_VERSION for Linux."
./buildscripts/electron-build-linux.sh
echo
echo "Preparing electron package $IGUANA_VERSION for Windows."
./buildscripts/electron-build-win.sh
echo
echo "Preparing electron package $IGUANA_VERSION for MacOS."
./buildscripts/electron-build-osx.sh
echo

16
buildscripts/electron-build-linux.sh

@ -0,0 +1,16 @@
#!/bin/bash
### Build script for Iguana application for Linux x32 and x64 platform.
### Created by mmaxian, 3/2017
[ -z $IGUANA_VERSION ] && echo "IGUANA_VERSION variable is not set." && exit 0
echo "Build script for Iguana application for Linux x32 and x64 platform."
echo "Preparing electron package $IGUANA_VERSION"
electron-packager . --platform=linux --arch=ia32 \
--icon=assets/icons/iguana_app_icon_png/128x128.png \
--out=build/ --buildVersion=$IGUANA_VERSION \
--ignore=assets/bin/win64 --ignore=assets/bin/osx --overwrite
electron-packager . --platform=linux --arch=x64 \
--icon=assets/icons/iguana_app_icon_png/128x128.png \
--out=build/ --buildVersion=$IGUANA_VERSION \
--ignore=assets/bin/win64 --ignore=assets/bin/osx --overwrite

12
buildscripts/electron-build-osx.sh

@ -0,0 +1,12 @@
#!/bin/bash
### Build script for Iguana application for MacOS platform.
### Created by mmaxian, 3/2017
[ -z $IGUANA_VERSION ] && echo "IGUANA_VERSION variable is not set." && exit 0
echo "Build script for Iguana application for MacOS platform."
echo "Preparing electron package $IGUANA_VERSION"
electron-packager . --platform=darwin --arch=x64 \
--icon=assets/icons/iguana_app_icon.icns \
--out=build/ --buildVersion=$IGUANA_VERSION \
--ignore=assets/bin/win64 --ignore=assets/bin/linux64 --overwrite

18
buildscripts/electron-build-win.sh

@ -0,0 +1,18 @@
#!/bin/bash
### Build script for Iguana application for Windows ia32 and x64 platform.
### Created by mmaxian, 3/2017
[ -z $IGUANA_VERSION ] && echo "IGUANA_VERSION variable is not set." && exit 0
echo "Build script for Iguana application for Windows ia32 and x64 platform."
echo "Preparing electron package $IGUANA_VERSION"
electron-packager . --platform=win32 --arch=x64 \
--icon=assets/icons/iguana_app_icon.ico \
--out=build/ --buildVersion=$IGUANA_VERSION \
--ignore=assets/bin/osx --ignore=assets/bin/linux64 --overwrite
electron-packager . --platform=win32 --arch=ia32 \
--icon=assets/icons/iguana_app_icon.ico \
--out=build/ --buildVersion=$IGUANA_VERSION \
--ignore=assets/bin/osx --ignore=assets/bin/linux64 --overwrite

14
check_submodule.sh

@ -0,0 +1,14 @@
#!/bin/bash
### Script will check EasyDEX-GUI submodule in gui folder.
### If you used git clone without --recursive option this is way to go.
PWD=`pwd`
SIZE=`du -sk gui/EasyDEX-GUI`
echo "Checking EasyDEX-GUI folder."
cd gui/EasyDEX-GUI && \
git submodule update --recursive && \
cd ../.. && \
echo "Folder looks fine." || \
echo "Some problem with cloning submodule EasyDEX-GUI."
echo

10
compile-dev.sh

@ -1,10 +0,0 @@
#!/usr/bin/env bash
cd "tmp/Iguana-application"
gulp prod
cd ../../
rm "gui/Iguana-GUI" -rf
cp -rf "tmp/Iguana-application/compiled/prod" "gui/Iguana-GUI"

1
gui/EasyDEX-GUI

@ -0,0 +1 @@
Subproject commit 6832f1924506c8749e72ecc43cf7c39f04402a3f

2
gui/init.js

@ -38,4 +38,4 @@ $(document).ready(function() {
}
sartcheck();
});
});

15
gui/loading.css

@ -1,5 +1,7 @@
body {
overflow: hidden !important;
border: solid 1px #ccc;
height: 300px;
}
.text-center {
@ -7,15 +9,10 @@ body {
}
.loader-block {
/*
background-image: url('loading.gif');
background-repeat: no-repeat;
background-position: center;
*/
height: 240px;
width: 400px;
width: 100%;
position: absolute;
top: 0;
top: -30px;
bottom: 0;
left: 0;
right: 0;
@ -23,5 +20,9 @@ body {
}
.pulse-loader {
position: absolute;
top: 10px;
left: -100px;
margin: 80px 50px;
width: 400px !important;
}

41
gui/loading.js

@ -18,19 +18,20 @@ function Iguana_activehandle(callback) {
'method': 'activehandle'
},
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
});
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
});
}
//Iguana_activehandle().then(function(result){
//console.log(result)
@ -70,11 +71,13 @@ function GetAppConf() { // get iguana app conf
async: false,
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
}).done(function(_data) {
})
.done(function(_data) {
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;
}).fail(function(xhr, textStatus, error) {
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
@ -97,7 +100,8 @@ function EDEX_DEXnotarychains() {
AjaxOutputData = JSON.parse(AjaxOutputData.responseText);
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
}).fail(function(xhr, textStatus, error) {
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
@ -155,9 +159,11 @@ function EDEX_DEXgetinfoAll(skip, minNotaries) {
if ( tmp_index == minNotaries ) {
console.log('min notaries connected');
window.createWindow('open');
window.hide();
}
}).fail(function(xhr, textStatus, error) {
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
@ -169,6 +175,7 @@ function EDEX_DEXgetinfoAll(skip, minNotaries) {
});
});
} else {
window.createWindow('open');
window.hide();
}
}

520
main.js

@ -1,80 +1,125 @@
//main proc for EasyDEX GUI
//this app spawns iguana in background in nontech-mode
// main proc for EasyDEX GUI
// this app spawns iguana in background in nontech-mode
const electron = require('electron'),
app = electron.app,
BrowserWindow = electron.BrowserWindow,
path = require('path'),
url = require('url'),
os = require('os'),
spawn = require('child_process').spawn,
exec = require('child_process').exec,
fixPath = require('fix-path');
app = electron.app,
BrowserWindow = electron.BrowserWindow,
path = require('path'),
url = require('url'),
os = require('os'),
spawn = require('child_process').spawn,
exec = require('child_process').exec,
{ Menu } = require('electron'),
fixPath = require('fix-path');
var express = require('express'),
bodyParser = require('body-parser'),
fs = require('fs'),
fsnode = require('fs'),
fs = require('fs-extra'),
mkdirp = require('mkdirp'),
pm2 = require('pm2');
cluster = require('cluster');
numCPUs = require('os').cpus().length;
bodyParser = require('body-parser'),
fs = require('fs'),
fsnode = require('fs'),
fs = require('fs-extra'),
mkdirp = require('mkdirp'),
pm2 = require('pm2'),
cluster = require('cluster'),
numCPUs = require('os').cpus().length;
Promise = require('bluebird');
app.setName('Iguana');
app.setName('Agama');
app.setVersion('0.1.5.6e-beta');
if (os.platform() === 'linux') {
process.env.ELECTRON_RUN_AS_NODE = true;
console.log(process.env);
process.env.ELECTRON_RUN_AS_NODE = true;
console.log(process.env);
}
// GUI APP settings and starting gui on address http://120.0.0.1:17777
var shepherd = require('./routes/shepherd'),
guiapp = express();
var appConfig = shepherd.loadLocalConfig(); // load app config
guiapp = express(),
appConfig = shepherd.loadLocalConfig(); // load app config
guiapp.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', 'http://127.0.0.1:' + appConfig.iguanaAppPort);
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
next();
});
// preload.js
const _setImmediate = setImmediate,
_clearImmediate = clearImmediate;
_clearImmediate = clearImmediate;
process.once('loaded', () => {
global.setImmediate = _setImmediate;
global.clearImmediate = _clearImmediate;
if (os.platform() === 'darwin') {
process.setFdLimit(appConfig.maxDescriptors.darwin);
}
if (os.platform() === 'linux') {
process.setFdLimit(appConfig.maxDescriptors.linux);
}
global.setImmediate = _setImmediate;
global.clearImmediate = _clearImmediate;
if (os.platform() === 'darwin') {
process.setFdLimit(appConfig.maxDescriptors.darwin);
app.setAboutPanelOptions({
applicationName: app.getName(),
applicationVersion: app.getVersion(),
copyright: "Released under the MIT license",
credits: "SuperNET Team"
})
}
if (os.platform() === 'linux') {
process.setFdLimit(appConfig.maxDescriptors.linux);
}
});
guiapp.use(bodyParser.json()); // support json encoded bodies
guiapp.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
guiapp.use(bodyParser.json({ limit: '50mb' })); // support json encoded bodies
guiapp.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
})); // support encoded bodies
guiapp.get('/', function (req, res) {
res.send('Iguana app server');
res.send('Iguana app server');
});
var guipath = path.join(__dirname, '/gui');
guiapp.use('/gui', express.static(guipath));
guiapp.use('/shepherd', shepherd);
/*if (cluster.isMaster && process.env.NODE_ENV !== "development") {
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
}
console.log(cluster)
*/
var rungui = guiapp.listen(appConfig.iguanaAppPort, function () {
console.log('guiapp listening on port ' + appConfig.iguanaAppPort + '!');
/*var rungui = guiapp.listen(appConfig.iguanaAppPort, function () {
console.log('guiapp listening on port ' + appConfig.iguanaAppPort + '!');
});*/
var server = require('http').createServer(guiapp),
io = require('socket.io').listen(server);
server.listen(appConfig.iguanaAppPort, function() {
console.log('guiapp and sockets.io are listening on port ' + appConfig.iguanaAppPort + '!');
});
io.set('origins', 'http://127.0.0.1:17777'); // set origin
io.on('connection', function(client) {
console.log('EDEX GUI is connected...');
client.on('event', function(data) { // listen for client requests
console.log(data);
});
client.on('disconnect', function(data) {
console.log('EDEX GUI is disconnected');
});
client.on('join', function(data) {
console.log(data);
client.emit('messages', 'Sockets server is listening');
});
});
shepherd.setIO(io); // pass sockets object to shepherd router
module.exports = guiapp;
// END GUI App Settings
@ -89,47 +134,47 @@ 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';
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')
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);
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/iguana_app_icon_png/128x128.png');
var iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png');
}
if (os.platform() === 'win32') {
var iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico');
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);
});
})
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 )
if (err) return console.error(err)
console.log('confs files copied successfully at: '+ iguanaConfsDir )
})
*/
@ -137,192 +182,219 @@ let mainWindow;
let loadingWindow;
function createLoadingWindow() {
mainWindow = null;
// initialise window
loadingWindow = new BrowserWindow({
width: 500,
height: 300,
frame: false,
icon: iguanaIcon
});
// load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/');
// DEVTOOLS - only for dev purposes - ca333
//loadingWindow.webContents.openDevTools()
// if window closed we kill iguana proc
loadingWindow.on('hide', function () {
// our app does not have multiwindow - so we dereference the window object instead of
// putting them into an window_arr
loadingWindow = null;
createWindow('open');
})
//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}` ); }); }
mainWindow = null;
// initialise window
loadingWindow = new BrowserWindow({
width: 500,
height: 300,
frame: false,
icon: iguanaIcon
});
loadingWindow.createWindow = createWindow; // expose createWindow to front-end scripts
// load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/');
// DEVTOOLS - only for dev purposes - ca333
//loadingWindow.webContents.openDevTools()
// if window closed we kill iguana proc
loadingWindow.on('hide', function () {
// our app does not have multiwindow - so we dereference the window object instead of
// putting them into an window_arr
loadingWindow = null;
});
//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);
function createWindow (status) {
if ( status === 'open') {
require(path.join(__dirname, 'private/mainmenu'));
// initialise window
mainWindow = new BrowserWindow({
width: 1280,
height: 800,
icon: iguanaIcon
});
// load our index.html (i.e. easyDEX GUI)
if (appConfig.edexGuiOnly) {
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/EasyDEX-GUI/');
} else {
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/main.html');
}
// DEVTOOLS - only for dev purposes - ca333
//mainWindow.webContents.openDevTools()
// if window closed we kill iguana proc
mainWindow.on('closed', function () {
var ConnectToPm2 = function() {
return new Promise(function(resolve, reject) {
console.log('Closing Main Window...');
pm2.connect(true, function(err) {
console.log('connecting to pm2...');
if (err) {
console.log(err);
}
});
var result = 'Connecting To Pm2: done';
console.log(result);
resolve(result);
})
}
var KillPm2 = function() {
return new Promise(function(resolve, reject) {
console.log('killing to pm2...');
pm2.killDaemon(function(err) {
pm2.disconnect();
console.log('killed to pm2...');
if (err)
throw err;
});
var result = 'Killing Pm2: done';
setTimeout(function() {
console.log(result);
resolve(result);
}, 2000)
})
}
var HideMainWindow = function() {
return new Promise(function(resolve, reject) {
console.log('Exiting App...');
mainWindow = null;
var result = 'Hiding Main Window: done';
console.log(result);
resolve(result);
});
}
var QuitApp = function() {
return new Promise(function(resolve, reject) {
app.quit();
var result = 'Quiting App: done';
console.log(result);
resolve(result);
});
}
ConnectToPm2()
.then(function(result) {
return KillPm2();
})
.then(HideMainWindow)
.then(QuitApp);
});
}
if ( status === 'open') {
require(path.join(__dirname, 'private/mainmenu'));
// initialise window
mainWindow = new BrowserWindow({
width: 1280,
height: 800,
icon: iguanaIcon
});
const staticMenu = Menu.buildFromTemplate([ //if static
{ role: 'copy' },
{ type: 'separator' },
{ role: 'selectall' },
]);
const editMenu = Menu.buildFromTemplate([ //if editable
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ type: 'separator' },
{ role: 'selectall' },
]);
// load our index.html (i.e. easyDEX GUI)
if (appConfig.edexGuiOnly) {
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/EasyDEX-GUI/');
} else {
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.iguanaAppPort + '/gui/main.html');
}
mainWindow.webContents.on('context-menu', (e, params) => { //context-menu returns params
const { selectionText, isEditable } = params; //params obj
if (isEditable) {
editMenu.popup(mainWindow);
} else if (selectionText && selectionText.trim() !== '') {
staticMenu.popup(mainWindow);
}
});
// DEVTOOLS - only for dev purposes - ca333
//mainWindow.webContents.openDevTools()
// if window closed we kill iguana proc
mainWindow.on('closed', function () {
var ConnectToPm2 = function() {
return new Promise(function(resolve, reject) {
console.log('Closing Main Window...');
pm2.connect(true, function(err) {
console.log('connecting to pm2...');
if (err) {
console.log(err);
}
});
var result = 'Connecting To Pm2: done';
console.log(result);
resolve(result);
})
}
var KillPm2 = function() {
return new Promise(function(resolve, reject) {
console.log('killing to pm2...');
pm2.killDaemon(function(err) {
pm2.disconnect();
console.log('killed to pm2...');
if (err)
throw err;
});
var result = 'Killing Pm2: done';
setTimeout(function() {
console.log(result);
resolve(result);
}, 2000)
})
}
var HideMainWindow = function() {
return new Promise(function(resolve, reject) {
console.log('Exiting App...');
mainWindow = null;
var result = 'Hiding Main Window: done';
console.log(result);
resolve(result);
});
}
var QuitApp = function() {
return new Promise(function(resolve, reject) {
app.quit();
var result = 'Quiting App: done';
console.log(result);
resolve(result);
});
}
ConnectToPm2()
.then(function(result) {
return KillPm2();
})
.then(HideMainWindow)
.then(QuitApp);
});
}
}
//app.on('ready', function() {
//createLoadingWindow
//createLoadingWindow
//})
app.on('window-all-closed', function () {
//if (os.platform() !== 'win32') { ig.kill(); }
// in osx apps stay active in menu bar until explictly closed or quitted by CMD Q
// so we do not kill the app --> for the case user clicks again on the iguana icon
// we open just a new window and respawn iguana proc
/*if (process.platform !== 'darwin' || process.platform !== 'linux' || process.platform !== 'win32') {
app.quit()
}*/
//if (os.platform() !== 'win32') { ig.kill(); }
// in osx apps stay active in menu bar until explictly closed or quitted by CMD Q
// so we do not kill the app --> for the case user clicks again on the iguana icon
// we open just a new window and respawn iguana proc
/*if (process.platform !== 'darwin' || process.platform !== 'linux' || process.platform !== 'win32') {
app.quit()
}*/
})
//Emitted before the application starts closing its windows.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('before-quit', function (event) {
if (mainWindow === null && loadingWindow != null) { //mainWindow not intitialised and loadingWindow not dereferenced
//loading window is still open
console.log('before-quit prevented');
event.preventDefault();
}
if (mainWindow === null && loadingWindow != null) { //mainWindow not intitialised and loadingWindow not dereferenced
//loading window is still open
console.log('before-quit prevented');
event.preventDefault();
}
});
//Emitted when all windows have been closed and the application will quit.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('will-quit', function (event) {
if (mainWindow === null && loadingWindow != null) {
//loading window is still open
console.log('will-quit while loading window active');
event.preventDefault();
}
if (mainWindow === null && loadingWindow != null) {
//loading window is still open
console.log('will-quit while loading window active');
event.preventDefault();
}
});
//Emitted when the application is quitting.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('quit', function (event) {
if (mainWindow === null && loadingWindow != null) {
console.log('quit while loading window active');
event.preventDefault();
}
if (mainWindow === null && loadingWindow != null) {
console.log('quit while loading window active');
event.preventDefault();
}
})
app.on('activate', function () {
if (mainWindow === null) {
//createWindow('open');
}
});
if (mainWindow === null) {
//createWindow('open');
}
});

18
package.json

@ -1,15 +1,16 @@
{
"name": "iguana_app",
"productName": "Iguana",
"version": "0.1.0",
"description": "iguana Desktop App",
"name": "agama_app",
"productName": "Agama",
"version": "0.1.5",
"description": "Agama Desktop App",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/SuperNETorg/iguana/",
"repository": "https://github.com/SuperNETorg/Agama/",
"keywords": [
"iguana",
"agama",
"superNET",
"komodo",
"easydex",
@ -25,14 +26,17 @@
"bluebird": "^3.4.7",
"body-parser": "^1.15.2",
"corsproxy": "^1.5.0",
"electron": "^1.4.15",
"electron": "^1.6.4",
"express": "^4.14.0",
"fix-path": "^2.1.0",
"fs-extra": "^1.0.0",
"graceful-fs": "^4.1.11",
"md5": "^2.2.1",
"mkdirp": "^0.5.1",
"pm2": "^2.3.0",
"ps-node": "^0.1.4",
"read-last-lines": "^1.1.0"
"request": "^2.80.0",
"rimraf": "^2.6.1",
"socket.io": "^1.7.3"
}
}

9
private/mainmenu.js

@ -55,6 +55,15 @@ const template = [
focusedWindow.webContents.toggleDevTools();
}
},
/*{
label: 'Relaunch app',
click (item, focusedWindow) {
if (focusedWindow)
app.relaunch({ args: process.argv.slice(1).concat([ '--relaunch' ]) });
app.exit(0);
}
TODO: figure out a way to restart iguana and komodod, reload gui
},*/
{
type: 'separator'
},

36
pull-gui.sh

@ -1,36 +0,0 @@
#!/usr/bin/env bash
if [ -d "tmp" ]; then
cd tmp
else
mkdir tmp
cd tmp
fi
if [ -d "EasyDEX-GUI" ]; then
cd EasyDEX-GUI
git pull
cd ../
else
git clone https://github.com/SuperNETorg/EasyDEX-GUI.git
fi
#if [ -d "Iguana-application" ]; then
# cd Iguana-application
# git checkout 0.3.1
# git pull
#else
# git clone https://github.com/SuperNETorg/Iguana-application.git -b 0.3.1
# cd Iguana-application
#fi
#bower install
#npm install
#gulp electron
cd ../../
rm "gui/EasyDEX-GUI" -rf
#rm "gui/Iguana-GUI" -rf
#cp -rf "tmp/Iguana-application/compiled/prod" "gui/Iguana-GUI"
cp -rf "tmp/EasyDEX-GUI" "gui/EasyDEX-GUI"

589
routes/cache.js

@ -0,0 +1,589 @@
const fs = require('fs-extra'),
request = require('request'),
async = require('async');
var cache = {};
cache.setVar = function(variable, value) {
cache[variable] = value;
}
cache.get = function(req, res, next) {
var pubkey = req.query.pubkey;
if (pubkey) {
if (fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json')) {
fs.readFile(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json', 'utf8', function (err, data) {
if (err) {
var errorObj = {
'msg': 'error',
'result': err
};
res.end(JSON.stringify(errorObj));
} else {
var parsedJSON = 'JSON parse error';
try {
parsedJSON = JSON.parse(data);
} catch (e) {
console.log('JSON parse error');
}
var successObj = {
'msg': 'success',
'result': parsedJSON
};
res.end(JSON.stringify(successObj));
}
});
} else {
var errorObj = {
'msg': 'error',
'result': 'no file with handle ' + pubkey
};
res.end(JSON.stringify(errorObj));
}
} else {
var errorObj = {
'msg': 'error',
'result': 'no pubkey provided'
};
res.end(JSON.stringify(errorObj));
}
}
cache.groomGet = function(req, res, next) {
var _filename = req.query.filename;
if (_filename) {
if (fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json')) {
fs.readFile(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json', 'utf8', function (err, data) {
if (err) {
var errorObj = {
'msg': 'error',
'result': err
};
res.end(JSON.stringify(errorObj));
} else {
var successObj = {
'msg': 'success',
'result': data ? JSON.parse(data) : ''
};
res.end(JSON.stringify(successObj));
}
});
} else {
var errorObj = {
'msg': 'error',
'result': 'no file with name ' + _filename
};
res.end(JSON.stringify(errorObj));
}
} else {
var errorObj = {
'msg': 'error',
'result': 'no file name provided'
};
res.end(JSON.stringify(errorObj));
}
}
cache.groomDelete = function(req, res, next) {
var _filename = req.body.filename;
if (_filename) {
if (fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json')) {
fs.unlink(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json', function(err) {
if (err) {
var errorObj = {
'msg': 'error',
'result': err
};
res.end(JSON.stringify(errorObj));
} else {
var successObj = {
'msg': 'success',
'result': 'deleted'
};
res.end(JSON.stringify(successObj));
}
});
} else {
var errorObj = {
'msg': 'error',
'result': 'no file with name ' + _filename
};
res.end(JSON.stringify(errorObj));
}
} else {
var errorObj = {
'msg': 'error',
'result': 'no file name provided'
};
res.end(JSON.stringify(errorObj));
}
}
cache.groomPost = function(req, res) {
var _filename = req.body.filename,
_payload = req.body.payload;
if (_filename) {
if (!_payload) {
var errorObj = {
'msg': 'error',
'result': 'no payload provided'
};
res.end(JSON.stringify(errorObj));
} else {
fs.writeFile(cache.iguanaDir + '/shepherd/cache-' + _filename + '.json', _payload, function (err) {
if (err) {
var errorObj = {
'msg': 'error',
'result': err
};
res.end(JSON.stringify(errorObj));
} else {
var successObj = {
'msg': 'success',
'result': 'done'
};
res.end(JSON.stringify(successObj));
}
});
}
} else {
var errorObj = {
'msg': 'error',
'result': 'no file name provided'
};
res.end(JSON.stringify(errorObj));
}
}
var cacheCallInProgress = false,
cacheGlobLifetime = 300; // sec
// TODO: reset calls' states on new /cache call start
var mock = require('./mock');
/*
* type: GET
* 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')) {
cacheCallInProgress = false;
}
if (!cacheCallInProgress) {
// TODO: add check to allow only one cache call/sequence in progress
cacheCallInProgress = true;
var sessionKey = req.query.userpass,
coin = req.query.coin,
address = req.query.address,
pubkey = req.query.pubkey,
mock = req.query.mock,
skipTimeout = req.query.skip,
callsArray = req.query.calls.split(':'),
errorObj = {
'msg': 'error',
'result': 'error'
},
outObj = {},
pubkey,
writeCache = function(timeStamp) {
if (timeStamp) {
outObj.timestamp = timeStamp;
}
fs.writeFile(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json', JSON.stringify(outObj), function(err) {
if (err) {
return console.log(err);
}
console.log('file ' + cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json is updated');
if (timeStamp) {
console.log('file ' + cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json is timestamped');
}
});
},
callStack = {},
checkCallStack = function() {
var total = 0;
for (var coin in callStack) {
total =+ callStack[coin];
}
if (total / Object.keys(callStack).length === 1) {
cacheCallInProgress = false;
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'done',
'resp': 'success'
}
}
});
// add timestamp to cache file
// writeCache(Date.now());
}
},
checkTimestamp = function(dateToCheck) {
var currentEpochTime = new Date(Date.now()) / 1000,
secondsElapsed = Number(currentEpochTime) - Number(dateToCheck / 1000);
return Math.floor(secondsElapsed);
},
internalError = false;
callStack[coin] = 1;
console.log(callsArray);
if (!sessionKey) {
var errorObj = {
'msg': 'error',
'result': 'no session key provided'
};
res.end(JSON.stringify(errorObj));
internalError = true;
}
if (!pubkey) {
var errorObj = {
'msg': 'error',
'result': 'no pubkey provided'
};
res.end(JSON.stringify(errorObj));
internalError = true;
}
console.log('cache-one call started');
if (fs.existsSync(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json') && coin !== 'all') {
var _file = fs.readFileSync(cache.iguanaDir + '/shepherd/cache-' + pubkey + '.json', 'utf8');
outObj = _file ? JSON.parse(_file) : {};
if (!outObj || !outObj.basilisk) {
console.log('no local basilisk info');
outObj['basilisk'] = {};
outObj['basilisk'][coin] = {};
} else {
if (!outObj['basilisk'][coin]) {
console.log('no local coin info');
outObj['basilisk'][coin] = {};
}
}
} else {
outObj['basilisk'] = {};
outObj['basilisk'][coin] = {};
}
res.end(JSON.stringify({
'msg': 'success',
'result': 'call is initiated'
}));
if (!internalError) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress'
}
}
});
function execDEXRequests(address, coin) {
let dexUrls = {
'listunspent': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/dex/listunspent?userpass=' + sessionKey + '&symbol=' + coin + '&address=' + address,
'listtransactions': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/dex/listtransactions?userpass=' + sessionKey + '&count=100&skip=0&symbol=' + coin + '&address=' + address,
'getbalance': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/dex/getbalance?userpass=' + sessionKey + '&symbol=' + coin + '&address=' + address,
'refresh': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/basilisk/refresh?userpass=' + sessionKey + '&timeout=600000&symbol=' + coin + '&address=' + address
},
_dexUrls = {};
for (var a = 0; a < callsArray.length; a++) {
_dexUrls[callsArray[a]] = dexUrls[callsArray[a]];
}
if (coin === 'BTC' || coin === 'SYS') {
delete _dexUrls.refresh;
delete _dexUrls.getbalance;
}
console.log(coin + ' address ' + address);
if (!outObj.basilisk[coin][address]) {
outObj.basilisk[coin][address] = {};
writeCache();
}
// set current call status
async.forEachOf(_dexUrls, function(dexUrl, key) {
if (!outObj.basilisk[coin][address][key]) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].status = 'waiting';
} else {
outObj.basilisk[coin][address][key].status = 'waiting';
}
});
writeCache();
async.forEachOf(_dexUrls, function(dexUrl, key) {
var tooEarly = false;
if (outObj.basilisk[coin][address][key] &&
outObj.basilisk[coin][address][key].timestamp &&
checkTimestamp(outObj.basilisk[coin][address][key].timestamp) < cacheGlobLifetime) {
tooEarly = true;
outObj.basilisk[coin][address][key].status = 'done';
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': key,
'coin': coin,
'address': address,
'status': 'done',
'resp': 'too early'
}
}
}
});
}
if (!tooEarly) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': key,
'coin': coin,
'address': address,
'status': 'in progress'
}
}
}
});
outObj.basilisk[coin][address][key].status = 'in progress';
request({
url: mock ? 'http://localhost:17777/shepherd/mock?url=' + dexUrl : dexUrl,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': key,
'coin': coin,
'address': address,
'status': 'done',
'resp': body
}
}
}
});
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].data = JSON.parse(body);
outObj.basilisk[coin][address][key].timestamp = Date.now(); // add timestamp
outObj.basilisk[coin][address][key].status = 'done';
console.log(dexUrl);
console.log(body);
callStack[coin]--;
console.log(coin + ' _stack len ' + callStack[coin]);
checkCallStack();
writeCache();
}
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
outObj.basilisk[coin][address][key].status = 'done';
callStack[coin]--;
console.log(coin + ' _stack len ' + callStack[coin]);
checkCallStack();
writeCache();
}
});
} else {
console.log(key + ' is fresh, check back in ' + (cacheGlobLifetime - checkTimestamp(outObj.basilisk[coin][address][key].timestamp)) + 's');
callStack[coin]--;
console.log(coin + ' _stack len ' + callStack[coin]);
checkCallStack();
}
});
}
function getAddresses(coin) {
var 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) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'getaddressesbyaccount',
'coin': coin,
'status': 'done',
'resp': body
}
}
}
});
outObj.basilisk[coin].addresses = JSON.parse(body).result;
console.log(JSON.parse(body).result);
writeCache();
var addrCount = outObj.basilisk[coin].addresses ? outObj.basilisk[coin].addresses.length : 0;
var callsArrayBTC = callsArray.length;
if (callsArray.indexOf('getbalance') > - 1) {
callsArrayBTC--;
}
if (callsArray.indexOf('refresh') > - 1) {
callsArrayBTC--;
}
callStack[coin] = callStack[coin] + addrCount * (coin === 'BTC' || coin === 'SYS' ? callsArrayBTC : callsArray.length);
console.log(coin + ' stack len ' + callStack[coin]);
async.each(outObj.basilisk[coin].addresses, function(address) {
execDEXRequests(address, coin);
});
} else {
// TODO: error
}
});
}
// update all available coin addresses
if (!address) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'getaddressesbyaccount',
'coin': coin,
'status': 'in progress'
}
}
}
});
if (coin === 'all') {
var 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) {
console.log(JSON.parse(body).basilisk);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'allcoins',
'status': 'done',
'resp': body
}
}
}
});
body = JSON.parse(body);
// basilisk coins
if (body.basilisk && body.basilisk.length) {
// get coin addresses
async.each(body.basilisk, function(coin) {
callStack[coin] = 1;
});
async.each(body.basilisk, function(coin) {
outObj.basilisk[coin] = {};
writeCache();
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'getaddressesbyaccount',
'coin': coin,
'status': 'in progress'
}
}
}
});
getAddresses(coin);
});
}
}
if (error) { // stop further requests on failure, exit
callStack[coin] = 1;
checkCallStack();
}
});
} else {
getAddresses(coin);
}
} else {
callStack[coin] = callStack[coin] + (coin === 'BTC' ? callsArray.length : callsArray.length - 2);
console.log(coin + ' stack len ' + callStack[coin]);
execDEXRequests(coin, address);
}
} else {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-all',
'status': 'done',
'resp': 'internal error'
}
}
});
cacheCallInProgress = false;
}
} else {
res.end(JSON.stringify({
'msg': 'error',
'result': 'another call is in progress already'
}));
}
};
module.exports = cache;

39
routes/mock.js

@ -0,0 +1,39 @@
const fs = require('fs-extra'),
request = require('request'),
async = require('async'),
url = require('url');
var mock = {};
mock.setVar = function(variable, value) {
mock[variable] = value;
}
mock.get = function(req, res, next) {
var _url = req.query.url;
if (_url.indexOf('/InstantDEX/allcoins') > -1) {
res.end(JSON.stringify({
'native': [],
'basilisk': [ 'KMD', 'BTC'],
'full':[],
'tag': '18430609759584422959'
}));
}
if (_url.indexOf('/bitcoinrpc/getaddressesbyaccount') > -1) {
console.log(_url.indexOf('/bitcoinrpc/getaddressesbyaccount'));
res.end(JSON.stringify({
'result': ["RDbGxL8QYdEp8sMULaVZS2E6XThcTKT9Jd","RL4orv22Xch7PhM5w9jUHhVQhX6kF6GkfS","RUrxvPTEKGWEDTvAtgiqbUTTFE53Xdpj8a","RPJoLDa7RezvfUUBr7R3U8wrP16AgUsNw3","RQPTpRJEeafNx5hkDzgjcsPyU4E8RFVApT"]
}));
}
if (_url.indexOf('/api/dex/listunspent') > -1 ||
_url.indexOf('/api/dex/listtransactions') > -1 ||
_url.indexOf('/api/ss/getbalance') > -1 ||
_url.indexOf('/api/ww/refresh') > -1) {
res.end(JSON.stringify({
'some key': 'some value'
}));
}
}
module.exports = mock;

635
routes/shepherd.js

@ -6,14 +6,16 @@ const electron = require('electron'),
os = require('os'),
fsnode = require('fs'),
fs = require('fs-extra'),
_fs = require('graceful-fs'),
mkdirp = require('mkdirp'),
express = require('express'),
exec = require('child_process').exec,
spawn = require('child_process').spawn,
md5 = require('md5'),
pm2 = require('pm2'),
readLastLines = require('read-last-lines'),
request = require('request'),
async = require('async');
async = require('async'),
rimraf = require('rimraf');
Promise = require('bluebird');
@ -36,13 +38,17 @@ if (os.platform() === 'darwin') {
komododBin = path.join(__dirname, '../assets/bin/osx/komodod'),
komodocliBin = path.join(__dirname, '../assets/bin/osx/komodo-cli'),
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, '../assets/bin/linux64/iguana'),
iguanaDir = process.env.HOME + '/.iguana',
iguanaConfsDir = iguanaDir + '/confs',
iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon_png/128x128.png'),
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png'),
komododBin = path.join(__dirname, '../assets/bin/linux64/komodod'),
komodocliBin = path.join(__dirname, '../assets/bin/linux64/komodo-cli'),
komodoDir = process.env.HOME + '/.komodo';
@ -55,11 +61,15 @@ if (os.platform() === 'win32') {
iguanaDir = path.normalize(iguanaDir);
iguanaConfsDir = process.env.APPDATA + '/iguana/confs';
iguanaConfsDir = path.normalize(iguanaConfsDir);
iguanaIcon = path.join(__dirname, '/assets/icons/iguana_app_icon.ico'),
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.normalize(komododBin),
komodocliBin = path.join(__dirname, '../assets/bin/win64/komodo-cli.exe'),
komodoDir = process.env.APPDATA + '/Komodo';
komodocliBin = path.normalize(komodocliBin),
komodoDir = process.env.APPDATA + '/Komodo',
komodoDir = path.normalize(komodoDir);
}
shepherd.appConfig = {
@ -79,6 +89,9 @@ shepherd.appConfig = {
console.log('iguana dir: ' + iguanaDir);
console.log('iguana bin: ' + iguanaBin);
console.log('--------------------------')
console.log('iguana dir: ' + komododBin);
console.log('iguana bin: ' + komodoDir);
// END IGUANA FILES AND CONFIG SETTINGS
shepherd.get('/', function(req, res, next) {
@ -90,231 +103,82 @@ shepherd.get('/appconf', function(req, res, next) {
res.send(obj);
});
shepherd.get('/sysinfo', function(req, res, next) {
var obj = shepherd.SystemInfo();
res.send(obj);
});
var cache = require('./cache');
var mock = require('./mock');
// expose sockets obj
shepherd.setIO = function(io) {
shepherd.io = io;
cache.setVar('io', io);
};
cache.setVar('iguanaDir', iguanaDir);
cache.setVar('appConfig', shepherd.appConfig);
/*
* params: pubkey
* type: GET
* params: pubkey
*/
shepherd.get('/cache', function(req, res, next) {
var pubkey = req.query.pubkey;
if (pubkey) {
if (fs.existsSync(iguanaDir + '/cache-' + pubkey + '.json')) {
fs.readFile(iguanaDir + '/cache-' + pubkey + '.json', 'utf8', function (err, data) {
if (err) {
var errorObj = {
'msg': 'error',
'result': err
};
res.end(JSON.stringify(errorObj));
} else {
var successObj = {
'msg': 'success',
'result': JSON.parse(data)
};
res.end(JSON.stringify(successObj));
}
});
} else {
var errorObj = {
'msg': 'error',
'result': 'no pubkey provided'
};
res.end(JSON.stringify(errorObj));
}
}
cache.get(req, res, next);
});
var allcoinsInProgress = false;
/*
* type: GET
* params: filename
*/
shepherd.get('/groom', function(req, res, next) {
cache.groomGet(req, res, next);
})
/*
* params: userpass, pubkey
* type: DELETE
* params: filename
*/
shepherd.get('/allcoins', function(req, res, next) {
if (!allcoinsInProgress) {
allcoinsInProgress = true;
var sessionKey = req.query.userpass,
pubkey = req.query.pubkey,
_obj = {
'msg': 'error',
'result': 'error'
},
outObj = {
basilisk: {}
},
writeCache = function() {
fs.writeFile(iguanaDir + '/cache-' + pubkey + '.json', JSON.stringify(outObj), function(err) {
if (err) {
return console.log(err);
}
console.log('file ' + iguanaDir + '/cache-' + pubkey + '.json is updated');
});
},
callStack = {},
checkCallStack = function() {
var total = 0;
for (var coin in callStack) {
total =+ callStack[coin];
}
if (total / Object.keys(callStack).length === 1) {
allcoinsInProgress = false;
}
};
res.end(JSON.stringify({
'msg': 'success',
'result': 'call is initiated'
}));
console.log('allcoins call started');
request({
url: 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/InstantDEX/allcoins?userpass=' + sessionKey,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
body = JSON.parse(body);
// basilisk coins
if (body.basilisk && body.basilisk.length) {
// get coin addresses
async.each(body.basilisk, function(coin) {
callStack[coin] = 1;
});
shepherd.delete('/groom', function(req, res, next) {
cache.groomDelete(req, res, next);
});
async.each(body.basilisk, function(coin) {
outObj.basilisk[coin] = {};
writeCache();
request({
url: 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/bitcoinrpc/getaddressesbyaccount?userpass=' + sessionKey + '&coin=' + coin + '&account=*',
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
outObj.basilisk[coin].addresses = JSON.parse(body).result;
writeCache();
callStack[coin] = callStack[coin] + outObj.basilisk[coin].addresses.length * (coin === 'BTC' ? 2 : 3);
console.log(coin + ' stack len ' + callStack[coin]);
async.each(outObj.basilisk[coin].addresses, function(address) {
var dexUrls = {
'listunspent': 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/dex/listunspent' + (coin !== 'BTC' && coin !== 'SYS' ? '2' : '') + '?userpass=' + sessionKey + '&symbol=' + coin + '&address=' + address,
'listtransactions': 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/dex/listtransactions' + (coin !== 'BTC' && coin !== 'SYS' ? '2' : '') + '?userpass=' + sessionKey + '&count=100&skip=0&symbol=' + coin + '&address=' + address,
'getbalance': 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/dex/getbalance?userpass=' + sessionKey + '&symbol=' + coin + '&address=' + address,
'refresh': 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/basilisk/refresh?userpass=' + sessionKey + '&timeout=600000&symbol=' + coin + '&address=' + address
};
if (coin === 'BTC' && coin === 'SYS') {
delete dexUrls.refresh;
delete dexUrls.getbalance;
}
//console.log(JSON.stringify(dexUrls));
console.log(coin+' address ' + address);
outObj.basilisk[coin][address] = {};
writeCache();
async.forEachOf(dexUrls, function(dexUrl, key) {
request({
url: dexUrl,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
outObj.basilisk[coin][address][key] = JSON.parse(body);
console.log(dexUrl);
console.log(body);
callStack[coin]--;
console.log(coin + ' _stack len ' + callStack[coin]);
checkCallStack();
writeCache();
}
});
});
});
} else {
// TODO: error
}
});
});
} else {
// TODO: error
}
} else {
// TODO: error
}
});
} else {
res.end(JSON.stringify({
'msg': 'error',
'result': 'another call is in progress already'
}));
}
/*
* type: POST
* params: filename, payload
*/
shepherd.post('/groom', function(req, res) {
cache.groomPost(req, res, next);
});
/*
* params: userpass, pubkey, coin, address
* type: GET
* params: userpass, pubkey, skip
*/
shepherd.get('/refresh', function(req, res, next) {
var sessionKey = req.query.userpass,
coin = req.query.coin,
address = req.query.address,
pubkey = req.query.pubkey,
errorObj = {
'msg': 'error',
'result': 'error'
},
outObj,
pubkey,
writeCache = function() {
fs.writeFile(iguanaDir + '/cache-' + pubkey + '.json', JSON.stringify(outObj), function(err) {
if (err) {
return console.log(err);
}
console.log('file ' + iguanaDir + '/cache-' + pubkey + '.json is updated');
});
};
if (fs.existsSync(iguanaDir + '/cache-' + pubkey + '.json')) {
outObj = JSON.parse(fs.readFileSync(iguanaDir + '/cache-' + pubkey + '.json', 'utf8'));
if (outObj && !outObj.basilisk) {
outObj['basilisk'] = {};
outObj['basilisk'][coin] = {};
} else {
if (!outObj[coin]) {
outObj['basilisk'][coin][address] = {};
}
}
} else {
outObj = {
basilisk: {}
};
}
shepherd.get('/cache-all', function(req, res, next) {
cache.all(req, res, next);
});
var refreshUrl = 'http://' + shepherd.appConfig.host + ':' + shepherd.appConfig.iguanaCorePort + '/api/basilisk/refresh?userpass=' + sessionKey + '&timeout=600000&symbol=' + coin + '&address=' + address
request({
url: refreshUrl,
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
outObj.basilisk[coin][address].refresh = JSON.parse(body);
console.log(refreshUrl);
console.log(body);
writeCache();
res.end(JSON.stringify({
'msg': 'success',
'result': iguanaDir + '/cache-' + pubkey + '.json updated'
}));
}
});
/*
* type: GET
* params: userpass, pubkey, coin, address, skip
*/
shepherd.get('/cache-one', function(req, res, next) {
cache.one(req, res, next);
});
/*
* type: GET
*/
shepherd.get('/mock', function(req, res, next) {
mock.get(req, res, next);
});
/*
* type: GET
* params: herd, lastLines
*/
shepherd.post('/debuglog', function(req, res) {
var _herd = req.body.herdname,
_lastNLines = req.body.lastLines,
@ -344,6 +208,10 @@ shepherd.post('/debuglog', function(req, res) {
});
});
/*
* type: POST
* params: herd
*/
shepherd.post('/herd', function(req, res) {
console.log('======= req.body =======');
//console.log(req);
@ -361,6 +229,10 @@ shepherd.post('/herd', function(req, res) {
res.end(JSON.stringify(obj));
});
/*
* type: POST
* params: herdname
*/
shepherd.post('/herdlist', function(req, res) {
//console.log('======= req.body =======');
//console.log(req);
@ -390,6 +262,9 @@ shepherd.post('/herdlist', function(req, res) {
});
});
/*
* type: POST
*/
shepherd.post('/slay', function(req, res) {
console.log('======= req.body =======');
//console.log(req);
@ -405,13 +280,22 @@ shepherd.post('/slay', function(req, res) {
res.end(JSON.stringify(obj));
});
/*
* type: POST
*/
shepherd.post('/setconf', function(req, res) {
console.log('======= req.body =======');
//console.log(req);
console.log(req.body);
//console.log(req.body.chain);
setConf(req.body.chain);
if (os.platform() === 'win32' && req.body.chain == 'komodod') {
setkomodoconf = spawn(path.join(__dirname, '../assets/bin/win64/genkmdconf.bat'));
} else {
setConf(req.body.chain);
}
var obj = {
'msg': 'success',
'result': 'result'
@ -420,6 +304,9 @@ shepherd.post('/setconf', function(req, res) {
res.end(JSON.stringify(obj));
});
/*
* type: POST
*/
shepherd.post('/getconf', function(req, res) {
console.log('======= req.body =======');
//console.log(req);
@ -437,6 +324,147 @@ shepherd.post('/getconf', function(req, res) {
res.end(JSON.stringify(obj));
});
/*
* type: GET
* params: coin, type
*/
shepherd.get('/kick', function(req, res, next) {
var _coin = req.query.coin,
_type = req.query.type;
if (!_coin) {
var errorObj = {
'msg': 'error',
'result': 'no coin name provided'
};
res.end(JSON.stringify(errorObj));
}
if (!_type) {
var errorObj = {
'msg': 'error',
'result': 'no type provided'
};
res.end(JSON.stringify(errorObj));
}
var kickStartDirs = {
'soft': [
{
'name': 'DB/[coin]',
'type': 'pattern',
'match': 'balancecrc.'
},
{
'name': 'DB/[coin]/utxoaddrs',
'type': 'file'
},
{
'name': 'DB/[coin]/accounts',
'type': 'folder'
},
{
'name': 'DB/[coin]/fastfind',
'type': 'folder'
},
{
'name': 'tmp/[coin]',
'type': 'folder'
}
],
'hard': [
{
'name': 'DB/[coin]',
'type': 'pattern',
'match': 'balancecrc.'
},
{
'name': 'DB/[coin]/utxoaddrs',
'type': 'file'
},
{
'name': 'DB/[coin]',
'type': 'pattern',
'match': 'utxoaddrs.'
},
{
'name': 'DB/[coin]/accounts',
'type': 'folder'
},
{
'name': 'DB/[coin]/fastfind',
'type': 'folder'
},
{
'name': 'DB/[coin]/spends',
'type': 'folder'
},
{
'name': 'tmp/[coin]',
'type': 'folder'
}
],
'brutal': [ // delete coin related data
{
'name': 'DB/[coin]',
'type': 'folder'
},
{
'name': 'DB/purgeable/[coin]',
'type': 'folder'
},
{
'name': 'DB/ro/[coin]',
'type': 'folder'
},
{
'name': 'tmp/[coin]',
'type': 'folder'
}
]
};
if (_coin && _type) {
for (var i = 0; i < kickStartDirs[_type].length; i++) {
var currentKickItem = kickStartDirs[_type][i];
console.log('deleting ' + currentKickItem.type + (currentKickItem.match ? ' ' + currentKickItem.match : '') + ' ' + iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin));
if (currentKickItem.type === 'folder' || currentKickItem.type === 'file') {
rimraf(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin), function(err) {
if (err) {
throw err;
}
});
} else if (currentKickItem.type === 'pattern') {
var dirItems = fs.readdirSync(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin));
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) {
if (err) {
throw err;
}
});
console.log('deleting ' + dirItems[j]);
}
}
}
}
}
var successObj = {
'msg': 'success',
'result': 'kickstart: brutal is executed'
};
res.end(JSON.stringify(successObj));
}
});
shepherd.loadLocalConfig = function() {
if (fs.existsSync(iguanaDir + '/config.json')) {
var localAppConfig = fs.readFileSync(iguanaDir + '/config.json', 'utf8');
@ -482,15 +510,21 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) {
return new Promise(
function(resolve, reject) {
if (lastNLines) {
if (fs.existsSync(fileLocation)) {
console.log('reading ' + fileLocation);
readLastLines
.read(fileLocation, lastNLines)
.then((lines) => resolve(lines));
} else {
reject('file ' + fileLocation + ' doesn\'t exist!');
}
_fs.access(fileLocation, fs.constants.R_OK, function(err) {
if (err) {
console.log('error reading ' + fileLocation);
reject('readDebugLog error: ' + err);
} else {
console.log('reading ' + fileLocation);
_fs.readFile(fileLocation, 'utf-8', function(err, data) {
if (err) throw err;
var lines = data.trim().split('\n'),
lastLine = lines.slice(lines.length - lastNLines, lines.length).join('\n');
resolve(lastLine);
});
}
});
} else {
reject('readDebugLog error: lastNLines param is not provided!');
}
@ -549,6 +583,18 @@ function herder(flock, data) {
})
});
// ADD SHEPHERD FOLDER
mkdirp(iguanaDir + '/shepherd', 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)
@ -577,9 +623,20 @@ function herder(flock, data) {
}
if (flock === 'komodod') {
var kmdDebugLogLocation = komodoDir + '/debug.log';
console.log('komodod flock selected...');
console.log('selected data: ' + data);
// truncate debug.log
_fs.access(kmdDebugLogLocation, fs.constants.R_OK, function(err) {
if (err) {
console.log('error accessing ' + kmdDebugLogLocation);
} else {
console.log('truncate ' + kmdDebugLogLocation);
fs.unlink(kmdDebugLogLocation);
}
});
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
@ -601,6 +658,32 @@ function herder(flock, data) {
});
}
if (flock === 'zcashd') {
var kmdDebugLogLocation = zcashDir + '/debug.log';
console.log('zcashd flock selected...');
console.log('selected data: ' + data);
pm2.connect(true, function(err) { // start up pm2 god
if (err) {
console.error(err);
process.exit(2);
}
pm2.start({
script: zcashdBin, // path to binary
name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork',
cwd: zcashDir,
args: data.ac_options
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2
if (err)
throw err;
});
});
}
if (flock === 'corsproxy') {
console.log('corsproxy flock selected...');
console.log('selected data: ' + data);
@ -699,12 +782,21 @@ function setConf(flock) {
switch (flock) {
case 'komodod':
var DaemonConfPath = komodoDir + '/komodo.conf';
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
break;
case 'zcashd':
var DaemonConfPath = ZcashDir + '/zcash.conf';
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
break;
default:
var DaemonConfPath = komodoDir + '/' + flock + '/' + flock + '.conf';
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
}
console.log(DaemonConfPath);
@ -801,8 +893,7 @@ function setConf(flock) {
console.log('rpcpass: NOT FOUND');
var randomstring = md5(Math.random() * Math.random() * 999);
fs.appendFile(DaemonConfPath, '\nrpcpass=' + randomstring +
'\nrpcpassword=' + randomstring, (err) => {
fs.appendFile(DaemonConfPath, '\nrpcpassword=' + randomstring, (err) => {
if (err)
throw err;
console.log('rpcpass: ADDED');
@ -899,31 +990,87 @@ function setConf(flock) {
}
function getConf(flock) {
var komodoDir = '',
ZcashDir = '',
DaemonConfPath = '';
console.log(flock);
if (os.platform() === 'darwin') {
var komodoDir = process.env.HOME + '/Library/Application Support/Komodo',
ZcashDir = process.env.HOME + '/Library/Application Support/Zcash';
}
if (os.platform() === 'darwin') {
komodoDir = process.env.HOME + '/Library/Application Support/Komodo';
ZcashDir = process.env.HOME + '/Library/Application Support/Zcash';
}
if (os.platform() === 'linux') {
var komodoDir = process.env.HOME + '/.komodo',
ZcashDir = process.env.HOME + '/.zcash';
}
if (os.platform() === 'linux') {
komodoDir = process.env.HOME + '/.komodo';
ZcashDir = process.env.HOME + '/.zcash';
}
switch (flock) {
case 'komodod':
var DaemonConfPath = komodoDir;
break;
case 'zcashd':
var DaemonConfPath = ZcashDir;
break;
default:
var DaemonConfPath = komodoDir + '/' + flock;
}
if (os.platform() === 'win32') {
komodoDir = process.env.APPDATA + '/Komodo';
ZcashDir = process.env.APPDATA + '/Zcash';
}
switch (flock) {
case 'komodod':
DaemonConfPath = komodoDir;
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
console.log('===>>> SHEPHERD API OUTPUT ===>>>');
}
break;
case 'zcashd':
DaemonConfPath = ZcashDir;
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
break;
default:
DaemonConfPath = komodoDir + '/' + flock;
if (os.platform() === 'win32') {
DaemonConfPath = path.normalize(DaemonConfPath);
}
}
console.log(DaemonConfPath);
return DaemonConfPath;
}
function formatBytes(bytes, decimals) {
if (bytes == 0)
return '0 Bytes';
var k = 1000,
dm = decimals + 1 || 3,
sizes = [
'Bytes',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
shepherd.SystemInfo = function() {
const os_data = {
'totalmem_bytes': os.totalmem(),
'totalmem_readble': formatBytes(os.totalmem()),
'arch': os.arch(),
'cpu': os.cpus()[0].model,
'cpu_cores': os.cpus().length,
'platform': os.platform(),
'os_release': os.release(),
'os_type': os.type()
};
return os_data;
}
module.exports = shepherd;
Loading…
Cancel
Save