Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
14d58690
Commit
14d58690
authored
19 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
parse milter.log from bms.py into a sequence of connections
parent
28ca3b28
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
report.py
+57
-0
57 additions, 0 deletions
report.py
with
57 additions
and
0 deletions
report.py
0 → 100644
+
57
−
0
View file @
14d58690
# Analyze milter log to find abusers
class
Connection
(
object
);
def
__init__
(
self
,
dt
,
tm
,
id
,
ip
)
self
.
dt
=
dt
self
.
tm
=
tm
self
.
id
=
id
_
,
self
.
host
,
self
.
ip
=
ip
.
split
(
None
,
2
)
def
connections
(
fp
):
conndict
=
{}
for
line
in
fp
:
a
=
line
.
split
(
None
,
4
)
if
len
(
a
)
<
4
:
continue
dt
,
tm
,
id
,
op
=
a
[:
4
]
if
id
,
op
==
'
bms
'
,
'
milter
'
:
# FIXME: optionally yield all partial connections
conndict
=
{}
key
=
id
if
op
==
'
connect
'
:
ip
=
a
[
4
].
rstrip
()
conn
=
Connection
(
dt
,
tm
,
id
,
ip
)
conndict
[
key
]
=
conn
else
:
conn
=
conndict
[
key
]
if
op
==
'
Subject:
'
:
if
len
(
a
)
>
4
:
conn
.
subject
=
a
[
4
].
rstrip
()
elif
op
==
'
mail
'
:
_
,
conn
.
mfrom
=
a
[
4
].
split
(
None
,
2
)
elif
op
==
'
rcpt
'
:
_
,
conn
.
rcpt
=
a
[
4
].
split
(
None
,
2
)
elif
op
in
(
'
eom
'
,
'
dspam
'
,
'
abort
'
):
del
conndict
[
key
]
conn
.
enddt
=
dt
conn
.
endtm
=
tm
conn
.
result
=
op
yield
conn
elif
op
in
(
'
REJECT:
'
,
'
DSPAM:
'
,
'
SPAM:
'
):
conn
.
enddt
=
dt
conn
.
endtm
=
tm
conn
.
result
=
op
conn
.
resmsg
=
a
[
4
].
rstrip
()
yield
conn
else
:
print
line
.
rstrip
()
if
__name__
==
'
__main__
'
:
import
gzip
import
sys
for
fn
in
sys
.
argv
[:
1
]:
if
fn
.
endswith
(
'
.gz
'
):
fp
=
gzip
.
open
(
fn
)
else
:
fp
=
open
(
fn
)
for
conn
in
connections
(
fp
):
print
conn
.
dt
,
conn
.
tm
,
conn
.
id
,
conn
.
subject
,
conn
.
mfrom
,
conn
.
rcpt
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment