Reverted / change because flask gives a Method error sometimes for no reason...

This commit is contained in:
ZKWolf 2023-09-16 04:22:37 +02:00
parent e445d78de5
commit 836ca1cfcc
6 changed files with 84 additions and 74 deletions

View File

@ -4,7 +4,7 @@ import os
from logic.mongodb_handler import mongo
@app.route("/gamenews/messages/", methods=["GET"])
@app.route("/gamenews/messages", methods=["GET"])
def gamenews():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -27,7 +27,7 @@ def gamenews():
logger.graylog_logger(level="error", handler="general-Game-News", message=e)
@app.route("/api/v1/config/VER_LATEST_CLIENT_DATA/", methods=["GET"])
@app.route("/api/v1/config/VER_LATEST_CLIENT_DATA", methods=["GET"])
def config_ver_latest_client_data():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -41,7 +41,7 @@ def config_ver_latest_client_data():
logger.graylog_logger(level="error", handler="general-ver-latest-data", message=e)
@app.route("/api/v1/utils/contentVersion/latest/<version>/", methods=["GET"])
@app.route("/api/v1/utils/contentVersion/latest/<version>", methods=["GET"])
def content_version_latest(version):
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -97,7 +97,7 @@ def gameservers_live():
logger.graylog_logger(level="error", handler="general-gameserver-dev", message=e)
@app.route("/api/v1/config/UseMirrorsMM_Steam/", methods=["GET"]) # What is this even??? Maybe Use Matchmaking? Its only in old Versions tho...
@app.route("/api/v1/config/UseMirrorsMM_Steam", methods=["GET"]) # What is this even??? Maybe Use Matchmaking? Its only in old Versions tho...
def config_use_mirrors_mm_steam():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -111,7 +111,7 @@ def config_use_mirrors_mm_steam():
logger.graylog_logger(level="error", handler="general-use-mirrors-mm-steam", message=e)
@app.route("/crashreport/unreal/CrashReporter/Ping/", methods=["GET"])
@app.route("/crashreport/unreal/CrashReporter/Ping", methods=["GET"])
def crashreporter_ping():
check_for_game_client("soft")
try:
@ -122,7 +122,7 @@ def crashreporter_ping():
logger.graylog_logger(level="error", handler="general-crashreporter-ping", message=e)
@app.route("/tex/", methods=["GET"])
@app.route("/tex", methods=["GET"])
def tex_get():
check_for_game_client("soft")
try:
@ -145,7 +145,7 @@ def favicon():
logger.graylog_logger(level="error", handler="general-favicon", message=e)
@app.route("/api/v1/healthcheck/", methods=["GET"])
@app.route("/api/v1/healthcheck", methods=["GET"])
def healthcheck():
check_for_game_client("soft")
try:
@ -171,7 +171,7 @@ def services_tex():
logger.graylog_logger(level="error", handler="general-services-tex", message=e)
@app.route("/api/v1/consent/eula2/", methods=["PUT", "GET"])
@app.route("/api/v1/consent/eula2", methods=["PUT", "GET"])
def consent_eula():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -222,7 +222,7 @@ def consent_eula():
logger.graylog_logger(level="error", handler="general-consent-eula", message=e)
@app.route("/api/v1/consent/eula/", methods=["GET"])
@app.route("/api/v1/consent/eula", methods=["GET"])
def consent_eula0():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -237,7 +237,7 @@ def consent_eula0():
logger.graylog_logger(level="error", handler="general-consent-eula0", message=e)
@app.route("/api/v1/consent/privacyPolicy/", methods=["GET"])
@app.route("/api/v1/consent/privacyPolicy", methods=["GET"])
def privacy_policy():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -252,7 +252,7 @@ def privacy_policy():
logger.graylog_logger(level="error", handler="general-privacy-policy", message=e)
@app.route("/api/v1/extensions/leaderboard/getScores/", methods=["GET", "POST"])
@app.route("/api/v1/extensions/leaderboard/getScores", methods=["GET", "POST"])
def leaderboard_get_scores():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -272,7 +272,7 @@ def leaderboard_get_scores():
logger.graylog_logger(level="error", handler="general-leaderboard-get-scores", message=e)
@app.route("/submit/", methods=["POST"])
@app.route("/submit", methods=["POST"])
def submit():
check = check_for_game_client("soft")
if not check:
@ -280,7 +280,7 @@ def submit():
return "Discarded=1"
@app.route("/api/v1/extensions/quitters/getQuitterState/", methods=["POST"])
@app.route("/api/v1/extensions/quitters/getQuitterState", methods=["POST"])
def get_quitter_state():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")

View File

@ -1,7 +1,7 @@
from flask_definitions import *
@app.route("/metrics/client/event/", methods=["POST"])
@app.route("/metrics/client/event", methods=["POST"])
def receive_event():
check_for_game_client()
try:
@ -14,7 +14,7 @@ def receive_event():
logger.graylog_logger(level="error", handler="logging_client_Event", message=e)
@app.route("/metrics/httplog/event/", methods=["POST"])
@app.route("/metrics/httplog/event", methods=["POST"])
def metrics_httplog_event():
check_for_game_client()
try:
@ -27,7 +27,7 @@ def metrics_httplog_event():
logger.graylog_logger(level="error", handler="logging_httplog_Event", message=e)
@app.route("/api/v1/gameDataAnalytics/", methods=["POST"])
@app.route("/api/v1/gameDataAnalytics", methods=["POST"])
def analytics_post():
check_for_game_client()
try:
@ -40,7 +40,7 @@ def analytics_post():
logger.graylog_logger(level="error", handler="logging_gameDataAnalytics", message=e)
@app.route("/api/v1/gameDataAnalytics/batch/", methods=["POST"])
@app.route("/api/v1/gameDataAnalytics/batch", methods=["POST"])
def analytics_batch_post():
check_for_game_client()
try:
@ -53,7 +53,7 @@ def analytics_batch_post():
logger.graylog_logger(level="error", handler="logging_gameDataAnalyticsBatch", message=e)
@app.route("/api/v1/me/richPresence/", methods=["POST"])
@app.route("/api/v1/me/richPresence", methods=["POST"])
def me_rich_presence():
check_for_game_client()
try:
@ -65,7 +65,7 @@ def me_rich_presence():
logger.graylog_logger(level="error", handler="logging_meRichPresence", message=e)
@app.route("/metrics/server/event/", methods=["POST"])
@app.route("/metrics/server/event", methods=["POST"])
def metrics_server_event():
check_for_game_client()
try:
@ -77,7 +77,7 @@ def metrics_server_event():
logger.graylog_logger(level="error", handler="logging_server_Event", message=e)
@app.route("/crashreport/unreal/CrashReporter/CheckReport/", methods=["POST"])
@app.route("/crashreport/unreal/CrashReporter/CheckReport", methods=["POST"])
def crashreporter_check_report():
check_for_game_client()
try:

View File

@ -8,7 +8,7 @@ from flask_definitions import *
import uuid
@app.route("/api/v1/config/MATCH_MAKING_REGIONS/raw/", methods=["GET"])
@app.route("/api/v1/config/MATCH_MAKING_REGIONS/raw", methods=["GET"])
def match_making_regions_raw():
check_for_game_client("strict")
try:
@ -19,7 +19,7 @@ def match_making_regions_raw():
logger.graylog_logger(level="error", handler="matchmaking_RegionsRAW", message=e)
@app.route("/api/v1/queue/info/", methods=["GET"])
@app.route("/api/v1/queue/info", methods=["GET"])
def queue_info():
try:
# ?category=Steam-te-23ebf96c-27498-ue4-7172a3f5&gameMode=Default&region=US&countA=1&countB=5
@ -49,7 +49,7 @@ def queue_info():
logger.graylog_logger(level="error", handler="queue_info", message=e)
@app.route("/api/v1/queue/", methods=["POST"])
@app.route("/api/v1/queue", methods=["POST"])
def queue():
# {"category":"Steam-te-18f25613-36778-ue4-374f864b","rank":1,"side":"B","latencies":[],"additionalUserIds":[],
# "checkOnly":false,"gameMode":"08d2279d2ed3fba559918aaa08a73fa8-Default","region":"US","countA":1,"countB":5}
@ -70,6 +70,8 @@ def queue():
spoofed_match_id = "0051681e-72ce-46f0-bda2-752e471d0d08"
epoch = datetime.now().timestamp()
logger.graylog_logger(level="info", handler="logging_queue_DUMP", message=request.get_json())
logger.graylog_logger(level="info", handler="logging_queue",
message=f"User {userid} is queueing for {category} in {region} with {count_a} hunters and {count_b} runners")
try:
@ -117,7 +119,7 @@ def queue():
# eta, position = match_manager.find_eta_and_position(data["_match_uuid"])
@app.route("/api/v1/queue/cancel/", methods=["POST"])
@app.route("/api/v1/queue/cancel", methods=["POST"])
def cancel_queue():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -132,7 +134,7 @@ def cancel_queue():
return "", 204
@app.route("/api/v1/match/<matchid>/", methods=["GET"])
@app.route("/api/v1/match/<matchid>", methods=["GET"])
def match(matchid):
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -146,7 +148,7 @@ def match(matchid):
return jsonify({"message": "Internal Server Error"}), 500
@app.route("/api/v1/match/<matchid>/Kill/", methods=["PUT"])
@app.route("/api/v1/match/<matchid>/Kill", methods=["PUT"])
def match_kill(matchid):
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -167,7 +169,7 @@ def match_kill(matchid):
return jsonify({"message": "Internal Server Error"}), 500
@app.route("/api/v1/match/<match_id>/register/", methods=["POST"])
@app.route("/api/v1/match/<match_id>/register", methods=["POST"])
def match_register(match_id):
try:
check_for_game_client("strict")
@ -194,7 +196,7 @@ def match_register(match_id):
return jsonify({"message": "Internal Server Error"}), 500
@app.route("/api/v1/match/<match_id>/Quit/", methods=["PUT"])
@app.route("/api/v1/match/<match_id>/Quit", methods=["PUT"])
def match_quit(match_id):
try:
check_for_game_client("strict")
@ -222,7 +224,7 @@ def match_quit(match_id):
return jsonify({"status": "ERROR"}), 500
@app.route("/api/v1/match/create/", methods=["POST"])
@app.route("/api/v1/match/create", methods=["POST"])
def match_create():
# {'category': 'Steam-te-18f25613-36778-ue4-374f864b', 'region': 'US', 'playersA': [],
# 'playersB': ['00658d11-2dfd-41e8-b6d2-2462e8f3aa47', '95041085-e7e4-4759-be3d-e72c69167578',
@ -252,7 +254,7 @@ def match_create():
return jsonify(data)
@app.route("/api/v1/extensions/progression/playerEndOfMatch/", methods=["POST"])
@app.route("/api/v1/extensions/progression/playerEndOfMatch", methods=["POST"])
def progression_player_end_of_match():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -266,7 +268,7 @@ def progression_player_end_of_match():
logger.graylog_logger(level="error", handler="matchmaking_playerEndOfMatch", message=e)
@app.route("/file/<game_version>/<seed>/<map_name>/", methods=["POST", "GET"])
@app.route("/file/<game_version>/<seed>/<map_name>", methods=["POST", "GET"])
def file_gold_rush(seed, map_name, game_version):
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -290,7 +292,7 @@ def file_gold_rush(seed, map_name, game_version):
return {"status": "success"}
@app.route("/metrics/matchmaking/event/", methods=["POST"])
@app.route("/metrics/matchmaking/event", methods=["POST"])
def metrics_matchmaking_event():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")

View File

@ -2,7 +2,7 @@ from flask_definitions import *
# Do NOT change Result to ANYTHING or Add anything before it. Game will crash. Doesnt mean it 100% works tho XD
@app.route("/<game_version>/catalog/", methods=["GET"])
@app.route("/<game_version>/catalog", methods=["GET"])
def catalog_get(game_version):
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")

View File

