Browse Source

Fix #3

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
adc280cfac
  1. 2
      app.js
  2. 21
      routes/baseActionsRouter.js
  3. 8
      views/terminal.pug

2
app.js

@ -70,6 +70,8 @@ app.use(function(req, res, next) {
}); });
} }
res.locals.env = env;
res.locals.host = req.session.host; res.locals.host = req.session.host;
res.locals.port = req.session.port; res.locals.port = req.session.port;

21
routes/baseActionsRouter.js

@ -8,7 +8,7 @@ var bitcoin = require("bitcoin");
var rpcApi = require("./../app/rpcApi"); var rpcApi = require("./../app/rpcApi");
router.get("/", function(req, res) { router.get("/", function(req, res) {
if (!req.session.host) { if (req.session.host == null || req.session.host.trim() == "") {
if (req.cookies['rpc-host']) { if (req.cookies['rpc-host']) {
res.locals.host = req.cookies['rpc-host']; res.locals.host = req.cookies['rpc-host'];
} }
@ -140,6 +140,25 @@ router.post("/connect", function(req, res) {
res.redirect("/"); res.redirect("/");
}); });
router.get("/disconnect", function(req, res) {
res.cookie('rpc-host', "");
res.cookie('rpc-port', "");
res.cookie('rpc-username', "");
req.session.host = "";
req.session.port = "";
req.session.username = "";
console.log("destroyed client.");
global.client = null;
req.session.userMessage = "Disconnected from node.";
req.session.userMessageType = "success";
res.redirect("/");
});
router.get("/blocks", function(req, res) { router.get("/blocks", function(req, res) {
var limit = 20; var limit = 20;
var offset = 0; var offset = 0;

8
views/terminal.pug

@ -1,7 +1,15 @@
extends layout extends layout
block content block content
div(class="row mt-5")
div(class="col")
h1 RPC Terminal h1 RPC Terminal
div(class="col")
if (!env.bitcoind || !env.bitcoind.rpc)
span(style="float: right;")
a(href="/disconnect") Disconnect from node
hr hr
:markdown-it :markdown-it

Loading…
Cancel
Save