Skip to content

Commit 307d854

Browse files
committed
Merge branch 'release/0.2.0-beta'
2 parents b265a2c + 644aff2 commit 307d854

28 files changed

+428
-77
lines changed

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [0.4.0] - 2018-02-04
10+
11+
### BREAKING CHANGE
12+
- The url structure has changed. Please read the README!
13+
14+
### Added
15+
- Support for Nelson 0.4.0
16+
- Proxy to a Nelson server (you do not have to specify it in the URL any more)
17+
- More information about the running IRI instance
18+
- Stats about new/connected nodes
19+
20+
### Changed
21+
- Improved README
22+
- Hide IPs if the Nelson API is not password-protected

README.md

+32-3
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,31 @@ node build/nelson.gui.js
6565
```
6666

6767
Now your server runs at `http://localhost:5000`
68-
Is your Nelson running on a non-standard host:port (localhost:18600)?
69-
Simply provide it in browsers's url, like: `http://localhost:5000/yourhost/1234`
68+
69+
### Connecting to Nelson on another host/port
70+
71+
Is your Nelson's API running on a non-standard host:port (localhost:18600)?
72+
Simply provide it when starting the GUI:
73+
74+
```
75+
nelson.gui --p 5000 --apiHostname another.hostname.com --apiPort 123456
76+
```
77+
7078
The data is refreshed automatically each 5 seconds (or at the heartbeat rate of your Nelson)
71-
Work in progress.
79+
80+
### Connecting to Nelson +v.0.4.0 with username/password
81+
82+
If your Nelson's API is username/password protected (strongly recommended!),
83+
you can specify the credentials in the URL:
84+
85+
```
86+
http://www.your.gui.host.com:<port>/#/<username>:<password>
87+
```
88+
89+
This is the simplest way. A better login window is coming soon.
90+
91+
**NOTE**: If your Nelson API is not password protected, the GUI will
92+
scramble all the hostnames and IPs for security reasons.
7293

7394
## Development
7495

@@ -77,6 +98,14 @@ Contribution / Pull Requests are welcome, but at this early stages where so much
7798
work might become quickly non-mergeable and thus be in vain.
7899
Please, for now, refrain to small PRs, thank you!
79100

101+
### Donations
102+
103+
**Donations always welcome**:
104+
105+
```
106+
SOZAIPJMQUBOFCTDTJJDXCZEKNIYZGIGVDLFMH9FFBAYK9SWGTBCWVUTFHXDOUESZAXRJJCJESJPIEQCCKBUTVQPOW
107+
```
108+
80109
### What's Next
81110
* Make it responsive
82111
* Add optional listing of all known hosts (already fetching)

build/asset-manifest.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"main.css": "static/css/main.078b9fee.css",
3-
"main.css.map": "static/css/main.078b9fee.css.map",
4-
"main.js": "static/js/main.50ce7918.js",
5-
"main.js.map": "static/js/main.50ce7918.js.map"
2+
"main.css": "static/css/main.ef153f8d.css",
3+
"main.css.map": "static/css/main.ef153f8d.css.map",
4+
"main.js": "static/js/main.db092208.js",
5+
"main.js.map": "static/js/main.db092208.js.map"
66
}

build/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"><title>Nelson Monitor</title><link href="/static/css/main.078b9fee.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="/static/js/main.50ce7918.js"></script></body></html>
1+
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"><title>Nelson Monitor</title><link href="/static/css/main.ef153f8d.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="/static/js/main.db092208.js"></script></body></html>

build/nelson.gui.js

+58-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/usr/bin/env node
22
'use strict';
33

4+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
5+
6+
var request = require('request');
7+
var md5 = require('md5');
8+
var crypto = require('crypto');
49
var express = require('express');
10+
var bodyParser = require('body-parser');
511
var program = require('commander');
612
var path = require('path');
713
var app = express();
@@ -15,18 +21,66 @@ process.on('unhandledRejection', function (reason, p) {
1521
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
1622
});
1723

18-
program.version(version).option('-p, --port [value]', 'Nelson GUI port', parseNumber, 5000).parse(process.argv);
24+
program.version(version).option('-p, --port [value]', 'Nelson GUI port', parseNumber, 5000).option('-a, --apiPort [value]', 'Nelson API port', parseNumber, 18600).option('-h, --apiHostname [value]', 'Nelson API hostname', 'mainnet.deviota.com').parse(process.argv);
1925

2026
// Define the port to run on
2127
app.set('port', process.env.NELSON_GUI_PORT || program.port);
2228

2329
app.use(express.static(path.join(__dirname)));
24-
app.all('/*/*', function (req, res) {
25-
res.sendfile(path.join(__dirname, 'index.html'));
26-
});
30+
app.use(bodyParser.urlencoded({ extended: false }));
31+
app.use(bodyParser.json());
32+
app.get('/api', proxy);
33+
app.get('/api/peers', proxy);
2734

35+
var salt = crypto.randomBytes(48).toString('hex');
2836
// Listen for requests
2937
var server = app.listen(app.get('port'), function () {
3038
console.log('Nelson GUI running on port ' + server.address().port);
3139
});
3240

41+
var scramble = function scramble(str) {
42+
return md5(salt + ':' + str).substr(0, 6);
43+
};
44+
45+
function scramblePeer(peer) {
46+
return _extends({}, peer, {
47+
ip: scramble(peer.ip),
48+
hostname: scramble(peer.hostname)
49+
});
50+
}
51+
52+
function proxy(req, resp) {
53+
var path = req.originalUrl.replace('/api', '');
54+
var url = 'http://' + program.apiHostname + ':' + program.apiPort + path;
55+
var opts = { url: url };
56+
if (req.query.auth) {
57+
var tokens = req.query.auth.split(':');
58+
opts.auth = { user: tokens[0], pass: tokens[1] };
59+
}
60+
request(opts, function (err, r, body) {
61+
if (err) {
62+
console.log('Unexpected error happened: ' + err);
63+
resp.status(500);
64+
return;
65+
}
66+
if (r.statusCode === 401) {
67+
console.log('Remote access denied');
68+
resp.status(401);
69+
return;
70+
}
71+
try {
72+
var json = JSON.parse(body);
73+
var response = json;
74+
if (path.startsWith('peers') && !req.query.auth) {
75+
response = json.map(scramblePeer);
76+
} else if (response.connectedPeers && !req.query.auth) {
77+
response.connectedPeers = response.connectedPeers.map(scramblePeer);
78+
}
79+
resp.status(200).json(response);
80+
} catch (e) {
81+
console.log('Remote returned unexpected response(' + r.statusCode + ')', e);
82+
resp.status(500);
83+
}
84+
});
85+
}
86+

build/service-worker.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/static/css/main.078b9fee.css.map

-1
This file was deleted.

build/static/css/main.078b9fee.css build/static/css/main.ef153f8d.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/static/css/main.ef153f8d.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/static/js/main.50ce7918.js

-2
This file was deleted.

build/static/js/main.50ce7918.js.map

-1
This file was deleted.

build/static/js/main.db092208.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/static/js/main.db092208.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nelson.gui",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/SemkoDev/nelson.gui.git"
@@ -28,22 +28,26 @@
2828
"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive"
2929
},
3030
"dependencies": {
31+
"body-parser": "^1.18.2",
3132
"classnames": "^2.2.5",
3233
"commander": "^2.12.2",
3334
"lodash": "^4.17.4",
3435
"material-ui": "^0.20.0",
36+
"md5": "^2.2.1",
3537
"moment": "^2.20.1",
3638
"moment-duration-format": "^2.0.1",
3739
"node-sass-chokidar": "^0.0.3",
3840
"prop-types": "^15.6.0",
3941
"react": "^16.2.0",
42+
"react-copy-to-clipboard": "^5.0.1",
4043
"react-dom": "^16.2.0",
4144
"react-redux": "^5.0.6",
4245
"react-router-dom": "^4.2.2",
4346
"react-scripts": "1.0.17",
4447
"react-vis-force": "^0.3.1",
4548
"redux": "^3.7.2",
4649
"redux-thunk": "^2.2.0",
50+
"request": "^2.83.0",
4751
"reselect": "^3.0.1"
4852
},
4953
"devDependencies": {

0 commit comments

Comments
 (0)