Skip to content

Commit

Permalink
Release v1.1.2
Browse files Browse the repository at this point in the history
- doc(README): formatting improvements
- feat(syslog): permit single digit day
- feat(syslog): add a few more debug patterns
  • Loading branch information
msimerson committed Jan 13, 2024
2 parents fa795ca + 324768c commit 85e8c70
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
### Unreleased


### [1.1.2] - 2024-01-12

- feat(syslog): permit single digit day
- feat(syslog): add a few more debug patterns


### [1.1.1] - 2024-01-01

- doc(README): fix syntax example
Expand Down Expand Up @@ -51,3 +57,4 @@

[1.1.0]: https://github.com/msimerson/postfix-parser/releases/tag/1.1.0
[1.1.1]: https://github.com/msimerson/postfix-parser/releases/tag/1.1.1
[1.1.2]: https://github.com/msimerson/postfix-parser/releases/tag/1.1.2
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Returns an object:
}
```

----

## asObjectType

requires two positional arguments:
Expand All @@ -54,6 +56,7 @@ const msg = parser.asObject(parsed.prog, parsed.msg);

`msg` is an object of `parsed.prog` type (see examples below)

----

## Parser Types

Expand All @@ -80,6 +83,8 @@ Returns:

This is comparable to what you'd already have in Elasticsearch if you had imported your logs using Logstash.

----

### qmgr

```js
Expand All @@ -97,6 +102,8 @@ Returns:
}
```

----

### smtp

```js
Expand All @@ -117,6 +124,7 @@ Returns:
status: 'sent (250 2.0.0 t5UI2nBt018923-t5UI2nBw018923 Message accepted for delivery)',
}
```
----

### cleanup

Expand All @@ -133,6 +141,8 @@ Returns:
}
```

----

### error

```js
Expand All @@ -153,6 +163,8 @@ Returns:
}
```

----

### bounce

```js
Expand All @@ -168,6 +180,8 @@ Returns:
}
```

----

### scache

```js
Expand All @@ -182,6 +196,8 @@ Returns:
}
```

----

### pickup

```js
Expand All @@ -198,6 +214,8 @@ Returns:
}
```

----

### local

```js
Expand Down
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const postfixQidLong = '[0-9A-Za-z]{14,16}' // optional 'long' ids
const postfixQidAny = postfixQidLong + '|' + postfixQid

const regex = {
syslog : /^([A-Za-z]{3} [0-9 ]{2} [\d:]{8}) ([^\s]+) ([^[]+)\[([\d]+)\]: (.*)$/,
syslog : /^([A-Za-z]{3} [0-9 ]{1,2} [\d:]{8}) ([^\s]+) ([^[]+)\[([\d]+)\]: (.*)$/,
'submission/smtpd': new RegExp(
'^(?:(' + postfixQidAny + '): )?' +
'(client)=([^,]+), ' +
Expand Down Expand Up @@ -46,8 +46,12 @@ const regex = {
'smtp-debug' : new RegExp(
'(?:(' + postfixQidAny + '): )?' +
'(enabling PIX workarounds|' +
'setting up TLS|' +
'Cannot start TLS: handshake failure|' +
'lost connection with .*|' +
'lost connection .*|' +
'^connect from .*|' +
'^disconnect from .*|' +
'^SSL_accept|' +
'^SSL_connect error to .*|' +
'^warning: .*|' +
'conversation with |' +
Expand Down Expand Up @@ -189,8 +193,8 @@ function syslogAsObject (match) {
date: match[1],
host: match[2],
prog: match[3],
pid : match[4],
msg : match[5],
pid : match[4],
msg : match[5],
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"maillog",
"mail.log"
],
"version": "1.1.1",
"version": "1.1.2",
"private": false,
"homepage": "https://github.com/msimerson/postfix-parser",
"author": {
Expand Down
40 changes: 38 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ describe('syslog lines', function () {
context('asObject', function () {
syslogLines.forEach(function (test) {
it(test.name, function () {
var res = re.asObject(test.line)
const res = re.asObject(test.line)
assert.deepEqual(res, test.obj, util.inspect(res, { depth: null }))
})
})
})
})

var postfixLines = [
const postfixLines = [
{
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)',
type: 'postfix/smtp',
Expand Down Expand Up @@ -658,6 +658,42 @@ var postfixLines = [
msg: 'released from hold',
},
},
{
line: 'Jan 6 08:39:06 mail postfix/smtpd[339505]: 93C8388C38: client=unknown[192.168.1.0]',
type: 'syslog',
desc: 'postfix/smtpd',
obj : {
'date': 'Jan 6 08:39:06',
'host': 'mail',
'msg' : '93C8388C38: client=unknown[192.168.1.0]',
'pid' : '339505',
'prog': 'postfix/smtpd',
},
},
{
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',
type: 'syslog',
desc: 'postfix/smtpd disconnect',
obj : {
'date': 'Jan 6 08:39:06',
'host': 'mail',
'msg' : 'disconnect from unknown[192.168.1.0] ehlo=1 mail=1 rcpt=1 data=1 quit=1',
'pid' : '339505',
'prog': 'postfix/smtpd',
},
},
{
line: 'Jan 6 08:39:49 mail postfix/smtpd[339505]: connect from localhost[127.0.0.1]',
type: 'syslog',
desc: 'postfix/smtpd connect',
obj : {
'date': 'Jan 6 08:39:49',
'host': 'mail',
'msg' : 'connect from localhost[127.0.0.1]',
'pid' : '339505',
'prog': 'postfix/smtpd',
},
},
]

describe('postfix lines', function () {
Expand Down

0 comments on commit 85e8c70

Please sign in to comment.