Commit 59f20f55 authored by Cédric Moreau's avatar Cédric Moreau

Fix: infinite ping-pong of keyblock when non-valid block

parent f1181ae2
module.exports = {
ERROR: {
PUBKEY: {
ALREADY_UPDATED: 1
}
}
};
...@@ -11,6 +11,7 @@ var md5 = require('../lib/md5'); ...@@ -11,6 +11,7 @@ var md5 = require('../lib/md5');
var unix2dos = require('../lib/unix2dos'); var unix2dos = require('../lib/unix2dos');
var parsers = require('../lib/streams/parsers/doc'); var parsers = require('../lib/streams/parsers/doc');
var keyhelper = require('../lib/keyhelper'); var keyhelper = require('../lib/keyhelper');
var constants = require('../lib/constants');
var logger = require('../lib/logger')('pubkey'); var logger = require('../lib/logger')('pubkey');
var PublicKeySchema = new Schema({ var PublicKeySchema = new Schema({
...@@ -272,8 +273,8 @@ PublicKeySchema.statics.persist = function (pubkey, done) { ...@@ -272,8 +273,8 @@ PublicKeySchema.statics.persist = function (pubkey, done) {
} }
// If already treated this ASCII armored value // If already treated this ASCII armored value
if (~foundKeys[0].hashes.indexOf(comingHash)) { if (~foundKeys[0].hashes.indexOf(comingHash)) {
// next('Key already up-to-date'); next(constants.ERROR.PUBKEY.ALREADY_UPDATED);
// return; return;
} else { } else {
// Remembering incoming hash // Remembering incoming hash
foundKeys[0].hashes.push(comingHash); foundKeys[0].hashes.push(comingHash);
......
...@@ -10,6 +10,7 @@ var parsers = require('../lib/streams/parsers/doc'); ...@@ -10,6 +10,7 @@ var parsers = require('../lib/streams/parsers/doc');
var keyhelper = require('../lib/keyhelper'); var keyhelper = require('../lib/keyhelper');
var logger = require('../lib/logger')('keychain'); var logger = require('../lib/logger')('keychain');
var signature = require('../lib/signature'); var signature = require('../lib/signature');
var constants = require('../lib/constants');
var moment = require('moment'); var moment = require('moment');
var inquirer = require('inquirer'); var inquirer = require('inquirer');
...@@ -184,7 +185,7 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) { ...@@ -184,7 +185,7 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) {
next(); next();
} }
], function (err) { ], function (err) {
done(err, block); done(err, !err && block);
}); });
}; };
...@@ -678,7 +679,12 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) { ...@@ -678,7 +679,12 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) {
parsers.parsePubkey(next).asyncWrite(unix2dos(key.getArmored()), next); parsers.parsePubkey(next).asyncWrite(unix2dos(key.getArmored()), next);
}, },
function (obj, next){ function (obj, next){
PublicKeyService.submitPubkey(obj, next); PublicKeyService.submitPubkey(obj, function (err) {
if (err == constants.ERROR.PUBKEY.ALREADY_UPDATED)
next();
else
next(err);
});
}, },
], callback); ], callback);
}, },
......
...@@ -4,6 +4,7 @@ var util = require('util'); ...@@ -4,6 +4,7 @@ var util = require('util');
var _ = require('underscore'); var _ = require('underscore');
var mongoose = require('mongoose'); var mongoose = require('mongoose');
var common = require('./app/lib/common'); var common = require('./app/lib/common');
var constants = require('./app/lib/constants');
var express = require('express'); var express = require('express');
var request = require('request'); var request = require('request');
var http = require('http'); var http = require('http');
...@@ -80,7 +81,11 @@ function Server (dbConf, overrideConf, interceptors, onInit) { ...@@ -80,7 +81,11 @@ function Server (dbConf, overrideConf, interceptors, onInit) {
}, },
], function (err, res) { ], function (err, res) {
if (err){ if (err){
logger.debug(err); switch (err) {
case constants.ERROR.PUBKEY.ALREADY_UPDATED: msg = 'Key already up-to-date';
default: msg = err.toString();
}
logger.debug(msg);
} }
if (res != null && res != undefined) { if (res != null && res != undefined) {
that.push(res); that.push(res);
......
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