mirror of
https://gitea.tendokyu.moe/AttackVector/AVNetwork.git
synced 2026-09-25 07:38:02 +03:00
73 lines
2.6 KiB
Python
73 lines
2.6 KiB
Python
from urllib.parse import parse_qs
|
|
from base64 import b64decode
|
|
from flask import Blueprint, request # Import necessary functions
|
|
from kbinxml import KBinXML
|
|
from variables.protocols import IIDX_XML, IIDX_RESULT, EAC_XML, EAC_RESULT, Respond, EAC_PROTOCOL_1, EAC_PROTOCOL_2
|
|
from time import time
|
|
from variables.strings.preLaunch import GenericOK
|
|
from variables.strings.common import heartbeat
|
|
from variables.strings.iidx import serverValues
|
|
|
|
bp = Blueprint(
|
|
"commonNeedAuth", __name__, url_prefix="/common/needAuth"
|
|
) # Create a Blueprint for this route section
|
|
|
|
@bp.route("/CheckGameStart", methods=["POST"])
|
|
def CheckGameStart():
|
|
if request.method == "POST":
|
|
# Access post data
|
|
post_data = request.get_data().decode("UTF-8")
|
|
|
|
variables = parse_qs(post_data)
|
|
protocolVersion = variables["protocol_version"][0]
|
|
binary_data = None
|
|
protocol = None
|
|
if protocolVersion == EAC_PROTOCOL_1 or protocolVersion == EAC_PROTOCOL_2:
|
|
protocol=EAC_XML
|
|
else:
|
|
protocol=IIDX_XML
|
|
response = KBinXML(GenericOK.format(protocol=protocol).encode())
|
|
binary_data = response.to_binary()
|
|
return Respond(binary_data,variables["protocol_version"][0])
|
|
|
|
return "Invalid request method", 400
|
|
|
|
|
|
@bp.route("/Heartbeat", methods=["POST"])
|
|
def HeartbeatPulse():
|
|
if request.method == "POST":
|
|
# Access post data
|
|
post_data = request.get_data().decode("UTF-8")
|
|
|
|
variables = parse_qs(post_data)
|
|
protocolVersion = variables["protocol_version"][0]
|
|
binary_data = None
|
|
protocol = None
|
|
result = None
|
|
if protocolVersion == EAC_PROTOCOL_1 or protocolVersion == EAC_PROTOCOL_2:
|
|
protocol=EAC_XML
|
|
result=EAC_RESULT
|
|
else:
|
|
protocol=IIDX_XML
|
|
result=IIDX_RESULT
|
|
|
|
response = KBinXML(heartbeat.format(protocol=protocol,result=result,nextClock=int(round(time() * 1000) + 34526426473),timeRemain=int(time() + 1 * 10000)).encode())
|
|
binary_data = response.to_binary()
|
|
return Respond(binary_data,protocolVersion)
|
|
|
|
return "Invalid request method", 400
|
|
|
|
@bp.route("/GetServerValues", methods=["POST"])
|
|
def GetServerValues():
|
|
if request.method == "POST":
|
|
post_data = request.get_data().decode("UTF-8")
|
|
variables = parse_qs(post_data)
|
|
protocolVersion = variables["protocol_version"][0]
|
|
|
|
response = KBinXML(serverValues)
|
|
binary_data = response.to_binary()
|
|
if isinstance(binary_data, str):
|
|
binary_data = binary_data.encode("utf-8")
|
|
return Respond(binary_data,protocolVersion)
|
|
|
|
return "Invalid request method", 400 |