Skip to content

Commit

Permalink
Add IPWARE_META_PROXY_COUNT setting + corresponding docs (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcclelland1002 authored Nov 29, 2023
1 parent 19d9a61 commit 8210a30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ get_client_ip(request, request_header_order=['X_FORWARDED_FOR'])
get_client_ip(request, request_header_order=['X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR'])
```

- ### Proxy Count

The default meta proxy count is 0 unless explictly provided as an argument to `get_client_ip()`. You may customize the order
by providing your own `IPWARE_META_PROXY_COUNT` by adding it to your project's settings.py

### Trusted Proxies

If your Django server is behind one or more known proxy server(s), you can filter out unwanted requests
Expand Down
2 changes: 1 addition & 1 deletion ipware/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def get_client_ip(
request_header_order=None,
):
leftmost = proxy_order == 'left-most'
proxy_count = proxy_count if proxy_count is not None else 0
proxy_count = proxy_count if proxy_count is not None else getattr(settings, 'IPWARE_META_PROXY_COUNT', 0)
proxy_list = proxy_trusted_ips if proxy_trusted_ips is not None else []
request_header_order = getattr(settings, 'IPWARE_META_PRECEDENCE_ORDER', request_header_order)

Expand Down

0 comments on commit 8210a30

Please sign in to comment.