Changed checks to only 3 lines with ABORT. Other small changes aswell

This commit is contained in:
ZKWolf 2023-07-21 17:36:08 +02:00
parent 055a543b11
commit f9c4726420
5 changed files with 267 additions and 436 deletions

View File

@ -6,9 +6,10 @@ from logic.mongodb_handler import mongo
@app.route("/gamenews/messages", methods=["GET"])
def gamenews():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
# /gamenews/messages?sortDesc=true&gameVersion=0&platform=PC&language=EN&messageType=InGameNews&faction=Runner&playerLevel=1
try:
sort_desc = request.args.get('sortDesc')
@ -28,9 +29,10 @@ def gamenews():
@app.route("/api/v1/config/VER_LATEST_CLIENT_DATA", methods=["GET"])
def config_ver_latest_client_data():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
return jsonify({"LatestSupportedVersion": "te-18f25613-36778-ue4-374f864b"})
except TimeoutError:
@ -41,11 +43,13 @@ def config_ver_latest_client_data():
@app.route("/api/v1/utils/contentVersion/latest/<version>", methods=["GET"])
def content_version_latest(version):
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
print("Responded to content version api call GET")
print(f"Version called by client: {version}")
return jsonify({"LatestSupportedVersion": "te-18f25613-36778-ue4-374f864b"})
except TimeoutError:
return jsonify({"status": "error"})
@ -55,9 +59,8 @@ def content_version_latest(version):
@app.route("/gameservers.dev", methods=["POST", "GET"])
def gameservers_dev():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
try:
# logger.graylog_logger(level="info", handler="logging_gameservers-dev", message=request.get_json())
return jsonify({"status": "success"})
@ -69,9 +72,8 @@ def gameservers_dev():
@app.route("/gameservers.uat", methods=["POST"])
def gameservers_uat():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
try:
# graylog_logger(request.get_json(), "warning")
return jsonify({"status": "success"})
@ -84,9 +86,8 @@ def gameservers_uat():
@app.route("/gameservers.live", methods=["POST", "GET"])
def gameservers_live():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
try:
# graylog_logger(request.get_json(), "warning")
return jsonify({"status": "success"})
@ -98,9 +99,10 @@ def gameservers_live():
@app.route("/api/v1/config/UseMirrorsMM_Steam", methods=["GET"]) # What is this even???
def config_use_mirrors_mm_steam():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
return jsonify("false")
except TimeoutError:
@ -171,22 +173,17 @@ def services_tex():
@app.route("/api/v1/consent/eula2", methods=["PUT", "GET"])
def consent_eula():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
if request.method == "PUT":
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
mongo.eula(userId=userid, get_eula=False, server=mongo_host, db=mongo_db, collection=mongo_collection)
return jsonify({"isGiven": True})
return jsonify({"Userid": userid, "ConsentList": [{"ConsentId": "ZKApi", "isGiven": True,
"UpdatedDate": 1689714606, "AttentionNeeded": False,
"LatestVersion": "ZKApi"}]})
except TimeoutError:
return jsonify({"status": "error"})
except Exception as e:
@ -194,7 +191,9 @@ def consent_eula():
message=f"Error in consent_eula: {e}")
elif request.method == "GET":
if request.cookies.get('bhvrSession') is None:
return jsonify({"isGiven": True})
return jsonify({"Userid": userid, "ConsentList": [{"ConsentId": "ZKApi", "isGiven": True,
"UpdatedDate": 1689714606, "AttentionNeeded": False,
"LatestVersion": "ZKApi"}]})
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
@ -205,7 +204,19 @@ def consent_eula():
items={"eula"},
server=mongo_host, db=mongo_db, collection=mongo_collection)
if is_given["eula"]:
return jsonify({"isGiven": True})
return "", 204
return jsonify({
"Userid": "userid",
"ConsentList": [
{
"ConsentId": "ZKApi",
"isGiven": True,
"UpdatedDate": 1689714606,
"AttentionNeeded": False,
"LatestVersion": "ZKApi"
}
]
})
else:
return jsonify({"isGiven": False})
except Exception as e:
@ -214,9 +225,10 @@ def consent_eula():
@app.route("/api/v1/consent/eula", methods=["GET"])
def consent_eula0():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
output = json.load(open(os.path.join(app.root_path, "json", "eula.json"), "r"))
return jsonify(output)
@ -228,15 +240,10 @@ def consent_eula0():
@app.route("/api/v1/consent/privacyPolicy", methods=["GET"])
def privacy_policy():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
output = json.load(open(os.path.join(app.root_path, "json", "eula.json"), "r"))
return jsonify(output)
@ -248,15 +255,10 @@ def privacy_policy():
@app.route("/api/v1/extensions/leaderboard/getScores", methods=["GET", "POST"])
def leaderboard_get_scores():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
if request.method == "POST":
logger.graylog_logger(level="info", handler="general-leaderboard-get-scores",
message=f"Leaderboard getScores: {request.get_json()}")
@ -281,15 +283,10 @@ def submit():
@app.route("/api/v1/extensions/quitters/getQuitterState", methods=["POST"])
def get_quitter_state():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="logging_getQuitterState", message=request.get_json())
return jsonify({"status": "success"})

