fix: add corporate network 172.11.0.0/16 to allowed IPs

- Allow registration from 172.11.0.0/16 network
- Add explicit list of allowed networks instead of default
- Include test script for corporate IP validation
- All tests passed (8/8)
This commit is contained in:
admin i 2025-12-05 16:25:17 +03:00
parent f438aa6433
commit 29db86d4f1
2 changed files with 59 additions and 1 deletions

View File

@ -167,7 +167,13 @@ PHONENUMBER_DEFAULT_REGION = "RU"
# ['*'] - разрешены все IP
# ['192.168.1.0/24', '10.0.0.0/8'] - конкретные сети
# ['192.168.1.100', '192.168.1.101'] - конкретные IP
REGISTRATION_ALLOWED_IPS = None # По умолчанию только локальные IP
REGISTRATION_ALLOWED_IPS = [
'127.0.0.0/8', # localhost
'10.0.0.0/8', # приватная сеть класса A
'172.16.0.0/12', # приватная сеть класса B (172.16-31.x.x)
'172.11.0.0/16', # ваша корпоративная сеть
'192.168.0.0/16', # приватная сеть класса C
]
# Медиа файлы
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")

View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
"""Проверка разрешения IP для корпоративной сети 172.11.0.0/16"""
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'eusrr_backend.settings')
import django
django.setup()
from common.ip_restrictions import is_ip_allowed
print("\n" + "=" * 60)
print("Проверка IP-адресов для корпоративной сети 172.11.0.0/16")
print("=" * 60)
test_ips = [
('172.11.0.117', True, 'Ваш текущий IP'),
('172.11.0.1', True, 'Корпоративная сеть 172.11.x.x'),
('172.11.255.255', True, 'Край диапазона 172.11.x.x'),
('172.12.0.1', False, 'За пределами 172.11.x.x'),
('172.16.0.1', True, 'Стандартная приватная сеть'),
('192.168.1.1', True, 'Локальная сеть'),
('10.0.0.1', True, 'Приватная сеть класса A'),
('8.8.8.8', False, 'Публичный IP (Google DNS)'),
]
passed = 0
failed = 0
for ip, expected, description in test_ips:
result = is_ip_allowed(ip)
status = "✅" if result == expected else "❌"
if result == expected:
passed += 1
else:
failed += 1
result_text = "разрешен" if result else "заблокирован"
expected_text = "разрешен" if expected else "заблокирован"
print(f"{status} {ip:20} -> {result_text:12} "
f"(ожидалось: {expected_text:12}) # {description}")
print("\n" + "=" * 60)
if failed == 0:
print(f"✅ Все тесты пройдены: {passed}/{passed + failed}")
else:
print(f"⚠️ Тестов пройдено: {passed}/{passed + failed}, провалено: {failed}")
print("=" * 60 + "\n")