confirm that fail2ban is protecting pop3s, closes #629
This commit is contained in:
parent
27b4edfc76
commit
fc0abd5b4d
1 changed files with 25 additions and 0 deletions
|
@ -68,6 +68,28 @@ def imap_test():
|
||||||
finally:
|
finally:
|
||||||
M.logout() # shuts down connection, has nothing to do with login()
|
M.logout() # shuts down connection, has nothing to do with login()
|
||||||
|
|
||||||
|
|
||||||
|
def pop_test():
|
||||||
|
import poplib
|
||||||
|
try:
|
||||||
|
M = poplib.POP3_SSL(hostname)
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
# looks like fail2ban worked
|
||||||
|
raise IsBlocked()
|
||||||
|
try:
|
||||||
|
M.user('fakeuser')
|
||||||
|
try:
|
||||||
|
M.pass_('fakepassword')
|
||||||
|
except poplib.error_proto as e:
|
||||||
|
# Authentication should fail.
|
||||||
|
M = None # don't .quit()
|
||||||
|
return
|
||||||
|
M.list()
|
||||||
|
raise Exception("authentication didn't fail")
|
||||||
|
finally:
|
||||||
|
if M:
|
||||||
|
M.quit()
|
||||||
|
|
||||||
def http_test(url, expected_status, postdata=None, qsargs=None, auth=None):
|
def http_test(url, expected_status, postdata=None, qsargs=None, auth=None):
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import requests
|
import requests
|
||||||
|
@ -183,6 +205,9 @@ if __name__ == "__main__":
|
||||||
# IMAP
|
# IMAP
|
||||||
run_test(imap_test, [], 20, 30, 4)
|
run_test(imap_test, [], 20, 30, 4)
|
||||||
|
|
||||||
|
# POP
|
||||||
|
run_test(pop_test, [], 20, 30, 4)
|
||||||
|
|
||||||
# Mail-in-a-Box control panel
|
# Mail-in-a-Box control panel
|
||||||
run_test(http_test, ["/admin/me", 200], 20, 30, 1)
|
run_test(http_test, ["/admin/me", 200], 20, 30, 1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue