Skip to content

Commit

Permalink
Add types for get_client_ip parameters (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
federicobond authored Feb 4, 2024
1 parent 410e179 commit 2430b9c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ipware/ip.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from typing import Iterable, Literal, Optional, Tuple

from django.conf import settings
from django.http import HttpRequest
from python_ipware import IpWare


def get_client_ip(
request,
proxy_order='left-most',
proxy_count=None,
proxy_trusted_ips=None,
request_header_order=None,
):
request: HttpRequest,
proxy_order: Literal['left-most', 'right-most'] = 'left-most',
proxy_count: Optional[int] = None,
proxy_trusted_ips: Optional[Iterable[str]] = None,
request_header_order: Optional[Iterable[str]] = None,
) -> Tuple[str, bool]:
leftmost = proxy_order == 'left-most'
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 []
Expand Down

0 comments on commit 2430b9c

Please sign in to comment.