Logging refractoring

This commit is contained in:
Chocobozzz 2015-12-06 21:36:57 +01:00
parent 876d1bcfd0
commit 1cb4884db5
5 changed files with 4 additions and 12 deletions

View file

@ -25,15 +25,13 @@
}
misc.decryptBody = function (req, res, next) {
logger.debug('Decrypting body.')
PodsDB.findOne({ url: req.body.signature.url }, function (err, pod) {
if (err) {
logger.error('Cannot get signed url in decryptBody.', { error: err })
res.sendStatus(500)
}
logger.debug('Found one pod which could send the message.', { pod: pod.publicKey, url: req.body.signature.url })
logger.debug('Decrypting body from %s.', req.body.signature.url)
var crt = ursa.createPublicKey(pod.publicKey)
var signature_ok = crt.hashAndVerify('sha256', new Buffer(req.body.signature.url).toString('hex'), req.body.signature.signature, 'hex')
@ -41,9 +39,8 @@
if (signature_ok === true) {
var myKey = ursa.createPrivateKey(fs.readFileSync(utils.certDir + 'peertube.key.pem'))
var decryptedKey = myKey.decrypt(req.body.key, 'hex', 'utf8')
logger.debug(decryptedKey)
req.body.data = JSON.parse(utils.symetricDecrypt(req.body.data, decryptedKey))
logger.debug('Decrypted.', { body: req.body })
delete req.body.key
} else {
logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.url)
res.sendStatus(500)

View file

@ -12,7 +12,7 @@
req.checkBody('key', 'Should have a key').notEmpty()
req.checkBody('data', 'Should have data').notEmpty()
logger.debug('Checking secureRequest parameters', { parameters: req.body })
logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } })
checkErrors(req, res, next)
}

View file

@ -97,7 +97,6 @@
var pods_list = computeWinningPods(urls, pods_score)
logger.debug('Pods that we keep computed.', { pods_to_keep: pods_list })
logger.debug('Make requests...')
makeRequestsToWinningPods(cert, pods_list)
})
})

View file

@ -74,7 +74,6 @@
}
function makePoolRequest (type, requests) {
logger.debug('Make pool requests scheduled.')
PodsDB.find({}, { _id: 1, url: 1, publicKey: 1 }).exec(function (err, pods) {
if (err) throw err

View file

@ -30,7 +30,7 @@
}
}
logger.debug('Sending informations to %s.', to_pod.url, { params: params })
logger.debug('Make retry requests to %s.', to_pod.url)
// Default 10 but in tests we want to be faster
var retries = utils.isTestInstance() ? 2 : 10
@ -84,8 +84,6 @@
// Add data with POST requst ?
if (all_data.method === 'POST' && all_data.data) {
logger.debug('Make a POST request.')
// Encrypt data ?
if (all_data.encrypt === true) {
var crt = ursa.createPublicKey(pod.publicKey)
@ -109,7 +107,6 @@
makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
}
} else {
logger.debug('Make a GET/DELETE request')
makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
}
}, callback)