Commit d9d6570c authored by Cédric Moreau's avatar Cédric Moreau

Sync: add a question to trust remote's key for sync session

parent 800a211a
...@@ -4,6 +4,7 @@ var sha1 = require('sha1'); ...@@ -4,6 +4,7 @@ var sha1 = require('sha1');
var merkle = require('merkle'); var merkle = require('merkle');
var vucoin = require('vucoin'); var vucoin = require('vucoin');
var eventStream = require('event-stream'); var eventStream = require('event-stream');
var inquirer = require('inquirer');
var jpgp = require('./jpgp'); var jpgp = require('./jpgp');
var unix2dos = require('./unix2dos'); var unix2dos = require('./unix2dos');
var parsers = require('./streams/parsers/doc'); var parsers = require('./streams/parsers/doc');
...@@ -71,6 +72,15 @@ module.exports = function Synchroniser (server, host, port, authenticated, conf) ...@@ -71,6 +72,15 @@ module.exports = function Synchroniser (server, host, port, authenticated, conf)
PublicKeyService.submitPubkey(parsed, next); PublicKeyService.submitPubkey(parsed, next);
}); });
}, },
function (pubkey, next){
choose("Remote key is 0x" + pubkey.fingerprint + ", should this key be trusted for the sync session?", true,
function trust () {
next(null, pubkey);
},
function doNotTrust () {
next('You chose not to trust remote\'s pubkey, sync cannot continue');
});
},
//============ //============
// Peer // Peer
...@@ -528,3 +538,14 @@ function NodesMerkle (json) { ...@@ -528,3 +538,14 @@ function NodesMerkle (json) {
return this.merkleRoot; return this.merkleRoot;
} }
} }
function choose (question, defaultValue, ifOK, ifNotOK) {
inquirer.prompt([{
type: "confirm",
name: "q",
message: question,
default: defaultValue,
}], function (answer) {
answer.q ? ifOK() : ifNotOK();
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment