Skip to content
Snippets Groups Projects
Verified Commit b81ef50f authored by Marco De Donno's avatar Marco De Donno
Browse files

Refactoring of the get_rate_limit_key() function

parent af6800bb
No related branches found
No related tags found
No related merge requests found
......@@ -87,17 +87,19 @@ def do_login():
# Rate limiting check
def get_rate_limit_key():
target = request.form.get( "username", "" )
try:
hra = request.headers.environ[ "REMOTE_ADDR" ]
try:
hra = str( ipaddress.ip_network( unicode( hra ) ).supernet( 16 ) )
except:
pass
target = request.headers.environ[ "REMOTE_ADDR" ]
except:
pass
return "rate_limit_{}".format( hra )
try:
target = str( ipaddress.ip_network( unicode( target ) ).supernet( 16 ) )
except:
return "rate_limit_{}".format( request.form.get( "username", "" ) )
pass
return "rate_limit_{}".format( target )
def get_current_rate_limit():
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment