poprawki
This commit is contained in:
8
app.py
8
app.py
@@ -6,6 +6,7 @@ import time
|
|||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
import hmac, ipaddress
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.parse import urlparse, quote, unquote, urljoin
|
from urllib.parse import urlparse, quote, unquote, urljoin
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
@@ -387,7 +388,7 @@ def index():
|
|||||||
@app.route("/convert")
|
@app.route("/convert")
|
||||||
@limiter.limit(config.RATE_LIMIT_CONVERT)
|
@limiter.limit(config.RATE_LIMIT_CONVERT)
|
||||||
def convert():
|
def convert():
|
||||||
import hmac, ipaddress
|
|
||||||
|
|
||||||
def is_private_client_ip() -> bool:
|
def is_private_client_ip() -> bool:
|
||||||
ip = get_client_ip()
|
ip = get_client_ip()
|
||||||
@@ -436,8 +437,8 @@ def convert():
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
try:
|
try:
|
||||||
redis_client.incr("stats:convert_requests")
|
|
||||||
add_recent_convert()
|
add_recent_convert()
|
||||||
|
redis_client.incr("stats:convert_requests")
|
||||||
if debug_mode:
|
if debug_mode:
|
||||||
d("Start /convert w trybie debug")
|
d("Start /convert w trybie debug")
|
||||||
|
|
||||||
@@ -515,11 +516,13 @@ def convert():
|
|||||||
if debug_mode:
|
if debug_mode:
|
||||||
d("Upstream 304 – zwracam 304")
|
d("Upstream 304 – zwracam 304")
|
||||||
r.close()
|
r.close()
|
||||||
|
add_recent_convert()
|
||||||
return debug_response(status=304)
|
return debug_response(status=304)
|
||||||
resp = Response(status=304)
|
resp = Response(status=304)
|
||||||
resp.headers.update(cache_headers(etag, r.headers.get("Last-Modified")))
|
resp.headers.update(cache_headers(etag, r.headers.get("Last-Modified")))
|
||||||
resp.direct_passthrough = True
|
resp.direct_passthrough = True
|
||||||
r.close()
|
r.close()
|
||||||
|
add_recent_convert()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
up_etag = r.headers.get("ETag")
|
up_etag = r.headers.get("ETag")
|
||||||
@@ -566,6 +569,7 @@ def convert():
|
|||||||
resp.headers.update(cache_headers(etag, up_lm))
|
resp.headers.update(cache_headers(etag, up_lm))
|
||||||
resp.direct_passthrough = True
|
resp.direct_passthrough = True
|
||||||
redis_client.incr("stats:conversions_success")
|
redis_client.incr("stats:conversions_success")
|
||||||
|
add_recent_convert()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
|
Reference in New Issue
Block a user