Skip to main content

基于django实现的IP访问黑名单功能。可以通过asn/network对访问IP进行拦截,禁止符合要求的IP访问网站。

Project description

django-accessblacklist

介绍

基于django实现的IP访问黑名单功能。可以通过asn/network对访问IP进行拦截,禁止符合要求的IP访问网站。

软件架构

middleware对来访ip进行筛查,判断来访IP是否在禁止名单里。 禁止名单包括 asn 和 network ,可以在后台添加。 同时可以在settings.py里定义是否启用拦截,是否启用拦截缓存,拦截缓存使用的后段以及缓存生效时间。

安装教程

  1. 确保当前应用已经部署django,
  2. pip install django-accessblacklist

使用说明

  1. 在settings.py中的INSTALLED_APPS里添加 'accessblacklist', eg: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'accessblacklist', ]
  2. 在settings.py里这是CACHE: eg: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', # 使用本地内存缓存<适用于小型项目,大型项目建议使用Redis或Memcached> 'LOCATION': 'unique-blackiplist-cache', # 缓存的唯一标识符 'TIMEOUT': 606024*7, # 缓存过期时间(秒) 一周 } }
  3. 在settings.py里设置’是否启用缓存功能'和'是否启用拦截记录功能': IS_USE_CACHE = True # 是否启用缓存功能,True表示启用,False表示禁用 IS_USE_INTERCEPTIONRECORD = True # 是否启用拦截记录功能,True表示启用,False表示禁用

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_accessblacklist-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_accessblacklist-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file django_accessblacklist-0.1.1.tar.gz.

File metadata

  • Download URL: django_accessblacklist-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for django_accessblacklist-0.1.1.tar.gz
Algorithm Hash digest
SHA256 efb0e2639677c0fb55c4b12b2b4288d3c5cdb839169c1389ef5454644240e443
MD5 d95e4e2fb11c39e5348a2998d6e6766c
BLAKE2b-256 c7f5124259718b6395751c02ccdc13fa10bd905a4c4302ac6b9ab4aeaa913d73

See more details on using hashes here.

File details

Details for the file django_accessblacklist-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_accessblacklist-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6d3c80eacf954c1dc47207d36409e4272a24e7b26adcc88408c8e043dd2304a
MD5 4965d99f564a87ab6f3a986e3aa8655a
BLAKE2b-256 f1a20ef4eedc7fbeec70bd687121268282e96ce035cba7f3b7cc8c11d0664233

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page