A collection of basic policies for resources anti-spammer
Project description
A collection of basic policies for resources anti-spammer.
Install from Pypi
pip install bpolicy
Basic Example
import memcache from bpolicy.consts import MINUTE, HOUR from bpolicy import RatedPolicyFactory, ClockPolicyFactory, GenerationedPolicyFactory from bpolicy import chained_policy, silent_check store = memcache.Client(['127.0.0.1:9013']) rated_factory = RatedPolicyFactory(quota=10, interval=1 * MINUTE) clock_factory = ClockPolicyFactory(start_time=time(hour=1), end_time=time(hour=6), discount=0.3) generationed_factory = GenerationedPolicyFactory(quota=10, interval=1 * HOUR, discount=0.5, max_keep_traking=3) def check_policy(identity): return silent_check(chained_policy('hello', [generationed_factory, clock_factory, rated_factory], store), identity) identity = "88.88.23.1" for i in range(100): if check_policy(identity): print("success") else: print("banded")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bpolicy-0.3.3.tar.gz
(5.5 kB
view details)
File details
Details for the file bpolicy-0.3.3.tar.gz
.
File metadata
- Download URL: bpolicy-0.3.3.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12948b12d8b23bd47b2f86165a9e52d9f39a003d8f82829cb49fc542a9328ea8 |
|
MD5 | c3a64c79401b42aedbcc979b9a498daa |
|
BLAKE2b-256 | 96c788006a687fca8ac1657ccf1a6d9ea97712afadb9bd2f748e660de68b5c4f |