Skip to content

Instantly share code, notes, and snippets.

View axrorback's full-sized avatar
🎯
Focusing

Ahrorjon Ibrohimjonov axrorback

🎯
Focusing
View GitHub Profile
@axrorback
axrorback / ip_adress.py
Created September 19, 2025 09:26
IP MANZILNI OLISH
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: