diff --git a/dynmap_honeypot/__pycache__/__init__.cpython-312.pyc b/dynmap_honeypot/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 9fc3e63..0000000 Binary files a/dynmap_honeypot/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/dynmap_honeypot/__pycache__/__main__.cpython-312.pyc b/dynmap_honeypot/__pycache__/__main__.cpython-312.pyc deleted file mode 100644 index 5aff1f2..0000000 Binary files a/dynmap_honeypot/__pycache__/__main__.cpython-312.pyc and /dev/null differ diff --git a/dynmap_honeypot/__pycache__/main.cpython-312.pyc b/dynmap_honeypot/__pycache__/main.cpython-312.pyc deleted file mode 100644 index 4609cfc..0000000 Binary files a/dynmap_honeypot/__pycache__/main.cpython-312.pyc and /dev/null differ diff --git a/dynmap_honeypot/main.py b/dynmap_honeypot/main.py index bba68bb..d71636c 100644 --- a/dynmap_honeypot/main.py +++ b/dynmap_honeypot/main.py @@ -12,8 +12,16 @@ else: webhook = None @app.post("/up/sendmessage") -async def message_endpoint(request: Request, name: str = Body(str), message: str = Body(str)): - ip = request.headers['X-Forwarded-For'] +# async def message_endpoint(request: Request, name: str = Body(str), message: str = Body(str)): +async def message_endpoint(request: Request): + ip = request.headers['X-Forwarded-For'] if 'X-Forwarded-For' in request.headers else request.client.host + try: + data = await request.json() + name = data["name"] if "name" in data else "" + message = data["message"] if "message" in data else "" + except: + logger.info(f"{ip}: invalid body: {request._body}") + return {"error": "invalid body"} if webhook: embed = DiscordEmbed( title="message received", @@ -29,9 +37,9 @@ async def message_endpoint(request: Request, name: str = Body(str), message: str @app.get("/up/configuration") async def configuration_endpoint(request: Request): - ip = request.headers['X-Forwarded-For'] + ip = request.headers['X-Forwarded-For'] if 'X-Forwarded-For' in request.headers else request.client.host if webhook: - embed = DiscordEmbed(title="received configuration request") + embed = DiscordEmbed(title="received configuration request", description=f"address: {ip}") embed.add_embed_field(name="address", value=ip) response = webhook.execute()