mirror of
https://github.com/wolfswolke/DeathGarden_API_Rebirth.git
synced 2026-03-23 10:44:31 -05:00
Splitted Endpoints into different Files to make its clearer what is what.
This commit is contained in:
parent
fef61b0af6
commit
efe2ecd28f
238
src/endpoints/general.py
Normal file
238
src/endpoints/general.py
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
from flask_definitions import *
|
||||
import os
|
||||
|
||||
|
||||
@app.route("/file/te-f9b4768a-26590-ue4-cefc1aee/1686509333/Survival-Biome_Definition_DES_Mayan", methods=["POST"])
|
||||
def file_survival_biome_definition_des_mayan():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to file survival biome definition des mayan api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/gamenews/messages", methods=["GET"])
|
||||
def gamenews():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to aaaaa api call GET")
|
||||
return jsonify({"news": [
|
||||
{"contentTags": ["steam", "xbox", "ps4", "grdk", "xsx", "ps5", "egs", "stadia", "switch"],
|
||||
"description": "It's not The Clown's Bottles making you see double.<br/><br/>From September 1st 11AM ET - September 8th 11AM ET, earn twice the XP from Trials and Emblems.",
|
||||
"dwnImagePath": "", "imageHeight": "", "imagePath": "", "isHidden": False,
|
||||
"startDate": "2022-09-01T15:00:00", "title": "Double XP Event", "type": 5, "version": "6.2.0",
|
||||
"weight": 40990.0}]})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/config/VER_LATEST_CLIENT_DATA", methods=["GET"])
|
||||
def config_ver_latest_client_data():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to config ver latest client data api call GET")
|
||||
return jsonify({"status": "success", "value": "6.2.0"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/2.2", methods=["GET"])
|
||||
def content_version_latest():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({"availableVersions": {
|
||||
"10.0.19045.1.256live": "te-18f25613-36778-ue4-374f864b",
|
||||
"3.3.0_241792live": "te-f9b4768a-26590-ue4-cefc1aee",
|
||||
"3.3.0_244688live": "3.3.0_244688live-1573508813"}})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/gameservers.dev", methods=["POST"])
|
||||
def gameservers_dev():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to Gameserver event api call POST")
|
||||
# graylog_logger(request.get_json(), "warning")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/config/UseMirrorsMM_Steam", methods=["GET"])
|
||||
def config_use_mirrors_mm_steam():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to config use mirrors mm steam api call GET")
|
||||
return jsonify({"status": "success", "value": "true"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/crashreport/unreal/CrashReporter/Ping", methods=["GET"])
|
||||
def crashreporter_ping():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to crashreporter ping api call GET")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/tex", methods=["GET"])
|
||||
def tex_get():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def root():
|
||||
try:
|
||||
get_remote_ip()
|
||||
return jsonify({"status": "success"})
|
||||
# return render_template("index.html")
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route('/favicon.ico')
|
||||
def favicon():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return send_from_directory(os.path.join(app.root_path, 'image'), 'favicon.ico',
|
||||
mimetype='image/vnd.microsoft.icon')
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/healthcheck", methods=["GET"])
|
||||
def healthcheck():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return jsonify({"status": "success", "online": "true"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/services/tex")
|
||||
def services_tex():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to tex api call GET")
|
||||
return {"status": "success"}
|
||||
# return jsonify({"status": "success", "online": "true", "Version": "te-18f25613-36778-ue4-374f864b",
|
||||
# "ProjectID": "F72FA5E64FA43E878DC72896AD677FB5",
|
||||
# "DefaultFactoryName": "HttpNetworkReplayStreaming", "ServeMatchDelayInMin": "30.0f"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/2.11", methods=["GET"])
|
||||
def content_version():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({
|
||||
"latestSupportedVersion": "te-18f25613-36778-ue4-374f864b"}) # Don't know if this is correct. Just testing.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/0", methods=["GET"])
|
||||
def content_version0():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({
|
||||
"latestSupportedVersion": "te-18f25613-36778-ue4-374f864b"}) # Don't know if this is correct. Just testing.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/1.1", methods=["GET"])
|
||||
def content_version1():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({
|
||||
"latestSupportedVersion": "te-18f25613-36778-ue4-374f864b"}) # Don't know if this is correct. Just testing.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/consent/eula2", methods=["GET"])
|
||||
def consent_eula():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to consent eula api call GET")
|
||||
return jsonify({"status": "success", "consent": "true"}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"id": "eula", "language": ["de", "en", "es", "es-MX", "fr", "it", "ja", "ko", "nl", "pl",
|
||||
"pt-BR", "ru", "sv", "th", "tr", "zh-Hans", "zh-Hant"],
|
||||
"platform": ["steam", "xbox", "xsx", "switch", "grdk", "stadia"]})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/consent/eula", methods=["GET"])
|
||||
def consent_eula0():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to consent eula api call GET")
|
||||
return jsonify({"status": "success", "consent": "true"}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"id": "eula", "language": ["de", "en", "es", "es-MX", "fr", "it", "ja", "ko", "nl", "pl",
|
||||
"pt-BR", "ru", "sv", "th", "tr", "zh-Hans", "zh-Hant"],
|
||||
"platform": ["steam", "xbox", "xsx", "switch", "grdk", "stadia"]})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
131
src/endpoints/logging.py
Normal file
131
src/endpoints/logging.py
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
from flask_definitions import *
|
||||
|
||||
|
||||
@app.route("/api/v1/extensions/quitters/getQuitterState", methods=["POST"])
|
||||
def get_quitter_state():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to get quitter state api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/extensions/progression/initOrGetGroups", methods=["POST"])
|
||||
def extension_progression_init_or_get_groups():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to extension progression init or get groups api call POST")
|
||||
print(request.get_json())
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({'data': {'skipProgressionGroups': True, 'skipMetadataGroups': True}})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/metrics/client/event", methods=["POST"])
|
||||
def receive_event():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to Metrics api call POST")
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/metrics/httplog/event", methods=["POST"])
|
||||
def metrics_httplog_event():
|
||||
get_remote_ip()
|
||||
try:
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/gameDataAnalytics", methods=["POST"])
|
||||
def analytics_post():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to analytics api call POST")
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/gameDataAnalytics/batch", methods=["POST"])
|
||||
def analytics_batch_post():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to analytics batch api call POST")
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/me/richPresence", methods=["POST"])
|
||||
def me_rich_presence():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to me rich presence api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/metrics/server/event", methods=["POST"])
|
||||
def metrics_server_event():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to metrics server event api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/crashreport/unreal/CrashReporter/CheckReport", methods=["POST"])
|
||||
def crashreporter_check_report():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to crashreporter check report api call POST")
|
||||
# TODO: Add Crashreporter
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
27
src/endpoints/unknown.py
Normal file
27
src/endpoints/unknown.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from flask_definitions import *
|
||||
|
||||
|
||||
@app.route("/te-18f25613-36778-ue4-374f864b/catalog", methods=["GET"])
|
||||
def catalog_get():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/extensions/inventory/unlockSpecialItems", methods=["POST"])
|
||||
def inventory_unlock_special_items():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to Inventory Unlock Special Items event api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
187
src/endpoints/user_handeling.py
Normal file
187
src/endpoints/user_handeling.py
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
from flask_definitions import *
|
||||
import requests
|
||||
from logic.mongodb_handler import user_db_handler
|
||||
from logic.time_handler import get_time
|
||||
|
||||
global steam_api_key, mongo_db, mongo_collection, mongo_host
|
||||
|
||||
def steam_login_function(appid):
|
||||
try:
|
||||
steam_session_token = request.args.get('token')
|
||||
response = requests.get(
|
||||
'https://api.steampowered.com/ISteamUserAuth/AuthenticateUserTicket/v1/?key={}&ticket={}&appid={}'.format(
|
||||
steam_api_key, steam_session_token, appid))
|
||||
steamid = response.json()["response"]["params"]["steamid"]
|
||||
# owner_id = response.json()["response"]["params"]["result"]["ownersteamid"] # This is providerId
|
||||
|
||||
userid, token = user_db_handler(steamid, mongo_host, mongo_db, mongo_collection)
|
||||
current_time, expire_time = get_time()
|
||||
|
||||
graylog_logger("User {} logged in".format(steamid), "info")
|
||||
print("User {} logged in".format(steamid))
|
||||
# Read: Doc -> AUTH
|
||||
# You can copy and paste the JSON from the Auth Doc here. If you don't have a steam api key.
|
||||
# The Client does not validate this and just uses it.
|
||||
return jsonify({"preferredLanguage": "en", "friendsFirstSync": {"steam": True}, "fixedMyFriendsUserPlatformId":
|
||||
{"steam": True}, "id": userid, "provider": {"providerId": steamid, "providerName": "steam", "userId":
|
||||
userid}, "providers": [{"providerName": "steam", "providerId": steamid}], "friends": [], "triggerResults":
|
||||
{"success": [], "error": []}, "tokenId": userid, "generated": current_time,
|
||||
"expire": expire_time,
|
||||
"userId": userid, "token": token})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/auth/provider/steam/login", methods=["POST"])
|
||||
def steam_login():
|
||||
# Read Doc\SteamAuth.md for more information
|
||||
ip = get_remote_ip()
|
||||
user_agent = request.headers.get('User-Agent')
|
||||
print("####################################################")
|
||||
print("USER AGENT: " + user_agent)
|
||||
print("####################################################")
|
||||
|
||||
if user_agent == "TheExit/++UE4+Release-4.21-CL-0 Windows/6.2.9200.1.256.64bit":
|
||||
return_val = steam_login_function(854040)
|
||||
return return_val
|
||||
|
||||
elif user_agent.startswith("TheExit/++UE4+Release-4.21-CL-0 Windows"):
|
||||
try:
|
||||
return_val = steam_login_function(555440)
|
||||
return return_val
|
||||
except Exception as e:
|
||||
print("EXCEPTION: " + str(e))
|
||||
return_val = steam_login_function(854040)
|
||||
return return_val
|
||||
|
||||
elif user_agent.startswith("game=TheExit, engine=UE4, version="):
|
||||
return_val = steam_login_function(854040)
|
||||
return return_val
|
||||
|
||||
else:
|
||||
graylog_logger("Unauthorized User Agent {} connected from IP {}".format(user_agent, ip), "error")
|
||||
abort(401, "Unauthorized")
|
||||
|
||||
|
||||
@app.route("/api/v1/modifierCenter/modifiers/me", methods=["GET"])
|
||||
def modifiers():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to modifiers api call GET")
|
||||
return jsonify({"status": "success", "modifiers": []}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/moderation/check/username", methods=["POST"])
|
||||
def moderation_check_username():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to moderation check username api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success",
|
||||
"isAllowed": "true"}) # CLIENT: {"userId": "ID-ID-ID-ID-SEE-AUTH", "username": "Name-Name-Name"}
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/progression/experience", methods=["POST"])
|
||||
def progression_experience():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to progression experience api call POST")
|
||||
print(request.get_json())
|
||||
# graylog_logger(request.get_json(), "info")
|
||||
return jsonify({'groupExperiences': [{'objectId': 'PlayerProgression', 'experience': 0.57, 'version': 1}, {'objectId': 'RunnerProgression', 'experience': 0.555, 'version': 1}, {'objectId': 'HunterProgression', 'experience': 0.67, 'version': 1}]})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/extensions/challenges/getChallenges", methods=["POST"])
|
||||
def challenges_get_challenges():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to challenges get challenges api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/inventories", methods=["GET"])
|
||||
def inventories():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to inventories api call GET")
|
||||
return jsonify({})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/players/me/splinteredstates/ProgressionGroups", methods=["GET"])
|
||||
def progression_groups():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to progression groups api call GET")
|
||||
return jsonify({"status": "success", "progressionGroups": [1]}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
@app.route("/api/v1/players/ban/status", methods=["GET"])
|
||||
def ban_status():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to ban status api call GET")
|
||||
return jsonify({"banned": "false"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/wallet/currencies", methods=["GET"])
|
||||
def wallet_currencies():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to wallet currencies api call GET")
|
||||
return jsonify({"currencies": "EUR"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/players/me/splinteredstates/TheExit_Achievements", methods=["GET"])
|
||||
def achievements_get():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to achievements api call GET")
|
||||
return jsonify({"status": "success", "achievements": []}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
14
src/flask_definitions.py
Normal file
14
src/flask_definitions.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from flask import Flask, jsonify, request, send_from_directory, abort
|
||||
from logic.global_handlers import get_remote_ip, load_config
|
||||
from logic.logging_handler import graylog_logger
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
config = load_config()
|
||||
use_graylog = config['graylog']['use']
|
||||
graylog_server = config['graylog']['host']
|
||||
steam_api_key = config['steam']['api_key']
|
||||
mongo_host = config['mongodb']['host']
|
||||
mongo_db = config['mongodb']['db']
|
||||
mongo_collection = config['mongodb']['collection']
|
||||
17
src/logic/global_handlers.py
Normal file
17
src/logic/global_handlers.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from flask_definitions import *
|
||||
import yaml
|
||||
|
||||
|
||||
def get_remote_ip():
|
||||
if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
|
||||
ip_addr = request.environ['REMOTE_ADDR']
|
||||
else:
|
||||
ip_addr = request.environ['HTTP_X_FORWARDED_FOR']
|
||||
print("New Connection from: " + ip_addr)
|
||||
return ip_addr
|
||||
|
||||
|
||||
def load_config():
|
||||
with open('config//api_config.yaml', 'r') as f:
|
||||
config_file = yaml.safe_load(f)
|
||||
return config_file
|
||||
31
src/logic/logging_handler.py
Normal file
31
src/logic/logging_handler.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import logging
|
||||
import graypy
|
||||
|
||||
|
||||
def setup_graylog(use_graylog, graylog_server):
|
||||
if use_graylog:
|
||||
global my_logger
|
||||
my_logger = logging.getLogger('deathgarden_api')
|
||||
my_logger.setLevel(logging.DEBUG)
|
||||
handler = graypy.GELFUDPHandler(graylog_server, 12201)
|
||||
my_logger.addHandler(handler)
|
||||
my_logger.debug('Started Death Garden API')
|
||||
else:
|
||||
print("Graylog disabled. Not sending any Logs.")
|
||||
|
||||
|
||||
def graylog_logger(message, level):
|
||||
use_graylog = True
|
||||
if use_graylog:
|
||||
if level == "debug":
|
||||
my_logger.debug(message)
|
||||
if level == "warning":
|
||||
my_logger.warning(message)
|
||||
if level == "error":
|
||||
my_logger.error(message)
|
||||
if level == "info":
|
||||
my_logger.info(message)
|
||||
else:
|
||||
print("No valid log level specified.")
|
||||
else:
|
||||
print("Graylog disabled. Not sending any Logs.")
|
||||
643
src/start_app.py
643
src/start_app.py
|
|
@ -4,639 +4,21 @@
|
|||
# ------------------------------------------------------- #
|
||||
# imports
|
||||
# ------------------------------------------------------- #
|
||||
from flask import Flask, send_from_directory, request, jsonify, abort
|
||||
from threading import Thread
|
||||
import os
|
||||
import yaml
|
||||
import graypy
|
||||
import requests
|
||||
import logging
|
||||
import time
|
||||
|
||||
from logic.mongodb_handler import user_db_handler
|
||||
from logic.time_handler import get_time
|
||||
from logic.logging_handler import setup_graylog
|
||||
|
||||
from flask_definitions import *
|
||||
import endpoints.unknown
|
||||
import endpoints.user_handeling
|
||||
import endpoints.general
|
||||
import endpoints.logging
|
||||
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# functions
|
||||
# ------------------------------------------------------- #
|
||||
def load_config():
|
||||
with open('config//api_config.yaml', 'r') as f:
|
||||
config_file = yaml.safe_load(f)
|
||||
return config_file
|
||||
|
||||
|
||||
def setup_graylog():
|
||||
if use_graylog:
|
||||
global my_logger
|
||||
my_logger = logging.getLogger('deathgarden_api')
|
||||
my_logger.setLevel(logging.DEBUG)
|
||||
handler = graypy.GELFUDPHandler(graylog_server, 12201)
|
||||
my_logger.addHandler(handler)
|
||||
my_logger.debug('Started Death Garden API')
|
||||
else:
|
||||
print("Graylog disabled. Not sending any Logs.")
|
||||
|
||||
|
||||
def graylog_logger(message, level):
|
||||
if use_graylog:
|
||||
if level == "debug":
|
||||
my_logger.debug(message)
|
||||
if level == "warning":
|
||||
my_logger.warning(message)
|
||||
if level == "error":
|
||||
my_logger.error(message)
|
||||
if level == "info":
|
||||
my_logger.info(message)
|
||||
else:
|
||||
print("No valid log level specified.")
|
||||
else:
|
||||
print("Graylog disabled. Not sending any Logs.")
|
||||
|
||||
|
||||
def get_remote_ip():
|
||||
if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
|
||||
ip_addr = request.environ['REMOTE_ADDR']
|
||||
else:
|
||||
ip_addr = request.environ['HTTP_X_FORWARDED_FOR']
|
||||
print("New Connection from: " + ip_addr)
|
||||
return ip_addr
|
||||
|
||||
|
||||
def steam_login_function(appid):
|
||||
try:
|
||||
steam_session_token = request.args.get('token')
|
||||
response = requests.get(
|
||||
'https://api.steampowered.com/ISteamUserAuth/AuthenticateUserTicket/v1/?key={}&ticket={}&appid={}'.format(
|
||||
steam_api_key, steam_session_token, appid))
|
||||
steamid = response.json()["response"]["params"]["steamid"]
|
||||
# owner_id = response.json()["response"]["params"]["result"]["ownersteamid"] # This is providerId
|
||||
|
||||
userid, token = user_db_handler(steamid, mongo_host, mongo_db, mongo_collection)
|
||||
current_time, expire_time = get_time()
|
||||
|
||||
graylog_logger("User {} logged in".format(steamid), "info")
|
||||
print("User {} logged in".format(steamid))
|
||||
# Read: Doc -> AUTH
|
||||
# You can copy and paste the JSON from the Auth Doc here. If you don't have a steam api key.
|
||||
# The Client does not validate this and just uses it.
|
||||
return jsonify({"preferredLanguage": "en", "friendsFirstSync": {"steam": True}, "fixedMyFriendsUserPlatformId":
|
||||
{"steam": True}, "id": userid, "provider": {"providerId": steamid, "providerName": "steam", "userId":
|
||||
userid}, "providers": [{"providerName": "steam", "providerId": steamid}], "friends": [], "triggerResults":
|
||||
{"success": [], "error": []}, "tokenId": userid, "generated": current_time,
|
||||
"expire": expire_time,
|
||||
"userId": userid, "token": token})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def root():
|
||||
try:
|
||||
get_remote_ip()
|
||||
return jsonify({"status": "success"})
|
||||
# return render_template("index.html")
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route('/favicon.ico')
|
||||
def favicon():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return send_from_directory(os.path.join(app.root_path, 'image'), 'favicon.ico',
|
||||
mimetype='image/vnd.microsoft.icon')
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/metrics/client/event", methods=["POST"])
|
||||
def receive_event():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to Metrics api call POST")
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/metrics/httplog/event", methods=["POST"])
|
||||
def metrics_httplog_event():
|
||||
get_remote_ip()
|
||||
try:
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/healthcheck", methods=["GET"])
|
||||
def healthcheck():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return jsonify({"status": "success", "online": "true"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/services/tex")
|
||||
def services_tex():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to tex api call GET")
|
||||
return {"status": "success"}
|
||||
# return jsonify({"status": "success", "online": "true", "Version": "te-18f25613-36778-ue4-374f864b",
|
||||
# "ProjectID": "F72FA5E64FA43E878DC72896AD677FB5",
|
||||
# "DefaultFactoryName": "HttpNetworkReplayStreaming", "ServeMatchDelayInMin": "30.0f"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/gameDataAnalytics", methods=["POST"])
|
||||
def analytics_post():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to analytics api call POST")
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/gameDataAnalytics/batch", methods=["POST"])
|
||||
def analytics_batch_post():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to analytics batch api call POST")
|
||||
data = request.get_json()
|
||||
graylog_logger(data, "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/auth/provider/steam/login", methods=["POST"])
|
||||
def steam_login():
|
||||
# Read Doc\SteamAuth.md for more information
|
||||
ip = get_remote_ip()
|
||||
user_agent = request.headers.get('User-Agent')
|
||||
print("####################################################")
|
||||
print("USER AGENT: " + user_agent)
|
||||
print("####################################################")
|
||||
|
||||
if user_agent == "TheExit/++UE4+Release-4.21-CL-0 Windows/6.2.9200.1.256.64bit":
|
||||
return_val = steam_login_function(854040)
|
||||
return return_val
|
||||
|
||||
elif user_agent.startswith("TheExit/++UE4+Release-4.21-CL-0 Windows"):
|
||||
try:
|
||||
return_val = steam_login_function(555440)
|
||||
return return_val
|
||||
except Exception as e:
|
||||
print("EXCEPTION: " + str(e))
|
||||
return_val = steam_login_function(854040)
|
||||
return return_val
|
||||
|
||||
elif user_agent.startswith("game=TheExit, engine=UE4, version="):
|
||||
return_val = steam_login_function(854040)
|
||||
return return_val
|
||||
|
||||
else:
|
||||
graylog_logger("Unauthorized User Agent {} connected from IP {}".format(user_agent, ip), "error")
|
||||
abort(401, "Unauthorized")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/2.11", methods=["GET"])
|
||||
def content_version():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({"latestSupportedVersion": "te-18f25613-36778-ue4-374f864b"}) # Don't know if this is correct. Just testing.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/0", methods=["GET"])
|
||||
def content_version0():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({
|
||||
"latestSupportedVersion": "te-18f25613-36778-ue4-374f864b"}) # Don't know if this is correct. Just testing.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/1.1", methods=["GET"])
|
||||
def content_version1():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({
|
||||
"latestSupportedVersion": "te-18f25613-36778-ue4-374f864b"}) # Don't know if this is correct. Just testing.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/modifierCenter/modifiers/me", methods=["GET"])
|
||||
def modifiers():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to modifiers api call GET")
|
||||
return jsonify({"status": "success", "modifiers": []}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/consent/eula2", methods=["GET"])
|
||||
def consent_eula():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to consent eula api call GET")
|
||||
return jsonify({"status": "success", "consent": "true"}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"id": "eula", "language": ["de", "en", "es", "es-MX", "fr", "it", "ja", "ko", "nl", "pl",
|
||||
"pt-BR", "ru", "sv", "th", "tr", "zh-Hans", "zh-Hant"],
|
||||
"platform": ["steam", "xbox", "xsx", "switch", "grdk", "stadia"]})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
@app.route("/api/v1/consent/eula", methods=["GET"])
|
||||
def consent_eula0():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to consent eula api call GET")
|
||||
return jsonify({"status": "success", "consent": "true"}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"id": "eula", "language": ["de", "en", "es", "es-MX", "fr", "it", "ja", "ko", "nl", "pl",
|
||||
"pt-BR", "ru", "sv", "th", "tr", "zh-Hans", "zh-Hant"],
|
||||
"platform": ["steam", "xbox", "xsx", "switch", "grdk", "stadia"]})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
|
||||
# Logging
|
||||
@app.route("/api/v1/extensions/quitters/getQuitterState", methods=["POST"])
|
||||
def get_quitter_state():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to get quitter state api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
# Logging
|
||||
@app.route("/api/v1/extensions/progression/initOrGetGroups", methods=["POST"])
|
||||
def extension_progression_init_or_get_groups():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to extension progression init or get groups api call POST")
|
||||
print(request.get_json())
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({'data': {'skipProgressionGroups': True, 'skipMetadataGroups': True}})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
# Logging
|
||||
@app.route("/api/v1/me/richPresence", methods=["POST"])
|
||||
def me_rich_presence():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to me rich presence api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/moderation/check/username", methods=["POST"])
|
||||
def moderation_check_username():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to moderation check username api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success",
|
||||
"isAllowed": "true"}) # CLIENT: {"userId": "ID-ID-ID-ID-SEE-AUTH", "username": "Name-Name-Name"}
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
# Logging for Server Events
|
||||
@app.route("/metrics/server/event", methods=["POST"])
|
||||
def metrics_server_event():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to metrics server event api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
# [Backend]
|
||||
@app.route("/tex", methods=["GET"])
|
||||
def tex_get():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/te-18f25613-36778-ue4-374f864b/catalog", methods=["GET"])
|
||||
def catalog_get():
|
||||
get_remote_ip()
|
||||
try:
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/players/me/splinteredstates/TheExit_Achievements", methods=["GET"])
|
||||
def achievements_get():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to achievements api call GET")
|
||||
return jsonify({"status": "success", "achievements": []}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/crashreport/unreal/CrashReporter/Ping", methods=["GET"])
|
||||
def crashreporter_ping():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to crashreporter ping api call GET")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/players/ban/status", methods=["GET"])
|
||||
def ban_status():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to ban status api call GET")
|
||||
return jsonify({"banned": "false"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/wallet/currencies", methods=["GET"])
|
||||
def wallet_currencies():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to wallet currencies api call GET")
|
||||
return jsonify({"currencies": "EUR"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/extensions/inventory/unlockSpecialItems", methods=["POST"])
|
||||
def inventory_unlock_special_items():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to Inventory Unlocik Speical Items event api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/crashreport/unreal/CrashReporter/CheckReport", methods=["POST"])
|
||||
def crashreporter_check_report():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to crashreporter check report api call POST")
|
||||
# TODO: Add Crashreporter
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/utils/contentVersion/latest/2.2", methods=["GET"])
|
||||
def content_version_latest():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to content version api call GET")
|
||||
return jsonify({"availableVersions": {
|
||||
"10.0.19045.1.256live": "te-18f25613-36778-ue4-374f864b",
|
||||
"3.3.0_241792live": "te-f9b4768a-26590-ue4-cefc1aee",
|
||||
"3.3.0_244688live": "3.3.0_244688live-1573508813"}})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/gameservers.dev", methods=["POST"])
|
||||
def gameservers_dev():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to Gameserver event api call POST")
|
||||
# graylog_logger(request.get_json(), "warning")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/config/UseMirrorsMM_Steam", methods=["GET"])
|
||||
def config_use_mirrors_mm_steam():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to config use mirrors mm steam api call GET")
|
||||
return jsonify({"status": "success", "value": "true"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/players/me/splinteredstates/ProgressionGroups", methods=["GET"])
|
||||
def progression_groups():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to progression groups api call GET")
|
||||
return jsonify({"status": "success", "progressionGroups": [1]}) # Don't know. Added as Placeholder.
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/progression/experience", methods=["POST"])
|
||||
def progression_experience():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to progression experience api call POST")
|
||||
print(request.get_json())
|
||||
# graylog_logger(request.get_json(), "info")
|
||||
return jsonify({'groupExperiences': [{'objectId': 'PlayerProgression', 'experience': 0.57, 'version': 1}, {'objectId': 'RunnerProgression', 'experience': 0.555, 'version': 1}, {'objectId': 'HunterProgression', 'experience': 0.67, 'version': 1}]})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/file/te-f9b4768a-26590-ue4-cefc1aee/1686509333/Survival-Biome_Definition_DES_Mayan", methods=["POST"])
|
||||
def file_survival_biome_definition_des_mayan():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to file survival biome definition des mayan api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/extensions/challenges/getChallenges", methods=["POST"])
|
||||
def challenges_get_challenges():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to challenges get challenges api call POST")
|
||||
graylog_logger(request.get_json(), "info")
|
||||
return jsonify({"status": "success"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/gamenews/messages", methods=["GET"])
|
||||
def gamenews():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to aaaaa api call GET")
|
||||
return jsonify({"news":[{"contentTags":["steam","xbox","ps4","grdk","xsx","ps5","egs","stadia","switch"],"description":"It's not The Clown's Bottles making you see double.<br/><br/>From September 1st 11AM ET - September 8th 11AM ET, earn twice the XP from Trials and Emblems.","dwnImagePath":"","imageHeight":"","imagePath":"","isHidden":False,"startDate":"2022-09-01T15:00:00","title":"Double XP Event","type":5,"version":"6.2.0","weight":40990.0}]})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
@app.route("/api/v1/config/VER_LATEST_CLIENT_DATA", methods=["GET"])
|
||||
def config_ver_latest_client_data():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to config ver latest client data api call GET")
|
||||
return jsonify({"status": "success", "value": "6.2.0"})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
@app.route("/api/v1/inventories", methods=["GET"])
|
||||
def inventories():
|
||||
get_remote_ip()
|
||||
try:
|
||||
print("Responded to inventories api call GET")
|
||||
return jsonify({})
|
||||
except TimeoutError:
|
||||
print("Timeout error")
|
||||
return jsonify({"status": "error"})
|
||||
except Exception as e:
|
||||
graylog_logger("API ERROR: " + str(e), "error")
|
||||
|
||||
|
||||
def run():
|
||||
|
|
@ -652,23 +34,16 @@ def keep_alive():
|
|||
time.sleep(100)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
print('Received keyboard interrupt, quitting threads.')
|
||||
graylog_logger("Api shutting down do to keyboard interrupt.", "info")
|
||||
# graylog_logger("Api shutting down do to keyboard interrupt.", "info")
|
||||
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# global variables
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
config = load_config()
|
||||
use_graylog = config['graylog']['use']
|
||||
graylog_server = config['graylog']['host']
|
||||
steam_api_key = config['steam']['api_key']
|
||||
mongo_host = config['mongodb']['host']
|
||||
mongo_db = config['mongodb']['db']
|
||||
mongo_collection = config['mongodb']['collection']
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# main
|
||||
# ------------------------------------------------------- #
|
||||
setup_graylog()
|
||||
setup_graylog(use_graylog, graylog_server)
|
||||
keep_alive()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user