chenjunkai 6 年之前
父节点
当前提交
cd850091fb
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      Service/CommonService.py

+ 5 - 0
Service/CommonService.py

@@ -65,6 +65,11 @@ class CommonService:
         :param request:
         :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', "")