fix: 修复非标准实现 X-Forwarded-For 时的问题

merge/CORE-MR-3111/head^2
kebyn 2024-09-02 02:10:41 +00:00 committed by Bryan
parent 55e8e34226
commit e94520a3fd
2 changed files with 2 additions and 6 deletions

View File

@ -158,7 +158,7 @@ def is_uuid(seq):
def get_request_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '').split(',')
if x_forwarded_for and x_forwarded_for[0]:
login_ip = x_forwarded_for[0]
login_ip = x_forwarded_for[0].split(":")[0]
return login_ip
login_ip = request.META.get('REMOTE_ADDR', '')
@ -293,7 +293,7 @@ def get_docker_mem_usage_if_limit():
inactive_file = int(inactive_file)
return ((usage_in_bytes - inactive_file) / limit_in_bytes) * 100
except Exception as e:
except Exception:
return None

View File

@ -39,10 +39,6 @@ def iso8601_to_unixtime(time_string):
return to_unixtime(time_string, _ISO8601_FORMAT)
def get_remote_addr(request):
return request.META.get("HTTP_X_FORWARDED_HOST") or request.META.get("REMOTE_ADDR")
def is_true(value):
return value in BooleanField.TRUE_VALUES