feat: support app key

This commit is contained in:
xtaodada 2024-11-03 14:30:36 +08:00
parent 17fda3ca36
commit ea8eba883e
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 5 additions and 1 deletions

View File

@ -8,3 +8,4 @@ DEBUG = os.getenv("DEBUG", "True").lower() == "true"
DOMAIN = os.getenv("DOMAIN", "")
HOST = os.getenv("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", 8888))
APPKEY = os.getenv("APPKEY", "")

View File

@ -13,6 +13,7 @@ from src.core.click_model import ClickModel
from src.core.resnet_model import ResnetModel
from src.core.web_app import WebApp
from src.crack import Crack, GeetestInitError
from src.env import APPKEY
class ResultData(BaseModel):
@ -90,7 +91,9 @@ class PredictPlugin(AsyncInitializingComponent):
traceback.print_exc()
return Result(code=1, msg=msg, data=ResultData(gt=gt, challenge=challenge))
async def bypass_gt_challenge(self, gt: str, challenge: str) -> Result:
async def bypass_gt_challenge(self, gt: str, challenge: str, appkey: str) -> Result:
if APPKEY and appkey != APPKEY:
return self.default_result
# 使用新线程进行遍历,避免堵塞主线程
loop = asyncio.get_event_loop()
# 可以使用with语句来确保线程执行完成后及时被清理