|
@@ -65,16 +65,15 @@ class CommonService:
|
|
:param request:
|
|
:param request:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- ip = request.META.get("X-Forwarded-For","")
|
|
|
|
- if ip:
|
|
|
|
- client_ip = ip.split(",")[0].strip() if ip else ""
|
|
|
|
- if client_ip:
|
|
|
|
- return client_ip
|
|
|
|
- ip = request.META.get("HTTP_X_FORWARDED_FOR", "")
|
|
|
|
- if not ip:
|
|
|
|
- ip = request.META.get('REMOTE_ADDR', "")
|
|
|
|
- client_ip = ip.split(",")[-1].strip() if ip else ""
|
|
|
|
- return client_ip
|
|
|
|
|
|
+ try:
|
|
|
|
+ real_ip = request.META['HTTP_X_FORWARDED_FOR']
|
|
|
|
+ clientIP = real_ip.split(",")[0]
|
|
|
|
+ except:
|
|
|
|
+ try:
|
|
|
|
+ clientIP = request.META['REMOTE_ADDR']
|
|
|
|
+ except Exception as e:
|
|
|
|
+ clientIP = ''
|
|
|
|
+ return clientIP
|
|
|
|
|
|
# @获取一天每个小时的datetime.datetime
|
|
# @获取一天每个小时的datetime.datetime
|
|
@staticmethod
|
|
@staticmethod
|