Better logging

This commit is contained in:
Bryan Ashby 2018-12-15 02:40:36 -07:00
parent faf076f3e3
commit cf6e3d3ba8
1 changed files with 16 additions and 10 deletions

View File

@ -276,7 +276,7 @@ class NNTPServer extends NNTPServerBase {
_getArticle(session, messageId) {
return new Promise( resolve => {
this.log.trace( { messageId }, 'Get article request');
this.log.trace( { messageId }, 'Get article');
const messageUuid = this.getMessageUUIDFromMessageID(session, messageId);
if(!messageUuid) {
@ -291,14 +291,18 @@ class NNTPServer extends NNTPServerBase {
return message.load( { uuid : messageUuid }, callback);
},
(callback) => {
// :TODO: Must validate access! See Gopher, etc. !!!!!
// :TODO: we can only do this if a <message-id> style was sent in, not a direct ID ??????
if(!_.has(session, 'groupInfo.areaTag')) {
// :TODO: if this is needed, how to validate properly?
this.log.warn( { messageUuid, messageId }, 'Get article request without group selection');
return resolve(null);
}
if(session.groupInfo.areaTag !== message.areaTag) {
return resolve(null);
}
if(!this.hasConfAndAreaReadAccess(session, session.groupInfo.confTag, session.groupInfo.areaTag)) {
this.log.info(`Access denied to message ${messageUuid}`);
this.log.info( { messageUuid, messageId}, 'Access denied for message');
return resolve(null);
}
@ -519,6 +523,7 @@ class NNTPServer extends NNTPServerBase {
friendlyDesc : area.desc,
nntp : {
name : groupName,
description : area.desc,
min_index : 0,
max_index : 0,
total : 0,
@ -568,12 +573,13 @@ class NNTPServer extends NNTPServerBase {
const value = {
':bytes' : Buffer.byteLength(body).toString(),
':lines' : splitTextAtTerms(body).length.toString(),
}[field] || _.find(message.nntpHeaders, (v, k) => {
}[field]
|| _.find(message.nntpHeaders, (v, k) => {
return k.toLowerCase() === field;
});
if(!value) {
this.log.debug(`No value for requested header field "${field}"`);
this.log.trace(`No value for requested header field "${field}"`);
}
return value;