@ -45,7 +45,7 @@ def steam_login_function():
# This works
@app.route("/api/v1/auth/provider/steam/login/", methods=["POST"])
@app.route("/api/v1/auth/provider/steam/login", methods=["POST"])
def steam_login():
# Read Doc\SteamAuth.md for more information
ip = check_for_game_client("soft")
@ -92,7 +92,7 @@ def steam_login():
# Dont know if this works
@app.route("/api/v1/modifierCenter/modifiers/me/", methods=["GET"])
@app.route("/api/v1/modifierCenter/modifiers/me", methods=["GET"])
def modifiers():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -110,7 +110,7 @@ def modifiers():
# This works
@app.route("/moderation/check/username/", methods=["POST"])
@app.route("/moderation/check/username", methods=["POST"])
def moderation_check_username():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -130,7 +130,7 @@ def moderation_check_username():
# Doesn't work
@app.route("/api/v1/progression/experience/", methods=["POST"])
@app.route("/api/v1/progression/experience", methods=["POST"])
def progression_experience():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -168,7 +168,7 @@ def progression_experience():
logger.graylog_logger(level="error", handler="progression_experience", message=e)
@app.route("/api/v1/extensions/challenges/getChallenges/", methods=["POST"])
@app.route("/api/v1/extensions/challenges/getChallenges", methods=["POST"])
def challenges_get_challenges():
# client: {"data":{"userId":"619d6f42-db87-4f3e-8dc9-3c9995613614","challengeType":"Daily"}}
check_for_game_client("strict")
@ -202,7 +202,7 @@ def challenges_get_challenges():
logger.graylog_logger(level="error", handler="getChallanges", message=e)
@app.route("/api/v1/extensions/challenges/executeChallengeProgressionOperationBatch/", methods=["POST"])
@app.route("/api/v1/extensions/challenges/executeChallengeProgressionOperationBatch", methods=["POST"])
def challenges_execute_challenge_progression_operation_batch():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -224,7 +224,7 @@ def challenges_execute_challenge_progression_operation_batch():
# idk dont think it works
@app.route("/api/v1/inventories/", methods=["GET"])
@app.route("/api/v1/inventories", methods=["GET"])
def inventories():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -247,7 +247,7 @@ def inventories():
# idk if this works
@app.route("/api/v1/players/me/splinteredstates/ProgressionGroups/", methods=["GET"])
@app.route("/api/v1/players/me/splinteredstates/ProgressionGroups", methods=["GET"])
def progression_groups():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -274,7 +274,7 @@ def progression_groups():
# This works
@app.route("/api/v1/players/ban/status/", methods=["GET"])
@app.route("/api/v1/players/ban/status", methods=["GET"])
def ban_status():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -306,7 +306,7 @@ def ban_status():
# broken. no need to fix... OG DG endpoint. Not needed.
@app.route("/api/v1/players/ban/getbaninfo/", methods=["GET"])
@app.route("/api/v1/players/ban/getbaninfo", methods=["GET"])
def get_ban_info():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -322,7 +322,7 @@ def get_ban_info():
# This works
@app.route("/api/v1/wallet/currencies/", methods=["GET"])
@app.route("/api/v1/wallet/currencies", methods=["GET"])
def wallet_currencies():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -348,7 +348,7 @@ def wallet_currencies():
# Does not work. Old DG endpoint. Not needed.
@app.route("/api/v1/wallet/currencies/PROGRESSION_CURRENCY/", methods=["GET"])
@app.route("/api/v1/wallet/currencies/PROGRESSION_CURRENCY", methods=["GET"])
def wallet_currencies_progression():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -363,16 +363,16 @@ def wallet_currencies_progression():
# Dont know if this works. Dont think it does.
@app.route("/api/v1/players/me/splinteredstates/TheExit_Achievements/", methods=["GET"])
@app.route("/api/v1/players/me/splinteredstates/TheExit_Achievements", methods=["GET"])
def achievements_get():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
return jsonify({"UserId": userid, "StateName": "", "Segment": "", "List": [
{"ObjectId": "EFAB89E6465D1163D62A07B11048F2B6", "Version": 11, "SchemaVersion": 11, "Data": {}}
]})
# return jsonify({"UserId": userid, "StateName": "", "Segment": "", "List": [
# {"ObjectId": "EFAB89E6465D1163D62A07B11048F2B6", "Version": 11, "SchemaVersion": 11, "Data": {}}
# ]})
# This works but lemme test smthing...
return jsonify({"gameName": "Deathgarden: BLOODHARVEST", "achievements":
[{"apiname": "EFAB89E6465D1163D62A07B11048F2B6", "achieved": 1, "unlocktime": 1587140058},
@ -387,7 +387,7 @@ def achievements_get():
# Does not work
@app.route("/api/v1/messages/count/", methods=["GET"])
@app.route("/api/v1/messages/count", methods=["GET"])
def messages_count():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -405,7 +405,7 @@ def messages_count():
logger.graylog_logger(level="error", handler="messages_count", message=e)
@app.route("/api/v1/messages/list/", methods=["GET", "DELETE"])
@app.route("/api/v1/messages/list", methods=["GET", "DELETE"])
def messages_list():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -452,13 +452,13 @@ def messages_list():
return jsonify({"messages": [], "NetPage": 0})
@app.route("/api/v1/messages/v2/markAs/", methods=["POST"])
@app.route("/api/v1/messages/v2/markAs", methods=["POST"])
def messages_mark_as():
return jsonify("", 204)
# Temp response.
@app.route("/moderation/check/chat/", methods=["POST"])
@app.route("/moderation/check/chat", methods=["POST"])
def moderation_check_chat():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -478,7 +478,7 @@ def moderation_check_chat():
# This is intently broken. If this works the game crashes in matchmaking.
@app.route("/api/v1/extensions/progression/initOrGetGroups/", methods=["POST"])
@app.route("/api/v1/extensions/progression/initOrGetGroups", methods=["POST"])
def extension_progression_init_or_get_groups():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -517,7 +517,9 @@ def extension_progression_init_or_get_groups():
"EquippedPowers": ["C8AF3D53-4973F82F-ADBB40BD-A96F9DCD"],
"EquippedWeapons": ["4E171BD1-4FF98ED4-3A7AFAB5-7FE55578"],
"EquippedBonuses": ["109BC590-4DC1272D-70822EBA-79CC85B1",
"54B3EF79-4FCB0643-C4644FA1-5BEF31D5"]}
"54B3EF79-4FCB0643-C4644FA1-5BEF31D5"],
"PrestigeLevel": 1,
"PickedChallenges": []}
},
{
"ObjectId": "C50FFFBF-46866131-82F45890-651797CE",
@ -534,7 +536,10 @@ def extension_progression_init_or_get_groups():
"EquippedWeapons": ["36466540-42433114-08F6A0BD-4DCE05BD",
"307A0B13-417737DE-D675309F-8B978AB8"],
"EquippedBonuses": ["791F12E0-47DA9E26-E246E385-9C3F587E",
"8A5BF227-4640C2F2-3EF3C996-A6F6404D"]}
"8A5BF227-4640C2F2-3EF3C996-A6F6404D"],
"PrestigeLevel": 1,
"PickedChallenges": []
}
}
]
})
@ -545,7 +550,7 @@ def extension_progression_init_or_get_groups():
# dont know if this works. Hope it does.
@app.route("/api/v1/extensions/inventory/unlockSpecialItems/", methods=["POST"])
@app.route("/api/v1/extensions/inventory/unlockSpecialItems", methods=["POST"])
def inventory_unlock_special_items():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
@ -560,7 +565,7 @@ def inventory_unlock_special_items():
logger.graylog_logger(level="error", handler="unknown_unlockSpecialItems", message=e)
@app.route("/api/v1/extensions/challenges/getChallengeProgressionBatch/", methods=["POST"])
@app.route("/api/v1/extensions/challenges/getChallengeProgressionBatch", methods=["POST"])
def challenges_get_challenge_progression_batch():
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")

