forked from Hay1tsme/artemis
allnet: add event logging to download report
This commit is contained in:
parent
a8f06ee266
commit
ab640760a9
@ -315,6 +315,7 @@ class AllnetServlet:
|
|||||||
|
|
||||||
def handle_dlorder_report(self, request: Request, match: Dict) -> bytes:
|
def handle_dlorder_report(self, request: Request, match: Dict) -> bytes:
|
||||||
req_raw = request.content.getvalue()
|
req_raw = request.content.getvalue()
|
||||||
|
client_ip = Utils.get_ip_addr(request)
|
||||||
try:
|
try:
|
||||||
req_dict: Dict = json.loads(req_raw)
|
req_dict: Dict = json.loads(req_raw)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -332,11 +333,18 @@ class AllnetServlet:
|
|||||||
self.logger.warning(f"Failed to parse DL Report: Invalid format - contains neither appimage nor optimage")
|
self.logger.warning(f"Failed to parse DL Report: Invalid format - contains neither appimage nor optimage")
|
||||||
return "NG"
|
return "NG"
|
||||||
|
|
||||||
dl_report_data = DLReport(dl_data, dl_data_type)
|
rep = DLReport(dl_data, dl_data_type)
|
||||||
|
|
||||||
if not dl_report_data.validate():
|
if not rep.validate():
|
||||||
self.logger.warning(f"Failed to parse DL Report: Invalid format - {dl_report_data.err}")
|
self.logger.warning(f"Failed to parse DL Report: Invalid format - {rep.err}")
|
||||||
return "NG"
|
return "NG"
|
||||||
|
|
||||||
|
msg = f"{rep.serial} @ {client_ip} reported download state {rep.rf_state} for {rep.gd} v{rep.dav}"\
|
||||||
|
f" ordered at {datetime.utcfromtimestamp(rep.ot).isoformat()} UTC:"\
|
||||||
|
f" {rep.tdsc}/{rep.tsc} segemnts downloaded for working files {rep.wfl} with {rep.dfl} complete."
|
||||||
|
|
||||||
|
self.data.base.log_event("allnet", "DL_ORDER", logging.INFO, msg, dl_data)
|
||||||
|
self.logger.info(msg)
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
@ -753,14 +761,6 @@ class DLReport:
|
|||||||
self.err = "serial not provided"
|
self.err = "serial not provided"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.dfl is None:
|
|
||||||
self.err = "dfl not provided"
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.wfl is None:
|
|
||||||
self.err = "wfl not provided"
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.tsc is None:
|
if self.tsc is None:
|
||||||
self.err = "tsc not provided"
|
self.err = "tsc not provided"
|
||||||
return False
|
return False
|
||||||
@ -769,18 +769,6 @@ class DLReport:
|
|||||||
self.err = "tdsc not provided"
|
self.err = "tdsc not provided"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.at is None:
|
|
||||||
self.err = "at not provided"
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.ot is None:
|
|
||||||
self.err = "ot not provided"
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.rt is None:
|
|
||||||
self.err = "rt not provided"
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.as_ is None:
|
if self.as_ is None:
|
||||||
self.err = "as not provided"
|
self.err = "as not provided"
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user