Skip to content

Commit

Permalink
fix(logging): set max subject length in graylog logs ZMS-173 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt authored Sep 6, 2024
1 parent c6bfdf8 commit c566491
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ module.exports.init = async app => {
// check with zilter
// if incorrect do app.reject()

const SUBJECT_MAX_ALLOWED_LENGTH = 16000;
const { userName, apiKey, serverHost, zilterUrl, logIncomingData } = app.config;

let subjectMaxLength = app.config.subjectMaxLength;

if (!subjectMaxLength || subjectMaxLength > SUBJECT_MAX_ALLOWED_LENGTH) {
subjectMaxLength = SUBJECT_MAX_ALLOWED_LENGTH;
}

if (logIncomingData) {
// log available data
app.logger.info('Incoming data: ', envelope, messageinfo, envelope.headers.getList());
Expand Down Expand Up @@ -184,7 +191,8 @@ module.exports.init = async app => {
const originhost = serverHost || (envelope.originhost || '').replace('[', '').replace(']', '');
const transhost = (envelope.transhost || '').replace('[', '').replace(']', '') || originhost;

const subject = messageinfo.subject || 'no subject';
let subject = messageinfo.subject || 'no subject';
subject = subject.substring(0, subjectMaxLength);
const messageIdHeaderVal = allHeadersParsed['Message-ID']?.replace('<', '').replace('>', '');

// Call Zilter with required params
Expand Down
3 changes: 2 additions & 1 deletion wildduck-zonemta-zilter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ enabled = "receiver"
userName = ""
apiKey = ""
serverHost = ""
zilterUrl = "" # full zilter url with https
zilterUrl = "" # full zilter url with https
logIncomingData = false
subjectMaxLength = 16000

0 comments on commit c566491

Please sign in to comment.