mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-05-15 14:32:53 +00:00
Add fingerprinting mechanism
This commit is contained in:
parent
da0890d60f
commit
f2268fe4d9
8 changed files with 65 additions and 20 deletions
|
@ -45,3 +45,16 @@ def is_banned(request_ip):
|
|||
|
||||
# More than X offences?
|
||||
return active and s.get_hash_int("banned", request_ip) >= threshold
|
||||
|
||||
def fingerprint_mismatch(request_ip, fingerprint):
|
||||
if not isinstance(fingerprint, str) or fingerprint == "":
|
||||
return True
|
||||
|
||||
s = get_storage()
|
||||
k = f"fingerprint:{request_ip}"
|
||||
expected = s.get_str(k)
|
||||
if expected == "":
|
||||
s.set_str(k, fingerprint, ex=300)
|
||||
return False
|
||||
else:
|
||||
return fingerprint != expected
|
Loading…
Add table
Add a link
Reference in a new issue