add protection that shares the data with my webside

This commit is contained in:
2025-12-23 15:20:36 +01:00
parent 0b2d635fd8
commit 729e7f5fca
13 changed files with 211 additions and 60 deletions
+2 -3
View File
@@ -1,7 +1,7 @@
from my_modules.TheIPManager import TheIPManager
from my_modules.app.logger import logger
from dotenv import find_dotenv, load_dotenv, dotenv_values
from pathlib import Path
import os, asyncio
async def read_dot_file():
@@ -17,5 +17,4 @@ WEB_DEBUG = os.getenv("WEB_DEBUG", False)
SECRET_KEY = os.getenv("FLASK_SECRET_KEY", "USE_ENV_das_ist_ein_geheimer_schlüssel_1")
API_GROUP = os.getenv("API_GROUP", 'NanoShare')
UPLOAD_DIR = Path("uploads")
UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
THE_IP_BOT_MANAGER = TheIPManager()
+1 -1
View File
@@ -8,5 +8,5 @@ formatter = Formatter(fmt="%(levelname)s %(module)s: %(message)s")
handler = AsyncStreamHandler(stream=sys.stdout)
handler.formatter = formatter
logger = Logger(name="my_webside_and_api", level="DEBUG" if os.getenv("WEB_DEBUG", False) == "true" else "INFO")
logger = Logger(name="simple-picoshare", level="DEBUG" if os.getenv("WEB_DEBUG", False) == "true" else "INFO")
logger.handlers = [handler]
+11 -4
View File
@@ -1,8 +1,7 @@
from my_modules.functions import custom_limit_key
from my_modules.app.constens import SECRET_KEY, UPLOAD_DIR
from my_modules.functions import custom_limit_key, get_my_ip_address, get_local_ip_addresses, replace_last_ip_segment, generate_all_ips
from my_modules.app.constens import SECRET_KEY, THE_IP_BOT_MANAGER
from my_modules.AsyncCache import AsyncCache
from my_modules.app.logger import logger
from my_modules.db.ConvexDB import ConvexDB
from quart_session import Session
@@ -16,7 +15,6 @@ app = Quart(__name__, template_folder="../../templates/side", static_folder="../
app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * 1024
app.secret_key = SECRET_KEY
app.upload_folder = UPLOAD_DIR
# Cache, Sessions and Limiter over Valkey
if os.getenv("VALKEY_HOST", None) is not None:
@@ -71,6 +69,15 @@ async def init_convex():
app.convex = ConvexDB(os.getenv("CONVEX_URL"))
await app.convex.connect()
THE_IP_BOT_MANAGER.add_always_allowed_ip('127.0.0.1')
THE_IP_BOT_MANAGER.add_always_allowed_ip(await get_my_ip_address())
local_docker_host_ip = get_local_ip_addresses()
if local_docker_host_ip:
base_ip = replace_last_ip_segment(local_docker_host_ip, 1)
all_local_ips = generate_all_ips(base_ip)
THE_IP_BOT_MANAGER.update_always_allowed_ip(all_local_ips)
@app.after_serving
async def close_convex():
if app.convex: