From de37c94b2e72c3196da59e427ac176c3e09ca2f2 Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Thu, 23 Feb 2017 17:18:05 -0500 Subject: [PATCH] Implemented logic to show version of the connected IPFS node on the dashboard --- lib/core/services.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/core/services.js b/lib/core/services.js index 8f5f0801d..a234b6670 100644 --- a/lib/core/services.js +++ b/lib/core/services.js @@ -1,6 +1,6 @@ var Web3 = require('web3'); var async = require('async'); - +var http = require('http'); var utils = require('./utils.js'); var ServicesMonitor = function(options) { @@ -60,11 +60,35 @@ ServicesMonitor.prototype.check = function() { utils.checkIsAvailable('http://localhost:5001', function(available) { if (available) { - result.push('IPFS'.green); - } else { - result.push('IPFS'.red); + //Ideally this method should be in an IPFS API JSONRPC wrapper + //The URL should also be flexible to accept non-default IPFS url + self.logger.trace("Checking IPFS version..."); + http.get('http://localhost:5001/api/v0/version', function(res) { + var body = ''; + res.on('data', function(d) { + body += d; + }); + res.on('end', function() { + var parsed = JSON.parse(body); + if(parsed.Version){ + result.push(("IPFS " + parsed.Version).green); + } + else{ + result.push("IPFS".green); + } + callback(null, result); + }); + res.on('error', function(err) { + self.logger.trace("Check IPFS version error: " + err); + result.push("IPFS".green); + callback(null, result); + }); + }); + } + else { + result.push('IPFS'.red); + callback(null, result); } - callback(null, result); }); }, function checkDevServer(result, callback) {