View File

@ -10,9 +10,7 @@ import uuid
@app.route("/api/v1/config/MATCH_MAKING_REGIONS/raw", methods=["GET"])
def match_making_regions_raw():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
try:
return jsonify(["EU", "US", "AP", "DEV"])
except TimeoutError:
@ -23,48 +21,41 @@ def match_making_regions_raw():
@app.route("/api/v1/queue/info", methods=["GET"])
def queue_info():
# ?category=Steam-te-23ebf96c-27498-ue4-7172a3f5&gameMode=Default&region=US&countA=1&countB=5
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
category = request.args.get("category")
game_mode = request.args.get("gameMode")
region = request.args.get("region")
count_a = request.args.get("countA") # Hunter Count
count_b = request.args.get("countB") # Runner Count
side = request.args.get("side", "")
session = matchmaking_queue.getSession(userid)
try:
# ?category=Steam-te-23ebf96c-27498-ue4-7172a3f5&gameMode=Default&region=US&countA=1&countB=5
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
category = request.args.get("category")
game_mode = request.args.get("gameMode")
region = request.args.get("region")
count_a = request.args.get("countA") # Hunter Count
count_b = request.args.get("countB") # Runner Count
side = request.args.get("side", "")
session = matchmaking_queue.getSession(userid)
if not side:
return jsonify({"message": "Side parameter is missing"}), 400
if not side:
return jsonify({"message": "Side parameter is missing"}), 400
if side not in ["A", "B"]:
return jsonify({"message": "Invalid side parameter"}), 400
if side not in ["A", "B"]:
return jsonify({"message": "Invalid side parameter"}), 400
response_data = matchmaking_queue.getQueueStatus(side, session)
return jsonify(response_data)
# return jsonify({"A": {"Size": 1, "ETA": 100, "stable": True}, "B": {"Size": 5, "ETA": 100, "stable": True}, "SizeA": count_a, "SizeB": count_b})
response_data = matchmaking_queue.getQueueStatus(side, session)
return jsonify(response_data)
# return jsonify({"A": {"Size": 1, "ETA": 100, "stable": True}, "B": {"Size": 5, "ETA": 100, "stable": True}, "SizeA": count_a, "SizeB": count_b})
except TimeoutError:
return jsonify({"status": "TimeoutError"})
except Exception as e:
logger.graylog_logger(level="error", handler="queue_info", message=e)
@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}
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
category = request.json.get("category")
rank = request.json.get("rank")
@ -128,15 +119,9 @@ def queue():
@app.route("/api/v1/queue/cancel", methods=["POST"])
def cancel_queue():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
matchmaking_queue.removePlayerFromQueue(userid)
@ -149,15 +134,9 @@ def cancel_queue():
@app.route("/api/v1/match/<matchid>", methods=["GET"])
def match(matchid):
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
response_data = matchmaking_queue.createMatchResponse(matchid)
@ -169,15 +148,9 @@ def match(matchid):
@app.route("/api/v1/match/<matchid>/Kill", methods=["PUT"])
def match_kill(matchid):
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
lobby, _ = matchmaking_queue.getLobbyById(matchid)
@ -197,15 +170,9 @@ def match_kill(matchid):
@app.route("/api/v1/match/<match_id>/register", methods=["POST"])
def match_register(match_id):
try:
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
logger.graylog_logger(level="info", handler="match_register",
message=f"User {userid} is registering to match {match_id}")
@ -230,15 +197,9 @@ def match_register(match_id):
@app.route("/api/v1/match/<match_id>/Quit", methods=["PUT"])
def match_quit(match_id):
try:
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
logger.graylog_logger(level="info", handler="logging_queue",
message=f"User {userid} is quitting match {match_id}")
@ -268,16 +229,9 @@ def match_create():
# '0385496c-f0ae-44d3-a777-26092750f39c'],
# 'props': {'MatchConfiguration': '/Game/Configuration/MatchConfig/MatchConfig_Demo.MatchConfig_Demo'},
# 'latencies': []}
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
category = request.json.get("category")
rank = request.json.get("rank")
@ -285,11 +239,12 @@ def match_create():
players_b = request.json.get("playersB")
props = request.json.get("props")
match_id = matchmaking_queue.create_match(request.json)
matchid = matchmaking_queue.genMatchUUID()
# match_send = matchmaking_queue.createQueueResponseMatched(userid, matchid, joinerId=players_a)
epoch = datetime.now().timestamp()
player_list = [players_b, players_a]
data = {"MatchId": match_id, "Category": category, "Rank": rank,
data = {"MatchId": matchid, "Category": category, "Rank": rank,
"CreationDateTime": epoch, "ExcludeFriends": False,
"ExcludeClanMembers": False, "Status": "WaitingForPlayers", "Creator": userid,
"Players": player_list, "SideA": players_a, "SideB": players_b, "CustomData": {}, "Props": props,
@ -299,15 +254,9 @@ def match_create():
@app.route("/api/v1/extensions/progression/playerEndOfMatch", methods=["POST"])
def progression_player_end_of_match():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="matchmaking_playerEndOfMatch", message=request.get_json())
return jsonify("", 204)
@ -319,15 +268,9 @@ def progression_player_end_of_match():
@app.route("/file/<game_version>/<seed>/<map_name>", methods=["POST", "GET"])
def file_gold_rush(seed, map_name, game_version):
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
file_name = f"{game_version}_{seed}_{map_name}.raw"
folder_path = os.path.join(app.root_path, "map_seeds")
@ -349,15 +292,10 @@ def file_gold_rush(seed, map_name, game_version):
@app.route("/metrics/matchmaking/event", methods=["POST"])
def metrics_matchmaking_event():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="logging_matchmaking_Event", message=request.get_json())
return jsonify({"status": "success"})

