aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-12-06 21:36:57 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-12-07 17:22:36 +0100
commit1cb4884db56c774e89db80bd0e79a9765441548d (patch)
treee292069f7fc3dee470b0e414cfb3add5e46b3e91
parent876d1bcfd07b14d47ba377474e3bb680872d1f7a (diff)
downloadPeerTube-1cb4884db56c774e89db80bd0e79a9765441548d.tar.gz
PeerTube-1cb4884db56c774e89db80bd0e79a9765441548d.tar.zst
PeerTube-1cb4884db56c774e89db80bd0e79a9765441548d.zip
Logging refractoring
-rw-r--r--middlewares/misc.js7
-rw-r--r--middlewares/reqValidators/remote.js2
-rw-r--r--src/pods.js1
-rw-r--r--src/poolRequests.js1
-rw-r--r--src/utils.js5
5 files changed, 4 insertions, 12 deletions
diff --git a/middlewares/misc.js b/middlewares/misc.js
index 69e8d78c1..9755eeff0 100644
--- a/middlewares/misc.js
+++ b/middlewares/misc.js
@@ -25,15 +25,13 @@
25 } 25 }
26 26
27 misc.decryptBody = function (req, res, next) { 27 misc.decryptBody = function (req, res, next) {
28 logger.debug('Decrypting body.')
29
30 PodsDB.findOne({ url: req.body.signature.url }, function (err, pod) { 28 PodsDB.findOne({ url: req.body.signature.url }, function (err, pod) {
31 if (err) { 29 if (err) {
32 logger.error('Cannot get signed url in decryptBody.', { error: err }) 30 logger.error('Cannot get signed url in decryptBody.', { error: err })
33 res.sendStatus(500) 31 res.sendStatus(500)
34 } 32 }
35 33
36 logger.debug('Found one pod which could send the message.', { pod: pod.publicKey, url: req.body.signature.url }) 34 logger.debug('Decrypting body from %s.', req.body.signature.url)
37 35
38 var crt = ursa.createPublicKey(pod.publicKey) 36 var crt = ursa.createPublicKey(pod.publicKey)
39 var signature_ok = crt.hashAndVerify('sha256', new Buffer(req.body.signature.url).toString('hex'), req.body.signature.signature, 'hex') 37 var signature_ok = crt.hashAndVerify('sha256', new Buffer(req.body.signature.url).toString('hex'), req.body.signature.signature, 'hex')
@@ -41,9 +39,8 @@
41 if (signature_ok === true) { 39 if (signature_ok === true) {
42 var myKey = ursa.createPrivateKey(fs.readFileSync(utils.certDir + 'peertube.key.pem')) 40 var myKey = ursa.createPrivateKey(fs.readFileSync(utils.certDir + 'peertube.key.pem'))
43 var decryptedKey = myKey.decrypt(req.body.key, 'hex', 'utf8') 41 var decryptedKey = myKey.decrypt(req.body.key, 'hex', 'utf8')
44 logger.debug(decryptedKey)
45 req.body.data = JSON.parse(utils.symetricDecrypt(req.body.data, decryptedKey)) 42 req.body.data = JSON.parse(utils.symetricDecrypt(req.body.data, decryptedKey))
46 logger.debug('Decrypted.', { body: req.body }) 43 delete req.body.key
47 } else { 44 } else {
48 logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.url) 45 logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.url)
49 res.sendStatus(500) 46 res.sendStatus(500)
diff --git a/middlewares/reqValidators/remote.js b/middlewares/reqValidators/remote.js
index 642dad1c7..a9d2cdf20 100644
--- a/middlewares/reqValidators/remote.js
+++ b/middlewares/reqValidators/remote.js
@@ -12,7 +12,7 @@
12 req.checkBody('key', 'Should have a key').notEmpty() 12 req.checkBody('key', 'Should have a key').notEmpty()
13 req.checkBody('data', 'Should have data').notEmpty() 13 req.checkBody('data', 'Should have data').notEmpty()
14 14
15 logger.debug('Checking secureRequest parameters', { parameters: req.body }) 15 logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } })
16 16
17 checkErrors(req, res, next) 17 checkErrors(req, res, next)
18 } 18 }
diff --git a/src/pods.js b/src/pods.js
index 9afc6cc96..a0dbb6b68 100644
--- a/src/pods.js
+++ b/src/pods.js
@@ -97,7 +97,6 @@
97 var pods_list = computeWinningPods(urls, pods_score) 97 var pods_list = computeWinningPods(urls, pods_score)
98 logger.debug('Pods that we keep computed.', { pods_to_keep: pods_list }) 98 logger.debug('Pods that we keep computed.', { pods_to_keep: pods_list })
99 99
100 logger.debug('Make requests...')
101 makeRequestsToWinningPods(cert, pods_list) 100 makeRequestsToWinningPods(cert, pods_list)
102 }) 101 })
103 }) 102 })
diff --git a/src/poolRequests.js b/src/poolRequests.js
index ee6c0156e..391ed6ab2 100644
--- a/src/poolRequests.js
+++ b/src/poolRequests.js
@@ -74,7 +74,6 @@
74 } 74 }
75 75
76 function makePoolRequest (type, requests) { 76 function makePoolRequest (type, requests) {
77 logger.debug('Make pool requests scheduled.')
78 PodsDB.find({}, { _id: 1, url: 1, publicKey: 1 }).exec(function (err, pods) { 77 PodsDB.find({}, { _id: 1, url: 1, publicKey: 1 }).exec(function (err, pods) {
79 if (err) throw err 78 if (err) throw err
80 79
diff --git a/src/utils.js b/src/utils.js
index 4aa1fc55e..30edcd0e9 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -30,7 +30,7 @@
30 } 30 }
31 } 31 }
32 32
33 logger.debug('Sending informations to %s.', to_pod.url, { params: params }) 33 logger.debug('Make retry requests to %s.', to_pod.url)
34 // Default 10 but in tests we want to be faster 34 // Default 10 but in tests we want to be faster
35 var retries = utils.isTestInstance() ? 2 : 10 35 var retries = utils.isTestInstance() ? 2 : 10
36 36
@@ -84,8 +84,6 @@
84 84
85 // Add data with POST requst ? 85 // Add data with POST requst ?
86 if (all_data.method === 'POST' && all_data.data) { 86 if (all_data.method === 'POST' && all_data.data) {
87 logger.debug('Make a POST request.')
88
89 // Encrypt data ? 87 // Encrypt data ?
90 if (all_data.encrypt === true) { 88 if (all_data.encrypt === true) {
91 var crt = ursa.createPublicKey(pod.publicKey) 89 var crt = ursa.createPublicKey(pod.publicKey)
@@ -109,7 +107,6 @@
109 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest) 107 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
110 } 108 }
111 } else { 109 } else {
112 logger.debug('Make a GET/DELETE request')
113 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest) 110 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
114 } 111 }
115 }, callback) 112 }, callback)