1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 16:29:25 +08:00

add: add request time limit to luahook api

This commit is contained in:
0O0o0oOoO00
2025-06-14 19:12:58 +08:00
parent 8913d3294d
commit 8ecf55b508
2 changed files with 6 additions and 4 deletions

View File

@@ -50,8 +50,9 @@ class CrackApi:
class ExerciseMorePowerRate(BaseModel):
rate: float
def __init__(self, base_url):
def __init__(self, base_url, timeout=10):
self.api_url = base_url
self.timeout = timeout
def get(self, path, **kwargs):
args = []
@@ -66,7 +67,7 @@ class CrackApi:
try:
response = requests.get(url, headers={
"Connection": "close",
}) # TODO: add timeout
}, timeout=self.timeout)
except requests.exceptions.Timeout:
raise CrackerError('CrackApi request timeout')
except Exception as e:
@@ -84,7 +85,7 @@ class CrackApi:
try:
response = requests.post(url, data=data_str, headers={
"Connection": "close",
}) # TODO: add timeout
}, timeout=self.timeout)
except requests.exceptions.Timeout:
raise CrackerError('CrackApi request timeout')
except Exception as e:

View File

@@ -84,7 +84,8 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp.
l = [ops]
base_url = f"http://127.0.0.1:{device.adb.forward_port(REMOTE_PORT)}"
api = CrackApi(base_url)
timeout = deep_get(config.data, "Hook.HookGeneral.RequestTimeLimit", 10)
api = CrackApi(base_url, timeout=timeout)
for op in l:
if op == CrackOp.DisableAll:
api.disable_all()