From aca318647fdf03c42dab9a0b9df0f4553c15e570 Mon Sep 17 00:00:00 2001 From: Alice Date: Mon, 16 Jan 2017 06:16:48 +0000 Subject: [PATCH] Missing file --- ccvpn/common.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ccvpn/common.py diff --git a/ccvpn/common.py b/ccvpn/common.py new file mode 100644 index 0000000..9e02a1b --- /dev/null +++ b/ccvpn/common.py @@ -0,0 +1,15 @@ +from django.conf import settings + + +def get_client_ip(request): + header_name = settings.REAL_IP_HEADER_NAME + + print(header_name) + print(request.META) + if header_name: + header_name = header_name.replace('-', '_').upper() + value = request.META.get('HTTP_' + header_name) + if value: + return value.split(',', 1)[0] + + return request.META.get('REMOTE_ADDR')