Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
4925c238
Commit
4925c238
authored
Sep 14, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse_mail: не добавляем IP, но добавляем почту. Улучшил проверки
parent
a4e56278
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
check_web_letters.sh
mail/check_web_letters.sh
+8
-1
parse_mail_log.py
mail/parse_mail_log.py
+7
-3
No files found.
mail/check_web_letters.sh
View file @
4925c238
#!/bin/sh
grep
"Connection refused"
/var/log/mail/all |
grep
"reject: RCPT"
|
grep
"Sender address rejected: unverified address"
\
# Не смогли проверить адрес
# Sep 14 22:42:20 server postfix/smtp[20843]: 2C6FD80098: to=<noreply@openlibrary.org>, relay=mail.archive.org[207.241.224.6]:25, delay=7.5, delays=0.06/0/0.89/6.5, dsn=5.1.1, status=undeliverable (host mail.archive.org[207.241.224.6] said: 550 5.1.1 <noreply@openlibrary.org>: Recipient address rejected: User unknown in virtual mailbox table (in reply to RCPT TO command))
# Не принимаем письмо
# Sep 14 04:11:10 server postfix/smtpd[22127]: NOQUEUE: reject: RCPT from mail.mtml.ru[95.131.27.100]: 450 4.1.7 <noreply@mirtesen.ru>: Sender address rejected: unverified address: connect to mirtesen.ru[95.131.27.20]:25: Connection refused; from=<noreply@mirtesen.ru> to=<lav@etersoft.ru> proto=ESMTP helo=<mailgate1.mtml.ru>
# Sep 14 22:46:17 server postfix/smtpd[20894]: NOQUEUE: reject: RCPT from mail.us.archive.org[207.241.224.6]: 450 4.1.7 <noreply@openlibrary.org>: Sender address rejected: unverified address: host mail.archive.org[207.241.224.6] said: 550 5.1.1 <noreply@openlibrary.org>: Recipient address rejected: User unknown in virtual mailbox table (in reply to RCPT TO command); from=<noreply@openlibrary.org> to=<lav@etersoft.ru> proto=ESMTP helo=<mail.archive.org>
cat
/var/log/mail/all |
grep
"reject: RCPT"
|
grep
"Sender address rejected: unverified address"
\
>
$0
.out
# sed "s!.*RCPT from \(.*\)\[.*from=<\(.*\)> to=<\(.*\)>.*!host=\1 from=\2 to=\3!g"
...
...
mail/parse_mail_log.py
View file @
4925c238
...
...
@@ -22,7 +22,8 @@ def check_http(url):
def
append_ip
(
host
,
ip
,
email
):
today
=
datetime
.
datetime
.
now
()
f
=
open
(
'/etc/postfix/access-our'
,
'a'
)
f
.
write
(
"
\n
# "
+
str
(
today
)
+
": "
+
host
+
"
\n
"
+
ip
+
" OK
\n
"
+
email
+
" OK
\n
"
);
# записываем и хост и e-mail, потому что настроено плохо, и access указан и для IP и для e-mail
f
.
write
(
"
\n
# "
+
str
(
today
)
+
": "
+
host
+
"
\n
#"
+
ip
+
" OK
\n
"
+
email
+
" OK
\n
"
);
f
.
close
()
print
ip
...
...
@@ -41,7 +42,8 @@ def check_if_already(ip):
# if row == (ip+" OK\n"):
# print TRUE
# return True
return
ip
+
" OK
\n
"
in
exists_ip
# FIXME: это хак, надо парсить строки что ли, или составлять список IP для поиска
return
(
"#"
+
ip
+
" OK
\n
"
in
exists_ip
)
or
(
ip
+
" OK
\n
"
in
exists_ip
)
test_string
=
"Sep 14 18:23:28 server postfix/smtpd[20585]: NOQUEUE: reject: RCPT from wiki.openvz.org[199.115.105.169]: 450 4.1.7 <apache@wiki.openvz.org>: Sender address rejected: unverified address: connect to wiki.openvz.org[199.115.105.169]:25: Connection refused; from=<apache@wiki.openvz.org> to=<lav@etersoft.ru> proto=ESMTP helo=<wiki.openvz.org>"
...
...
@@ -74,13 +76,15 @@ if __name__== "__main__":
f
=
open
(
'check_web_letters.sh.out'
,
'r'
)
result
=
[]
totip
=
[]
for
row
in
f
.
readlines
():
#print row
line
=
parse_row
(
row
)
if
line
==
False
:
continue
if
line
not
in
result
:
if
line
[
'ip'
]
not
in
totip
:
result
.
append
(
line
)
totip
.
append
(
line
[
'ip'
])
if
list_only
:
print
line
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment