clean up index.py

This commit is contained in:
Hay1tsme 2023-02-26 11:40:13 -05:00
parent 2b81ba206c
commit 56927c049f
2 changed files with 28 additions and 22 deletions

View File

@ -24,10 +24,10 @@ class DivaBase():
self.time_lut=parse.quote(dt.strftime("%Y-%m-%d %H:%M:%S:16.0"))
def handle_test_request(self, data: bytes) -> str:
return ""
pass
def handle_game_init_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_attend_request(self, data: bytes) -> str:
encoded = "&"
@ -296,40 +296,40 @@ class DivaBase():
return ( response )
def handle_nv_ranking_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_ps_ranking_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_ng_word_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_rmt_wp_list_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_pv_def_chr_list_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_pv_ng_mdl_list_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_cstmz_itm_ng_mdl_lst_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_banner_info_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_banner_data_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_cm_ply_info_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_pstd_h_ctrl_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_pstd_item_ng_lst_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_pre_start_request(self, data: bytes) -> str:
req = PreStartRequest(data)
@ -440,7 +440,7 @@ class DivaBase():
return ( response )
def handle_pd_unlock_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_spend_credit_request(self, data: bytes) -> str:
profile = self.data.profile.get_profile(data["pd_id"], self.version)
@ -552,7 +552,7 @@ class DivaBase():
return ( response )
def handle_stage_start_request(self, data: bytes) -> str:
return ( f'' )
pass
def handle_stage_result_request(self, data: bytes) -> str:

View File

@ -44,7 +44,6 @@ class DivaServlet():
if "THIS_STRING_SEPARATES" in str(url_header):
binary_request = req_raw.splitlines()
binary_cmd_decoded = binary_request[3].decode("utf-8")
self.logger.debug(f"Binary request {binary_request}")
req_cls = BaseBinaryRequest(binary_cmd_decoded)
@ -54,18 +53,19 @@ class DivaServlet():
gz_string = base64.b64decode(b64string) # Decompressing the base64 string
try:
url_data = zlib.decompress( gz_string ).decode("utf-8", errors="replace") # Decompressing the gzip
url_data = zlib.decompress( gz_string ) # Decompressing the gzip
except zlib.error as e:
self.logger.error(f"Failed to defalte! {e} -> {gz_string}")
return "stat=0"
return b"stat=0"
try:
req_cls = BaseRequest(url_data)
except DivaRequestParseException as e:
self.logger.error(e)
return b""
return b"stat=0"
self.logger.debug(f"Request: {req_cls.raw_dict}\nHeaders: {url_header}")
self.logger.debug(f"Request: {req_raw}\nHeaders: {url_header}")
self.logger.info(f"{req_cls.cmd} request from {req_cls.b_serial} at {req.getClientAddress().host}")
handler_str = f"handle_{req_cls.cmd}_request"
@ -74,4 +74,10 @@ class DivaServlet():
return BaseResponse(req_cls.cmd, req_cls.req_id).make().encode()
handler = getattr(self.base, handler_str)
return handler(req_cls.raw).encode(errors="ignore")
response = handler(req_cls.raw)
if response is None or response == "":
response = BaseResponse(req_cls.cmd, req_cls.req_id).make()
self.logger.debug(f"Response: {response}")
return response.encode(errors="ignore")