Synced (yesterday's)

Add fingerprinting mechanism (f2268fe4d9)
This commit is contained in:
vdbhb59 2025-04-19 13:26:54 +05:30
commit 7a7c33fa19
4 changed files with 30 additions and 16 deletions

View file

@ -193,12 +193,13 @@ Arguments passed to the process or set via environment variables are split into
### Settings / Flags
| Argument | Description | Default Setting | Env. name |
| --------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------- | ---------------------------- |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------------------------------ |
| --debug | Enable debug environment | `Disabled` | LT_DEBUG |
| --ssl | Whether to enable SSL | `Disabled` | LT_SSL |
| --api-keys | Enable API keys database for per-client rate limits when --req-limit is reached | `Don't use API keys` | LT_API_KEYS |
| --require-api-key-origin | Require use of an API key for programmatic access to the API, unless the request origin matches this domain | `No restrictions on domain origin` | LT_REQUIRE_API_KEY_ORIGIN |
| --require-api-key-secret | Require use of an API key for programmatic access to the API, unless the client also sends a secret match | `No secrets required` | LT_REQUIRE_API_KEY_SECRET |
| --require-api-key-fingerprint | Require use of an API key for programmatic access to the API, unless the client also matches a fingerprint | `No fingerprinting required` | LT_REQUIRE_API_KEY_FINGERPRINT |
| --under-attack | Enable under attack mode. When enabled, requests must be made with an API key | `Disabled` | LT_UNDER_ATTACK |
| --suggestions | Allow user suggestions | `Disabled` | LT_SUGGESTIONS |
| --disable-files-translation | Disable files translation | `File translation allowed` | LT_DISABLE_FILES_TRANSLATION |
@ -428,7 +429,7 @@ This is a list of public LibreTranslate instances, some require an API key. If y
| ----------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------- |
| [libretranslate.com](https://libretranslate.com) | :heavy_check_mark: | [ [Get API Key](https://portal.libretranslate.com) ] [ [Service Status](https://status.libretranslate.com/) ] |
| [translate.flossboxin.org.in](https://translate.flossboxin.org.in/) | | [ [Contact/eMail](mailto:dev@flossboxin.org.in) ] |
| [lt.blitzw.in](https://lt.blitzw.in/) | | hosted by blitzw.in. uses an open source javascript-based captcha to fight bots! |
| [lt.blitzw.in](https://lt.blitzw.in/) | | |
## TOR/i2p Mirrors

View file

@ -1 +1 @@
1.7.0
1.7.1

View file

@ -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

View file

@ -108,7 +108,7 @@ def get_emoji():
return random.choice(["😂", "🤪", "😜", "🤣", "😹", "🐒", "🙈", "🤡", "🥸", "😆", "🥴", "🐸", "🐤", "🐒🙊", "👀", "💩", "🤯", "😛", "🤥", "👻"])
def setup(args):
if args.api_keys and args.require_api_key_secret:
if args.require_api_key_secret:
s = get_storage()
if not s.exists("secret_0"):