forked from Hay1tsme/artemis
allnet: add handler for LoaderStateRecorder
This commit is contained in:
parent
03f91d18c9
commit
4ea83f6025
@ -1,4 +1,4 @@
|
|||||||
from typing import Dict, List, Any, Optional, Tuple
|
from typing import Dict, List, Any, Optional, Tuple, Union
|
||||||
import logging, coloredlogs
|
import logging, coloredlogs
|
||||||
from logging.handlers import TimedRotatingFileHandler
|
from logging.handlers import TimedRotatingFileHandler
|
||||||
from twisted.web.http import Request
|
from twisted.web.http import Request
|
||||||
@ -241,6 +241,22 @@ class AllnetServlet:
|
|||||||
)
|
)
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
|
def handle_loaderstaterecorder(self, request: Request, match: Dict) -> bytes:
|
||||||
|
req_data = request.content.getvalue()
|
||||||
|
req_dict = self.kvp_to_dict([req_data.decode()])[0]
|
||||||
|
|
||||||
|
serial: Union[str, None] = req_dict.get("serial", None)
|
||||||
|
num_files_to_dl: Union[str, None] = req_dict.get("nb_ftd", None)
|
||||||
|
num_files_dld: Union[str, None] = req_dict.get("nb_dld", None)
|
||||||
|
dl_state: Union[str, None] = req_dict.get("dld_st", None)
|
||||||
|
ip = Utils.get_ip_addr(request)
|
||||||
|
|
||||||
|
if serial is None or num_files_dld is None or num_files_to_dl is None or dl_state is None:
|
||||||
|
return "NG".encode()
|
||||||
|
|
||||||
|
self.logger.info(f"LoaderStateRecorder Request from {ip} {serial}: {num_files_dld}/{num_files_to_dl} Files download (State: {dl_state})")
|
||||||
|
return "OK".encode()
|
||||||
|
|
||||||
def handle_billing_request(self, request: Request, _: Dict):
|
def handle_billing_request(self, request: Request, _: Dict):
|
||||||
req_dict = self.billing_req_to_dict(request.content.getvalue())
|
req_dict = self.billing_req_to_dict(request.content.getvalue())
|
||||||
request_ip = Utils.get_ip_addr(request)
|
request_ip = Utils.get_ip_addr(request)
|
||||||
|
7
index.py
7
index.py
@ -63,6 +63,13 @@ class HttpDispatcher(resource.Resource):
|
|||||||
action="handle_dlorder",
|
action="handle_dlorder",
|
||||||
conditions=dict(method=["POST"]),
|
conditions=dict(method=["POST"]),
|
||||||
)
|
)
|
||||||
|
self.map_post.connect(
|
||||||
|
"allnet_loaderstaterecorder",
|
||||||
|
"/sys/servlet/LoaderStateRecorder",
|
||||||
|
controller="allnet",
|
||||||
|
action="handle_loaderstaterecorder",
|
||||||
|
conditions=dict(method=["POST"]),
|
||||||
|
)
|
||||||
self.map_post.connect(
|
self.map_post.connect(
|
||||||
"allnet_billing",
|
"allnet_billing",
|
||||||
"/request",
|
"/request",
|
||||||
|
Loading…
Reference in New Issue
Block a user