Skip to content

Commit 212b7b3

Browse files
committed
- feat(syslog): permit single digit day
- feat(syslog): add a few more debug patterns
1 parent fa795ca commit 212b7b3

File tree

4 files changed

+54
-7
lines changed

4 files changed

+54
-7
lines changed

Changes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
### Unreleased
33

44

5+
### [1.1.2] - 2024-01-12
6+
7+
- feat(syslog): permit single digit day
8+
- feat(syslog): add a few more debug patterns
9+
10+
511
### [1.1.1] - 2024-01-01
612

713
- doc(README): fix syntax example
@@ -51,3 +57,4 @@
5157

5258
[1.1.0]: https://github.com/msimerson/postfix-parser/releases/tag/1.1.0
5359
[1.1.1]: https://github.com/msimerson/postfix-parser/releases/tag/1.1.1
60+
[1.1.2]: https://github.com/msimerson/postfix-parser/releases/tag/1.1.2

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const postfixQidLong = '[0-9A-Za-z]{14,16}' // optional 'long' ids
77
const postfixQidAny = postfixQidLong + '|' + postfixQid
88

99
const regex = {
10-
syslog : /^([A-Za-z]{3} [0-9 ]{2} [\d:]{8}) ([^\s]+) ([^[]+)\[([\d]+)\]: (.*)$/,
10+
syslog : /^([A-Za-z]{3} [0-9 ]{1,2} [\d:]{8}) ([^\s]+) ([^[]+)\[([\d]+)\]: (.*)$/,
1111
'submission/smtpd': new RegExp(
1212
'^(?:(' + postfixQidAny + '): )?' +
1313
'(client)=([^,]+), ' +
@@ -46,8 +46,12 @@ const regex = {
4646
'smtp-debug' : new RegExp(
4747
'(?:(' + postfixQidAny + '): )?' +
4848
'(enabling PIX workarounds|' +
49+
'setting up TLS|' +
4950
'Cannot start TLS: handshake failure|' +
50-
'lost connection with .*|' +
51+
'lost connection .*|' +
52+
'^connect from .*|' +
53+
'^disconnect from .*|' +
54+
'^SSL_accept|' +
5155
'^SSL_connect error to .*|' +
5256
'^warning: .*|' +
5357
'conversation with |' +
@@ -189,8 +193,8 @@ function syslogAsObject (match) {
189193
date: match[1],
190194
host: match[2],
191195
prog: match[3],
192-
pid : match[4],
193-
msg : match[5],
196+
pid : match[4],
197+
msg : match[5],
194198
}
195199
}
196200

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"maillog",
99
"mail.log"
1010
],
11-
"version": "1.1.1",
11+
"version": "1.1.2",
1212
"private": false,
1313
"homepage": "https://github.com/msimerson/postfix-parser",
1414
"author": {

test/index.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ describe('syslog lines', function () {
126126
context('asObject', function () {
127127
syslogLines.forEach(function (test) {
128128
it(test.name, function () {
129-
var res = re.asObject(test.line)
129+
const res = re.asObject(test.line)
130130
assert.deepEqual(res, test.obj, util.inspect(res, { depth: null }))
131131
})
132132
})
133133
})
134134
})
135135

136-
var postfixLines = [
136+
const postfixLines = [
137137
{
138138
line: '3mPVKl0Mhjz7sXv: to=<susan.bck@example.org>, relay=mpafm.example.org[24.100.200.21]:25, conn_use=2, delay=1.2, delays=0.76/0.01/0.09/0.34, dsn=2.0.0, status=sent (250 2.0.0 t5UI2nBt018923-t5UI2nBw018923 Message accepted for delivery)',
139139
type: 'postfix/smtp',
@@ -658,6 +658,42 @@ var postfixLines = [
658658
msg: 'released from hold',
659659
},
660660
},
661+
{
662+
line: "Jan 6 08:39:06 mail postfix/smtpd[339505]: 93C8388C38: client=unknown[192.168.1.0]",
663+
type: 'syslog',
664+
desc: 'postfix/smtpd',
665+
obj: {
666+
"date": "Jan 6 08:39:06",
667+
"host": "mail",
668+
"msg": "93C8388C38: client=unknown[192.168.1.0]",
669+
"pid": "339505",
670+
"prog": "postfix/smtpd",
671+
},
672+
},
673+
{
674+
line: "Jan 6 08:39:06 mail postfix/smtpd[339505]: disconnect from unknown[192.168.1.0] ehlo=1 mail=1 rcpt=1 data=1 quit=1",
675+
type: 'syslog',
676+
desc: 'postfix/smtpd disconnect',
677+
obj: {
678+
"date": "Jan 6 08:39:06",
679+
"host": "mail",
680+
"msg": "disconnect from unknown[192.168.1.0] ehlo=1 mail=1 rcpt=1 data=1 quit=1",
681+
"pid": "339505",
682+
"prog": "postfix/smtpd",
683+
},
684+
},
685+
{
686+
line: "Jan 6 08:39:49 mail postfix/smtpd[339505]: connect from localhost[127.0.0.1]",
687+
type: 'syslog',
688+
desc: 'postfix/smtpd connect',
689+
obj: {
690+
"date": "Jan 6 08:39:49",
691+
"host": "mail",
692+
"msg": "connect from localhost[127.0.0.1]",
693+
"pid": "339505",
694+
"prog": "postfix/smtpd",
695+
},
696+
},
661697
]
662698

663699
describe('postfix lines', function () {

0 commit comments

Comments
 (0)