View File

@ -4,15 +4,10 @@ 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"])
def catalog_get(game_version):
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
output = json.load(open(os.path.join(app.root_path, "json", "catalog", game_version, "catalog.json"), "r"))
return jsonify(output)

View File

@ -48,10 +48,7 @@ def steam_login_function():
@app.route("/api/v1/auth/provider/steam/login", methods=["POST"])
def steam_login():
# Read Doc\SteamAuth.md for more information
ip = check = check_for_game_client("strict") # ToDo: Change when cookie validation is added.
if not check:
return jsonify({"message": "Endpoint not found"}), 404
ip = check_for_game_client("soft")
user_agent = request.headers.get('User-Agent')
if user_agent.startswith("TheExit/++UE4+Release-4.2"):
if request.args.get(
@ -97,15 +94,10 @@ def steam_login():
# Dont know if this works
@app.route("/api/v1/modifierCenter/modifiers/me", methods=["GET"])
def modifiers():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
steamid, token = mongo.get_data_with_list(login=userid, login_steam=False,
items={"token", "steamid"}, server=mongo_host, db=mongo_db,
collection=mongo_collection)
@ -121,24 +113,15 @@ def modifiers():
# This works
@app.route("/moderation/check/username", methods=["POST"])
def moderation_check_username():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
request_var = request.get_json()
userid = request_var["userId"]
steamid = mongo.get_data_with_list(login=userid, login_steam=False,
items={"steamid", "userId"}, server=mongo_host, db=mongo_db,
collection=mongo_collection)
steamid = steamid["steamid"]
userid = steamid["userId"]
return jsonify({"Id": userid, "Token": session_cookie,
steamid, token = mongo.get_user_info(userId=userid, server=mongo_host, db=mongo_db, collection=mongo_collection)
return jsonify({"Id": userid, "Token": token,
"Provider": {"ProviderName": request_var["username"],
"ProviderId": steamid}}) # CLIENT:{"userId": "ID-ID-ID-ID-SEE-AUTH", "username": "Name-Name-Name"}
except TimeoutError:
@ -150,15 +133,10 @@ def moderation_check_username():
# Doesn't work
@app.route("/api/v1/progression/experience", methods=["POST"])
def progression_experience():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="user_handling_progression_experience", message=request.get_json())
return jsonify({"List": [
@ -194,15 +172,10 @@ def progression_experience():
@app.route("/api/v1/extensions/challenges/getChallenges", methods=["POST"])
def challenges_get_challenges():
# client: {"data":{"userId":"619d6f42-db87-4f3e-8dc9-3c9995613614","challengeType":"Daily"}}
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
response = request.get_json()
challenge_type = response["data"]["challengeType"]
@ -221,6 +194,7 @@ def challenges_get_challenges():
elif challenge_type == "Daily":
return jsonify({"Challenges": ["Daily_Domination_Hunter", "Daily_Domination_Runner"]})
else:
logger.graylog_logger(level="error", handler="getChallanges", message=f"Unknown challenge type {challenge_type}")
return jsonify({"status": "error"})
except TimeoutError:
@ -231,15 +205,10 @@ def challenges_get_challenges():
@app.route("/api/v1/extensions/challenges/executeChallengeProgressionOperationBatch", methods=["POST"])
def challenges_execute_challenge_progression_operation_batch():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="logging_executeChallengeProgressionOperationBatch",
message=request.get_json())
@ -258,48 +227,15 @@ def challenges_execute_challenge_progression_operation_batch():
# idk dont think it works
@app.route("/api/v1/inventories", methods=["GET"])
def inventories():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
page = request.args.get('page', default=0, type=int)
limit = request.args.get('limit', default=500, type=int)
if page == 0:
return jsonify({"Code": 200, "Message": "OK", "Data": {"PlayerId": userid, "Inventory": [
{"ObjectId": "56B7B6F6-473712D0-B7A2F992-BB2C16CD", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "759E44DD-469C2841-75C2D6A1-AB0B0FA7", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "EF96A202-49884D43-7B87A6A4-BDE81B7F", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "755D4DFE-40DA1512-B01E3D8C-FF3C8D4D", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "CCA2272D-408ED953-87F017BE-D437FF9A", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "C50FFFBF-46866131-82F45890-651797CE", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "606129DC-45AB9D16-B69E2FA5-C99A9835", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "234FFD46-4C55514B-6C1E7386-45993CAA", "Quantity": 1, "LastUpdateAt": 16873773050},
{"ObjectId": "0EA4B7BD-456E322E-E1F0E1BD-6D92F269", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "51595917-43CBF0B5-7EC6FEB3-341960D6", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "08DC38B6-470A7A5B-0BA025B9-6279DAA8", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "7902D836-470BBB49-DE9B9D97-F17C9DB5", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "1069E6DF-40AB4CAE-F2AF03B4-FD60BB22", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "5998C1C5-48AB7BDA-80C87295-F2764C5D", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "F055513D-48AACBAC-280B2AA0-0A984180", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "EDB6D6B7-42023AE6-1AD8718C-AC073C0E", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "1098BEE2-41B1515B-44013A87-EDB16BDC", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "973C9176-404A29F9-26D13BAC-B76A2425", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "50D3005B-437066E4-C4D99F93-97CF1B0B", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "B83A141A-45FB8D96-D48A5185-CD607AA3", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "9281A7AB-4EE28B4F-B6341886-DFD50391", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "4886DDC4-46B96FEE-1255D6A2-AB114B0D", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "0C6D2A46-48B95C22-64312783-F977F211", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "C215B81F-4E421961-03ECE989-49892499", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "30363336-4217BE70-33C637B7-EE7D9CE8", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "5889A14A-44DEC8EA-D019F69C-FD3C5A44", "Quantity": 1, "LastUpdateAt": 1687377305},
{"ObjectId": "DA7C176F-48525599-C9477C95-137C7369", "Quantity": 1, "LastUpdateAt": 1687377305}
], "NextPage": 1}})
return jsonify({"Code": 200, "Message": "OK", "Data": {"PlayerId": userid, "Inventory": [], "NextPage": 0}})
elif page == 1:
return jsonify({"Code": 200, "Message": "OK", "Data": {"PlayerId": userid, "Inventory": [
{"ObjectId": "DA7C176F-48525599-C9477C95-137C7369", "Quantity": 1, "LastUpdateAt": 1687377305},
@ -314,16 +250,10 @@ def inventories():
# idk if this works
@app.route("/api/v1/players/me/splinteredstates/ProgressionGroups", methods=["GET"])
def progression_groups():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
# This is the real code but need to build this first
# return jsonify({"UserId": userid, "StateName": "Fstring", "Segment": "Fstring", "ObjectId": "Fstring",
# "Version": 1111, "schemaVersion": 1111, "Data": {}})
@ -347,15 +277,10 @@ def progression_groups():
# This works
@app.route("/api/v1/players/ban/status", methods=["GET"])
def ban_status():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
time.sleep(0.5)
ban_data = mongo.get_data_with_list(login=userid, login_steam=False,
@ -386,15 +311,10 @@ def ban_status():
# broken. no need to fix... OG DG endpoint. Not needed.
@app.route("/api/v1/players/ban/getbaninfo", methods=["GET"])
def get_ban_info():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
return jsonify({"BanPeriod": None, "BanReason": None, "BanStart": None, "BanEnd": None,
"Confirmed": False})
@ -407,15 +327,10 @@ def get_ban_info():
# This works
@app.route("/api/v1/wallet/currencies", methods=["GET"])
def wallet_currencies():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
currencies = mongo.get_data_with_list(login=userid, login_steam=False,
items={"currency_blood_cells", "currency_iron", "currency_ink_cells"},
@ -439,15 +354,10 @@ def wallet_currencies():
# Does not work. Old DG endpoint. Not needed.
@app.route("/api/v1/wallet/currencies/PROGRESSION_CURRENCY", methods=["GET"])
def wallet_currencies_progression():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
return jsonify([{"Currency": 1, "Amount": 10}, {"Currency": 2, "Amount": 10}, {"Currency": 3, "Amount": 10}])
except TimeoutError:
@ -459,16 +369,11 @@ def wallet_currencies_progression():
# Dont know if this works. Dont think it does.
@app.route("/api/v1/players/me/splinteredstates/TheExit_Achievements", methods=["GET"])
def achievements_get():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
userid = session_manager.get_user_id(session_cookie)
try:
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
return jsonify({"UserId": userid, "StateName": "", "Segment": "", "List": [
{"ObjectId": "EFAB89E6465D1163D62A07B11048F2B6", "Version": 11, "SchemaVersion": 11, "Data": {}}
]})
@ -488,57 +393,50 @@ def achievements_get():
# Does not work
@app.route("/api/v1/messages/count", methods=["GET"])
def messages_count():
check = check_for_game_client("strict")
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
if not check:
return jsonify({"message": "Endpoint not found"}), 404
try:
return jsonify({"Count": 1})
return jsonify({"Count": 2})
except TimeoutError:
return jsonify({"status": "error"})
except Exception as e:
logger.graylog_logger(level="error", handler="messages_count", message=e)
@app.route("/api/v1/messages/list", methods=["GET"])
@app.route("/api/v1/messages/list", methods=["GET", "DELETE"])
def messages_list():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
limit = request.args.get("limit")
output = json.load(open(os.path.join(app.root_path, "json", "placeholders", "messages.json"), "r"))
return jsonify(output)
return jsonify({"messages": []}) # from dbd
if request.method == "GET":
limit = request.args.get("limit")
output = json.load(open(os.path.join(app.root_path, "json", "placeholders", "messages.json"), "r"))
return jsonify(output)
return jsonify({"messages": []}) # from dbd
elif request.method == "DELETE":
return jsonify("", 204)
except TimeoutError:
return jsonify({"status": "error"})
except Exception as e:
logger.graylog_logger(level="error", handler="messages_list", message=e)
@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"])
def moderation_check_chat():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
data = request.get_json()
userid = data["userId"]
@ -555,15 +453,10 @@ 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"])
def extension_progression_init_or_get_groups():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="logging_initOrGetGroups", message=request.get_json())
# Client sends: {"data":{"skipProgressionGroups":false,"skipMetadataGroups":false,"playerName":"Steam-Name-Here"}}
@ -627,15 +520,10 @@ def extension_progression_init_or_get_groups():
# dont know if this works. Hope it does.
@app.route("/api/v1/extensions/inventory/unlockSpecialItems", methods=["POST"])
def inventory_unlock_special_items():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="unknown_unlockSpecialItems", message=request.get_json())
return jsonify({"UnlockedItems": ["9F54DE7A-4E15935B-503850A1-27B0A2A4"]})
@ -647,15 +535,10 @@ def inventory_unlock_special_items():
@app.route("/api/v1/extensions/challenges/getChallengeProgressionBatch", methods=["POST"])
def challenges_get_challenge_progression_batch():
check = check_for_game_client("strict")
if not check:
return jsonify({"message": "Endpoint not found"}), 404
check_for_game_client("strict")
session_cookie = request.cookies.get("bhvrSession")
if not session_cookie:
return jsonify({"message": "Endpoint not found"}), 404
userid = session_manager.get_user_id(session_cookie)
if userid == 401:
return jsonify({"message": "Endpoint not found"}), 404
try:
logger.graylog_logger(level="info", handler="logging_getChallengeProgressionBatch",
message=request.get_json())

View File

@ -1,5 +1,6 @@
import uuid
from logic.time_handler import get_time
from logic.logging_handler import logger
class QueueData:
@ -44,46 +45,57 @@ class MatchmakingQueue:
self.queuedPlayers = []
def queuePlayer(self, side, userId):
queuedPlayer = QueuedPlayer(userId, side,
get_time())
self.queuedPlayers.append(queuedPlayer)
try:
queuedPlayer = QueuedPlayer(userId, side,
get_time())
self.queuedPlayers.append(queuedPlayer)
except Exception as e:
logger.graylog_logger(level="error", handler="matchmaking_queuePlayer", message=e)
def getQueuedPlayer(self, userid):
for i, queuedPlayer in enumerate(self.queuedPlayers):
if queuedPlayer.userId == userid:
return queuedPlayer, i
return None, -1
try:
for i, queuedPlayer in enumerate(self.queuedPlayers):
if queuedPlayer.userId == userid:
return queuedPlayer, i
return None, -1
except Exception as e:
logger.graylog_logger(level="error", handler="matchmaking_getQueuedPlayer", message=e)
return None
def getQueueStatus(self, side, userid):
queuedPlayer, index = self.getQueuedPlayer(userid)
if not queuedPlayer:
return {}
if side == 'B':
if self.openLobbies:
for openLobby in self.openLobbies:
if not openLobby.isReady or openLobby.hasStarted:
continue
if len(openLobby.nonHosts) < 4:
openLobby.nonHosts.append(queuedPlayer)
self.queuedPlayers.pop(index)
return self.createQueueResponseMatched(openLobby.host.userId, openLobby.id,
userid)
try:
queuedPlayer, index = self.getQueuedPlayer(userid)
if not queuedPlayer:
return {}
if side == 'B':
if self.openLobbies:
for openLobby in self.openLobbies:
if not openLobby.isReady or openLobby.hasStarted:
continue
if len(openLobby.nonHosts) < 4:
openLobby.nonHosts.append(queuedPlayer)
self.queuedPlayers.pop(index)
return self.createQueueResponseMatched(openLobby.host.userId, openLobby.id,
userid)
else:
return {
"queueData": {
"ETA": -10000,
"position": 0,
"sizeA": 0,
"sizeB": 1,
},
"status": "QUEUED",
}
else:
return {
"queueData": {
"ETA": -10000,
"position": 0,
"sizeA": 0,
"sizeB": 1,
},
"status": "QUEUED",
}
else:
matchId = self.genMatchUUID()
lobby = Lobby(False, queuedPlayer, [], matchId, False, False)
self.openLobbies.append(lobby)
return self.createQueueResponseMatched(userid, matchId)
matchId = self.genMatchUUID()
lobby = Lobby(False, queuedPlayer, [], matchId, False, False)
self.openLobbies.append(lobby)
return self.createQueueResponseMatched(userid, matchId)
except Exception as e:
logger.graylog_logger(level="error", handler="matchmaking_getQueueStatus", message=e)
return None
def removePlayerFromQueue(self, userid):
_, index = self.getQueuedPlayer(userid)
@ -127,62 +139,18 @@ class MatchmakingQueue:
self.killedLobbies.pop(i)
def createMatchResponse(self, matchId, killed=False):
lobby = self.getLobbyById(matchId)[0] or self.getKilledLobbyById(matchId)
if not lobby:
return {}
return {
"category": "oman-100372-dev:None:Windows:::1:4:0:G:2",
"churn": 0,
"creationDateTime": get_time(),
"creator": lobby.host.userId,
"customData": {
"SessionSettings": lobby.sessionSettings or "",
},
"geolocation": {},
"matchId": matchId,
"props": {
"countA": 1,
"countB": 4,
"EncryptionKey": "Rpqy9fgpIWrHxjJpiwnJJtoZ2hbUZZ4paU+0n4K/iZI=",
"gameMode": "None",
"platform": "Windows",
},
"rank": 1,
"reason": lobby.reason or "",
"schema": 3,
"sideA": [lobby.host.userId],
"sideB": [player.userId for player in lobby.nonHosts],
"skill": {
"continent": "NA",
"country": "US",
"latitude": 0,
"longitude": 0,
"rank": 20,
"rating": {
"rating": 1500,
"RD": 347.4356,
"volatility": 0.06,
},
"regions": {
"good": ["us-east-1"],
"ok": ["us-east-1"],
},
"version": 2,
"x": 20,
},
"status": "KILLED" if killed else "OPENED",
"version": 2,
}
def createQueueResponseMatched(self, creatorId, matchId, joinerId=None):
return {
"status": "MATCHED",
"matchData": {
"category": "oman-100372-dev:None:Windows:::1:4:0:G:2",
try:
lobby = self.getLobbyById(matchId)[0] or self.getKilledLobbyById(matchId)
if not lobby:
return {}
return {
"category": "Steam-te-18f25613-36778-ue4-374f864b",
"churn": 0,
"creationDateTime": get_time(),
"creator": creatorId,
"customData": {},
"creator": lobby.host.userId,
"customData": {
"SessionSettings": lobby.sessionSettings or "",
},
"geolocation": {},
"matchId": matchId,
"props": {
@ -193,10 +161,10 @@ class MatchmakingQueue:
"platform": "Windows",
},
"rank": 1,
"reason": "",
"reason": lobby.reason or "",
"schema": 3,
"sideA": [creatorId],
"sideB": [joinerId] if joinerId else [],
"sideA": [lobby.host.userId],
"sideB": [player.userId for player in lobby.nonHosts],
"skill": {
"continent": "NA",
"country": "US",
@ -215,10 +183,60 @@ class MatchmakingQueue:
"version": 2,
"x": 20,
},
"status": "CREATED",
"version": 1,
},
}
"status": "KILLED" if killed else "OPENED",
"version": 2,
}
except Exception as e:
logger.graylog_logger(level="error", handler="matchmaking_createMatchResponse", message=e)
def createQueueResponseMatched(self, creatorId, matchId, joinerId=None):
try:
return {
"status": "MATCHED",
"matchData": {
"category": "Steam-te-18f25613-36778-ue4-374f864b",
"churn": 0,
"creationDateTime": get_time(),
"creator": creatorId,
"customData": {},
"geolocation": {},
"matchId": matchId,
"props": {
"countA": 1,
"countB": 4,
"EncryptionKey": "Rpqy9fgpIWrHxjJpiwnJJtoZ2hbUZZ4paU+0n4K/iZI=",
"gameMode": "None",
"platform": "Windows",
},
"rank": 1,
"reason": "",
"schema": 3,
"sideA": [creatorId],
"sideB": [joinerId] if joinerId else [],
"skill": {
"continent": "NA",
"country": "US",
"latitude": 0,
"longitude": 0,
"rank": 20,
"rating": {
"rating": 1500,
"RD": 347.4356,
"volatility": 0.06,
},
"regions": {
"good": ["us-east-1"],
"ok": ["us-east-1"],
},
"version": 2,
"x": 20,
},
"status": "CREATED",
"version": 1,
},
}
except Exception as e:
logger.graylog_logger(level="error", handler="matchmaking_createQueueResponseMatched", message=e)
def genMatchUUID(self):
return str(uuid.uuid4())