enable autoban.py to always ignore ips given in whilelist option
This commit is contained in:
parent
1222fb19a6
commit
af7d97a5aa
1 changed files with 4 additions and 0 deletions
|
@ -33,12 +33,16 @@ if __name__ == '__main__':
|
||||||
parser.add_argument('-c', '--count', default=3, type=int,
|
parser.add_argument('-c', '--count', default=3, type=int,
|
||||||
help='with how many failure times it should be '
|
help='with how many failure times it should be '
|
||||||
'considered as an attack')
|
'considered as an attack')
|
||||||
|
parser.add_argument('-wl', '--whitelist', action='append',
|
||||||
|
help='whiltelist ip that shall not be banned.')
|
||||||
config = parser.parse_args()
|
config = parser.parse_args()
|
||||||
ips = {}
|
ips = {}
|
||||||
banned = set()
|
banned = set()
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
if 'can not parse header when' in line:
|
if 'can not parse header when' in line:
|
||||||
ip = line.split()[-1].split(':')[-2]
|
ip = line.split()[-1].split(':')[-2]
|
||||||
|
if ip in config.whitelist:
|
||||||
|
continue
|
||||||
if ip not in ips:
|
if ip not in ips:
|
||||||
ips[ip] = 1
|
ips[ip] = 1
|
||||||
print(ip)
|
print(ip)
|
||||||
|
|
Loading…
Add table
Reference in a new issue