This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipaddress | |
def get_client_ip(request, trusted_proxies=None): | |
""" | |
trusted_proxies: ro'yxat yoki set — serveringiz/NGINX/Cloudflare kabi ishonchli proksi IPlari. | |
Agar None bo'lsa, faqat headerlarni qabul qilishda ehtiyot bo'ling. | |
""" | |
# 1) Cloudflare specific | |
cf_ip = request.META.get('HTTP_CF_CONNECTING_IP') | |
if cf_ip: |