View File

@ -3,31 +3,34 @@ import time
import uuid
def _get_remote_ip():
if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
ip_addr = request.environ['REMOTE_ADDR']
if ip_addr == "127.0.0.1":
return None
logger.graylog_logger(level="info", handler="ip_handler", message=f"New Connection from: {ip_addr}")
return ip_addr
else:
ip_addr = request.environ['HTTP_X_FORWARDED_FOR']
if ip_addr == "127.0.0.1":
return None
else:
def _get_remote_ip(check_type="strict"):
if check_type == "strict":
if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
ip_addr = request.environ['REMOTE_ADDR']
if ip_addr == "127.0.0.1":
return None
logger.graylog_logger(level="info", handler="ip_handler", message=f"New Connection from: {ip_addr}")
return ip_addr
else:
ip_addr = request.environ['HTTP_X_FORWARDED_FOR']
if ip_addr == "127.0.0.1":
return None
else:
logger.graylog_logger(level="info", handler="ip_handler", message=f"New Connection from: {ip_addr}")
return ip_addr
else:
return "127.0.0.1"
def check_for_game_client(check_type="strict"):
if check_type == "strict":
user_agent = request.headers.get('User-Agent')
if user_agent.startswith("TheExit/++UE4+Release-4.2"):
_get_remote_ip()
_get_remote_ip("strict")
elif user_agent.startswith("game=TheExit, engine=UE4, version="):
_get_remote_ip()
_get_remote_ip("strict")
elif user_agent.startswith("CrashReportClient/++UE4+Release-4.21"):
_get_remote_ip()
_get_remote_ip("strict")
else:
_get_remote_ip()
logger.graylog_logger(level="info", handler="UserAgents", message=f"INVALID User-Agent: {user_agent} "
@ -38,7 +41,7 @@ def check_for_game_client(check_type="strict"):
remote = _get_remote_ip()
return remote
else:
_get_remote_ip()
_get_remote_ip("soft")
class Session_Manager: