├── logs
└── .logs
├── VERSION
├── config
├── sitemap.conf
├── sia-cluster.local.conf-example
├── sia-cluster.conf
├── settings.json
└── i18n.conf
├── lib
├── manage
│ ├── index.js
│ ├── resources
│ │ ├── login.css
│ │ └── login.js
│ ├── manage.ejs
│ ├── login.ejs
│ └── lib
│ │ └── manage.js
├── markets.js
├── exchanges
│ ├── exchange.js
│ ├── bfx.js
│ ├── yunbi.js
│ ├── btc-e.js
│ ├── kraken.js
│ ├── polo.js
│ └── ecb.js
├── api-base.js
├── helper.js
├── api.js
└── price-aggregator.js
├── http
├── favicon.ico
├── fonts
│ ├── ETmodules_v2.eot
│ ├── ETmodules_v2.ttf
│ ├── ETmodules_v2.woff
│ ├── MaterialIcons-Regular.eot
│ ├── MaterialIcons-Regular.ttf
│ ├── MaterialIcons-Regular.woff
│ ├── MaterialIcons-Regular.woff2
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
├── images
│ ├── sia-cluster-16px.png
│ ├── sia-cluster-256px.png
│ ├── sia-cluster-32px.png
│ ├── sia-cluster-512px.png
│ ├── placeholder.svg
│ └── sia-cluster.svg
├── site
│ └── scripts
│ │ ├── index.js
│ │ └── jquery.easing.1.3.js
├── scripts
│ ├── scrypt.js
│ └── chart.js
├── app
│ ├── panel-style.html
│ ├── deps.html
│ ├── css
│ │ └── style.css
│ ├── sia-colors.html
│ ├── node-setting-style.html
│ ├── sia-network-panel.html
│ ├── sia-variable-graph.html
│ ├── app-style.html
│ ├── app.js
│ ├── sia-pricing.html
│ ├── sia-cluster-storage.html
│ ├── sia-network-peers-panel.html
│ ├── themes
│ │ └── sia-cluster.html
│ ├── sia-cluster.html
│ └── sia.html
└── api.js
├── .gitignore
├── resources
└── images
│ └── sia-cluster-screenshot-01.png
├── deploy
├── systemd
│ ├── siad.service
│ └── sia-cluster.service
└── upstart
│ └── sia-cluster.conf
├── tools
└── release
│ ├── NOTES.md
│ ├── bundle
│ ├── pubkey
│ ├── build
│ └── setup.js
├── views
├── site
│ ├── index.ejs
│ ├── partial
│ │ ├── footer.ejs
│ │ └── header.ejs
│ └── login.ejs
├── error.ejs
└── app
│ └── app.ejs
├── certificates
├── sia-cluster.crt
└── sia-cluster.key
├── LICENSE
├── package.json
├── run.js
└── sia-cluster.js
/logs/.logs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | v0-9-2-rc1
--------------------------------------------------------------------------------
/config/sitemap.conf:
--------------------------------------------------------------------------------
1 | {
2 | baseUrl : "http://127.0.0.1"
3 | }
4 |
--------------------------------------------------------------------------------
/lib/manage/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib/manage');
2 |
--------------------------------------------------------------------------------
/http/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/favicon.ico
--------------------------------------------------------------------------------
/http/fonts/ETmodules_v2.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/ETmodules_v2.eot
--------------------------------------------------------------------------------
/http/fonts/ETmodules_v2.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/ETmodules_v2.ttf
--------------------------------------------------------------------------------
/http/fonts/ETmodules_v2.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/ETmodules_v2.woff
--------------------------------------------------------------------------------
/http/images/sia-cluster-16px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/images/sia-cluster-16px.png
--------------------------------------------------------------------------------
/http/images/sia-cluster-256px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/images/sia-cluster-256px.png
--------------------------------------------------------------------------------
/http/images/sia-cluster-32px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/images/sia-cluster-32px.png
--------------------------------------------------------------------------------
/http/images/sia-cluster-512px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/images/sia-cluster-512px.png
--------------------------------------------------------------------------------
/http/fonts/MaterialIcons-Regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/MaterialIcons-Regular.eot
--------------------------------------------------------------------------------
/http/fonts/MaterialIcons-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/MaterialIcons-Regular.ttf
--------------------------------------------------------------------------------
/http/fonts/MaterialIcons-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/MaterialIcons-Regular.woff
--------------------------------------------------------------------------------
/http/fonts/MaterialIcons-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/MaterialIcons-Regular.woff2
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | bower_components/
3 | config/*.local.conf
4 | config/*.local.json
5 | temp/
6 | uuid
7 | logs/*
8 |
--------------------------------------------------------------------------------
/http/site/scripts/index.js:
--------------------------------------------------------------------------------
1 | (function($){
2 |
3 | $(document).ready(function(){
4 | Api.hideLoading();
5 | })
6 |
7 | })(jQuery);
8 |
--------------------------------------------------------------------------------
/http/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/http/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/http/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/http/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/http/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/resources/images/sia-cluster-screenshot-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspectron/sia-cluster/HEAD/resources/images/sia-cluster-screenshot-01.png
--------------------------------------------------------------------------------
/deploy/systemd/siad.service:
--------------------------------------------------------------------------------
1 | # /usr/lib/systemd/siad.service
2 |
3 | [Unit]
4 | Description=Sia Daemon
5 |
6 | [Service]
7 | Type=simple
8 | PIDFile=/var/run/siad.pid
9 | WorkingDirectory=/home/userfolder/sia
10 | ExecStart=/home/userfolder/sia/siad
11 |
12 | [Install]
13 | WantedBy=multi-user.target
14 |
--------------------------------------------------------------------------------
/deploy/systemd/sia-cluster.service:
--------------------------------------------------------------------------------
1 | # /usr/lib/systemd/sia-cluster.service
2 |
3 | [Unit]
4 | Description=Sia Cluster
5 |
6 | [Service]
7 | Type=simple
8 | PIDFile=/var/run/sia-cluster.pid
9 | WorkingDirectory=/home/userfolder/sia-cluster
10 | ExecStart=/home/userfolder/node/bin/node run sia-cluster
11 |
12 | [Install]
13 | WantedBy=multi-user.target
14 |
--------------------------------------------------------------------------------
/deploy/upstart/sia-cluster.conf:
--------------------------------------------------------------------------------
1 | # this should live in /etc/init
2 | description "sia-cluster"
3 |
4 | # start process on system startup
5 | start on filesystem
6 | stop on shutdown
7 |
8 | # Automatically Respawn:
9 | respawn
10 | respawn limit 20 5
11 |
12 | script
13 | cd /home/userfolder/releases/sia-cluster
14 | exec ../node/bin/node run sia-cluster
15 | end script
16 |
--------------------------------------------------------------------------------
/tools/release/NOTES.md:
--------------------------------------------------------------------------------
1 |
2 | ### Dependencies for build process:
3 |
4 | All Platforms:
5 |
6 | * `npm -g install bower`
7 | * `npm -g install flatten-packages`
8 |
9 | win64:
10 |
11 | * NodeJs
12 | * Visual Studio Community Edition
13 | * Python 2.7 (not 3.x!)
14 | * Git for Windows
15 | * GNU zip for Windows (mingw64)
16 |
17 | linux64:
18 |
19 | * `sudo apt-get install git`
20 | * NodeJs
21 | * Pyton
22 |
23 |
24 |
--------------------------------------------------------------------------------
/lib/manage/resources/login.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | font-family: "Exo";
3 | font-size: 18px;
4 | margin: 0px;
5 | overflow: hidden;
6 | }
7 |
8 | input#user, input#pass {
9 | font-family: "Exo";
10 | font-size: 18px;
11 | padding: 4px;
12 | }
13 |
14 | #status {
15 | margin-top: 16px;
16 | text-align: left;
17 | color: #900;
18 | }
19 | #login {
20 | border: 1px solid #888;
21 | background: #eee;
22 | padding: 5px 16px;
23 | }
--------------------------------------------------------------------------------
/http/scripts/scrypt.js:
--------------------------------------------------------------------------------
1 | var scrypt = scrypt_module_factory();
2 |
3 | scrypt.hex2uint8array = function(hex) {
4 | var bytes = new Uint8Array(hex.length/2);
5 | for(var i=0; i< hex.length-1; i+=2){
6 | bytes[i] = parseInt(hex.substr(i, 2), 16);
7 | }
8 | return bytes;
9 | }
10 |
11 | scrypt.createHash = function(data, config) {
12 | var hash = scrypt.crypto_scrypt(scrypt.encode_utf8(data), scrypt.hex2uint8array(config.salt), config.n, config.r, config.p, config.keyLength);
13 | return scrypt.to_hex(hash);
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/views/site/index.ejs:
--------------------------------------------------------------------------------
1 | <% req.__scriptAtHeader = false; %>
2 | <% req.__script = "underscore-min;index" %>
3 | <% include partial/header %>
4 |
5 |
6 |

7 |
8 |
9 |
16 |
17 |
23 | <% include partial/footer %>
24 |
--------------------------------------------------------------------------------
/certificates/sia-cluster.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIICATCCAWoCCQDt1dDerT7q6DANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
4 | cyBQdHkgTHRkMB4XDTE0MDUwNjA3MjAzNloXDTMwMDMxNjIxNTUxNlowRTELMAkG
5 | A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
6 | IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAymx7
7 | i02LQS3QBIxXvw5KzpvRcJjJco6gyTtuDRyLeGcSBWPKl0DJTEykIskD3QyoLTkL
8 | LtOMPdTLWCbSW7cyl6Uq/3qznnxjWB2A3xPV1Nvv1X0hBd0uovMAmwLtnDYgfd2Q
9 | SEJwLberGq+0OtodVZTH3ul8sBZ0cOwtKx6wlKcCAwEAATANBgkqhkiG9w0BAQUF
10 | AAOBgQBWSVHgxQPHGaQdVenAZlKdt+MR69Z224Ou+nmoXF49W1FThxc4oRG0t4xi
11 | NCglhytCiK/PcBvyt+3PyKYILD7PxUAsdmALq9nD+WG6rq7MIejfws7a6v5P7P/M
12 | fgQni0BRTefL5t3ZlxKGCgBR93gC/J8xoPe6DZzGytn+EMwW+A==
13 | -----END CERTIFICATE-----
14 |
--------------------------------------------------------------------------------
/http/app/panel-style.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
--------------------------------------------------------------------------------
/certificates/sia-cluster.key:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIICXAIBAAKBgQDKbHuLTYtBLdAEjFe/DkrOm9FwmMlyjqDJO24NHIt4ZxIFY8qX
3 | QMlMTKQiyQPdDKgtOQsu04w91MtYJtJbtzKXpSr/erOefGNYHYDfE9XU2+/VfSEF
4 | 3S6i8wCbAu2cNiB93ZBIQnAtt6sar7Q62h1VlMfe6XywFnRw7C0rHrCUpwIDAQAB
5 | AoGALFT/5a1Q7zBqW2SlHvmxVnh3sRI1JDqqagfy/TogLXldUALf7qpIq8YpOFkP
6 | 2IyaFHVmxpWcJDqDYkX2UhHYKUwedQ/i+KdZ5M52mOP7iUHWC+5PYCYndJijVkdn
7 | 1f1kaUDVGCEkrdXqgcB/7voj6rbqdcStVLc9XGAdrdEligkCQQDy4EXM3An9Z1pk
8 | BER5elaiRxQtjHUlL2h2XewzPnNIYLh4CLEY0m6XWj7Il1HlWdbkK4lFpBjGrYQv
9 | 0jGLEXc1AkEA1VyhIW/D07afxqkLfpRCwN5SHWuIykSh/MnMdZMh6kORSxcrv/6v
10 | glYb061kDw5IploUVwrhrXNH4xOK/yFr6wJAWJ+xmKEqHAdcmmZcPh+AAVMCb+Ry
11 | 0pDMA3UePUyqcFyqs1IonTAcHqpVgoiE37W6jiO8wWaxi73BIFoIrgA/iQJBAIi6
12 | eY/B3c54w989SV5uiHCsiBbOaLSmUuB6OYpHJX7Imf1y9dhtz+9IW0DFZs+3KZth
13 | MpOtJ35N2A2O4o4ozs0CQGGPbkjxROSFuTzXmh8nWnFBi19W6IHjX6MY84TYRvol
14 | h5eXvetVF6dwIjAER5Zm3I036XUarbIoWnEzuUlOnWE=
15 | -----END RSA PRIVATE KEY-----
16 |
--------------------------------------------------------------------------------
/lib/markets.js:
--------------------------------------------------------------------------------
1 | var POLO = require("./exchanges/polo");
2 | var YUNBI = require("./exchanges/yunbi");
3 | var BFX = require("./exchanges/bfx");
4 | var BTCE = require("./exchanges/btc-e");
5 | var KRAKEN = require("./exchanges/kraken");
6 | var ECB = require("./exchanges/ecb");
7 | var _ = require("iris-underscore");
8 |
9 |
10 | function Markets(core, config) {
11 | var self = this;
12 | self.exchanges = {
13 | polo : new POLO(core, config),
14 | yunbi : new YUNBI(core, config),
15 | btce : new BTCE(core, config),
16 | // bfx : new BFX(core, config),
17 | kraken : new KRAKEN(core, config),
18 | ecb : new ECB(core, config)
19 | }
20 |
21 | self.update = function(callback) {
22 |
23 | var list = _.keys(self.exchanges);
24 |
25 | _.asyncMap(list, function(ident, callback) {
26 |
27 | self.exchanges[ident].syncTickers(function(err) {
28 | if(err)
29 | console.log(err);
30 | callback();
31 | });
32 |
33 | }, function() {
34 | callback();
35 | })
36 |
37 |
38 | }
39 | }
40 |
41 | module.exports = Markets;
--------------------------------------------------------------------------------
/views/error.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%= _T("SIA Cluster") %>
5 |
6 |
7 |
8 |
15 |
16 |
17 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/http/images/placeholder.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 ASPECTRON Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/lib/manage/manage.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%=_T("Accredited Access")%> || <%=_T("CMS")%>
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/config/sia-cluster.local.conf-example:
--------------------------------------------------------------------------------
1 | //
2 | // Sia Cluster local config file
3 | //
4 | // WARNING: You must create unique auth string that you use throughout your deployment!
5 | //
6 | // To create user account - https://github.com/aspectron/sia-cluster#user-access
7 | //
8 |
9 | {
10 | rpc : {
11 | // server
12 | nodes : {
13 | port : 58481,
14 | auth : "1299ece0263565a53df103a34910884d5016a10d86c06e5f309f17761a965d28" // your auth
15 | },
16 | // client to remote server
17 | // remote_node_as_server_1 : {
18 | // address : ':17412',
19 | // auth : "1299ece0263565a53df103a34910884d5016a10d86c06e5f309f17761a965d28" // your auth
20 | // }
21 | },
22 |
23 | http : {
24 |
25 | // 'localhost' to listen on local interface only,
26 | // useful if you are proxying via NGINX
27 | //
28 | // host : "127.0.0.1",
29 |
30 |
31 | // basicAuth : {
32 | // user : "sia",
33 | // pass : "q1w2e3r4"
34 | // }
35 | },
36 |
37 | users : {
38 | "test": {pass: "13a5c202e320d0bf9bb2c6e2c7cf380a6f7de5d392509fee260b809c893ff2f9"}
39 | }
40 | }
--------------------------------------------------------------------------------
/lib/manage/resources/login.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 | $("#login").click(function() {
3 | var user = $("#user").val();
4 | var pass = $("#pass").val();
5 | if(!user || !pass)
6 | return $("#status").html("Please supply a valid username and password");
7 | var hash = CryptoJS.SHA256(CryptoJS.enc.Utf8.parse(pass)).toString();
8 | var sig = CryptoJS.HmacSHA256(CryptoJS.enc.Hex.parse(hash), CryptoJS.enc.Hex.parse(salt)).toString();
9 |
10 | $.ajax({
11 | url: '/manage/login',
12 | type: 'POST',
13 | dataType: "json",
14 | data: {
15 | user : user,
16 | sig : sig
17 | }
18 | }).done(function (data) {
19 | console.log("SUCCESS:",arguments);
20 | if(data.ack == salt)
21 | window.location.assign('/manage');
22 | else
23 | $("#status").html(data.ack);
24 | }).fail(function (jqXHR) {
25 | console.log("FAILURE:",arguments);
26 | $("#status").html(jqXHR.statusText);
27 | });
28 | })
29 | $("#user").keydown(function(e) {
30 | if(e.which == 13)
31 | $("#login").trigger('click');
32 | })
33 | $("#pass").keydown(function(e) {
34 | if(e.which == 13)
35 | $("#login").trigger('click');
36 | })
37 | $("#user").focus();
38 | })
--------------------------------------------------------------------------------
/lib/exchanges/exchange.js:
--------------------------------------------------------------------------------
1 | module.exports = Exchange;
2 |
3 | var util = require("util");
4 | var events = require('events');
5 | var request = require("request");
6 | var _ = require("underscore");
7 |
8 | function Exchange(core, config) {
9 | var self = this;
10 | events.EventEmitter.apply(this);
11 | self.verbose = config.verbose || false;
12 | self.ident = 'N/A';
13 | self.ctx = { ts : 0, tickers : { } }
14 |
15 | self.fetch = function(url, callback) {
16 | core.verbose > 1 && console.log("-->",url);
17 | request({
18 | url : url,
19 | timeout : 15 * 1000
20 | } , function(error, response, body) {
21 | if (!error && response.statusCode == 200) {
22 | var data;
23 | try {
24 | data = JSON.parse(body);
25 | }
26 | catch(err) {
27 | return callback(err);
28 | }
29 |
30 | return callback(null, data);
31 | }
32 | else
33 | if(!error && response.statusCode != 200) {
34 | console.log('-->', url);
35 | console.log("Invalid response code: "+response.statusCode);
36 | return callback(new Error("Invalid response code: "+response.statusCode));
37 | }
38 | else
39 | {
40 | console.log('-->', url);
41 | console.log(error.toString().red.bold);
42 | return callback(error)
43 | }
44 | });
45 | }
46 |
47 |
48 |
49 | }
50 |
51 | util.inherits(Exchange, events.EventEmitter);
52 |
--------------------------------------------------------------------------------
/lib/exchanges/bfx.js:
--------------------------------------------------------------------------------
1 | module.exports = BFX;
2 |
3 | var util = require("util");
4 | var events = require('events');
5 | var request = require("request");
6 | var Exchange = require("./exchange");
7 | var _ = require("underscore");
8 |
9 | var REQUEST_INTERVAL = 3000;
10 |
11 | function BFX(core) {
12 | var self = this;
13 | Exchange.apply(this,arguments);
14 |
15 | // ---
16 |
17 | var baseURL = "https://api.bitfinex.com/v1"
18 |
19 | function fetch(op, callback) {
20 |
21 | self.fetch(baseURL+op, callback);
22 | }
23 |
24 | self.syncTickers = function(callback) {
25 |
26 | var pairs = ["BTC/USD"];
27 |
28 | var out = { }
29 |
30 | _.asyncMap(pairs, function(pair, callback) {
31 |
32 | var ident = pair.replace('/','');
33 |
34 | fetch('/pubticker/'+ident, function(err, o) {
35 | if(err)
36 | return callback(err);
37 |
38 | out[pair] = {
39 | ask : parseFloat(o.ask),
40 | bid : parseFloat(o.bid),
41 | volume : parseFloat(o.volume),
42 | high : parseFloat(o.high),
43 | low : parseFloat(o.low)
44 | }
45 |
46 | dpc(self.ctx.ts ? REQUEST_INTERVAL : 100, callback);
47 |
48 | })
49 |
50 | }, function() {
51 |
52 | self.ctx.tickers = out;
53 | self.ctx.ts = Date.now();
54 | callback();
55 | })
56 |
57 |
58 | }
59 |
60 | }
61 |
62 | util.inherits(BFX, events.EventEmitter);
63 |
--------------------------------------------------------------------------------
/lib/api-base.js:
--------------------------------------------------------------------------------
1 | var _ = require("underscore");
2 | var request = require("request");
3 |
4 | function APIBase(core, apiName){
5 | var self = this;
6 |
7 | self.init = function(){}
8 |
9 | self.initHttp = function(app){}
10 |
11 | self.initRPC = function(rpc){}
12 |
13 | self.rpcRequest = function rpcRequest(socket, data, callback){
14 | self.getSocketUser(socket, function(err, user){
15 | if (err)
16 | return callback(err);
17 |
18 | if(!user || !user.token)
19 | return callback({code: "USER-TOKEN-MISSING", error: "User token missing in session"});
20 |
21 | data.token = user.token;
22 | data.op = data.op.replace("ws::", "");
23 | core.rpc.dispatch(data, function(err, result){
24 | console.log(('RPC-RESULT:'+data.op).redBG.white, err, result);
25 |
26 | if (err && err.logout)
27 | delete user.token;
28 |
29 | callback(err, result);
30 | });
31 | });
32 | }
33 |
34 | self.getSocketUser = function getSocketUser(socket, callback){
35 | core.getSocketSession(socket, function(err, session){
36 | if (err)
37 | return callback(err);
38 |
39 | var user = session && session.user;
40 | //console.log("session".greenBG, session)
41 | if (!user)
42 | return callback({error: "Please login", loginRequired: true, logout: true});
43 |
44 | callback(null, user, session);
45 | })
46 | }
47 |
48 | dpc(10, function(){
49 | self.init();
50 | });
51 | }
52 |
53 | module.exports = APIBase;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "sia-cluster",
3 | "version": "0.9.2",
4 | "description": "Sia Cluster - Remote management & monitoring of Sia hosts",
5 | "author": {
6 | "name": "ASPECTRON Inc.",
7 | "email": "info@aspectron.com"
8 | },
9 | "private": true,
10 | "scripts": {
11 | "start": "node sia-cluster.js"
12 | },
13 | "main": "sia-cluster.js",
14 | "dependencies": {
15 | "basic-auth": "*",
16 | "big-integer": "*",
17 | "cloudflare": "*",
18 | "compression": "*",
19 | "ejs": "*",
20 | "iris-app": "^0.1.44",
21 | "iris-i18n": "*",
22 | "iris-mdl": "*",
23 | "iris-polymer": "*",
24 | "iris-rpc": "^0.2.17",
25 | "iris-stats": "*",
26 | "iris-underscore": "*",
27 | "iris-utils": "*",
28 | "mongodb": "^2.1.21",
29 | "morgan": "*",
30 | "multiparty": "*",
31 | "node-uuid": "^1.4.7",
32 | "nodemailer": "*",
33 | "request": "*",
34 | "request-progress": "^2.0.1",
35 | "sia-api": "*",
36 | "underscore": "*",
37 | "xml2json": "*",
38 | "commander": "*",
39 | "readline-sync" : "*"
40 | },
41 | "engines": {
42 | "node": "*",
43 | "npm": "*"
44 | },
45 | "repository": {
46 | "type": "git",
47 | "url": "git://github.com/aspectron/sia-cluster"
48 | },
49 | "bugs": {
50 | "url": "https://github.com/aspectron/sia-cluster/issues"
51 | },
52 | "license": "MIT",
53 | "homepage": "https://github.com/aspectron/sia-cluster"
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/views/site/partial/footer.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
17 |
22 |
23 |
24 |
25 |
28 |
29 |
30 | <% if(!req.__scriptAtHeader) { %>
31 |
32 | <% } %>
33 |
34 |
35 |