edx_django_utils.ip.internal package#
Subpackages#
Submodules#
edx_django_utils.ip.internal.ip module#
Implementation of edx_django_utils.ip
– contains non-public
functions, and is subject to breaking changes without warning.
Import from edx_django_utils.ip
instead of this one.
See that module’s docstring for additional background.
- edx_django_utils.ip.internal.ip.get_all_client_ips(request)#
Get the request’s external chain, a non-empty list of IP address strings.
Most consumers of IP addresses should just use
get_safest_client_ip
.Calls
init_client_ips
if needed.
- edx_django_utils.ip.internal.ip.get_raw_ip_chain(request)#
Retrieve the full IP chain from this request, as list of raw strings.
This is uninterpreted and unparsed, except for splitting on commas and removing extraneous whitespace.
- edx_django_utils.ip.internal.ip.get_safest_client_ip(request)#
Get the safest choice of client IP.
Returns a single string containing the IP address that most likely represents the originator of the HTTP call, without compromising on safety.
This is always the rightmost value in the external IP chain that is returned by
get_all_client_ips
. See module docstring for more details.
- edx_django_utils.ip.internal.ip.init_client_ips(request)#
Compute the request’s external chain and store it in the request.
This should be called early in the middleware stack in order to avoid being called after another middleware that overwrites
REMOTE_ADDR
, which is a pattern some apps use.If called multiple times or if
CLIENT_IPS
is already present inrequest.META
, will just warn.