mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Make number of app proxies configurable by the user, default to zero
This commit is contained in:
parent
e7b131eb20
commit
a1b4695cf8
|
@ -63,6 +63,7 @@ DEFAULTS = {
|
|||
'user': None,
|
||||
'anon': None,
|
||||
},
|
||||
'NUM_PROXIES': 0,
|
||||
|
||||
# Pagination
|
||||
'PAGINATE_BY': None,
|
||||
|
|
|
@ -21,7 +21,9 @@ class BaseThrottle(object):
|
|||
def get_ident(self, request):
|
||||
if 'HTTP_X_FORWARDED_FOR' in request.META:
|
||||
xff = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||
return xff.split(',')[0].strip()
|
||||
num_proxies = api_settings.NUM_PROXIES
|
||||
|
||||
return xff.split(',')[-min(num_proxies, len(xff))].strip()
|
||||
|
||||
return request.META.get('REMOTE_ADDR', None)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user