feat: support app key
This commit is contained in:
parent
17fda3ca36
commit
ea8eba883e
@ -8,3 +8,4 @@ DEBUG = os.getenv("DEBUG", "True").lower() == "true"
|
|||||||
DOMAIN = os.getenv("DOMAIN", "")
|
DOMAIN = os.getenv("DOMAIN", "")
|
||||||
HOST = os.getenv("HOST", "0.0.0.0")
|
HOST = os.getenv("HOST", "0.0.0.0")
|
||||||
PORT = int(os.getenv("PORT", 8888))
|
PORT = int(os.getenv("PORT", 8888))
|
||||||
|
APPKEY = os.getenv("APPKEY", "")
|
||||||
|
@ -13,6 +13,7 @@ from src.core.click_model import ClickModel
|
|||||||
from src.core.resnet_model import ResnetModel
|
from src.core.resnet_model import ResnetModel
|
||||||
from src.core.web_app import WebApp
|
from src.core.web_app import WebApp
|
||||||
from src.crack import Crack, GeetestInitError
|
from src.crack import Crack, GeetestInitError
|
||||||
|
from src.env import APPKEY
|
||||||
|
|
||||||
|
|
||||||
class ResultData(BaseModel):
|
class ResultData(BaseModel):
|
||||||
@ -90,7 +91,9 @@ class PredictPlugin(AsyncInitializingComponent):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return Result(code=1, msg=msg, data=ResultData(gt=gt, challenge=challenge))
|
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()
|
loop = asyncio.get_event_loop()
|
||||||
# 可以使用with语句来确保线程执行完成后及时被清理
|
# 可以使用with语句来确保线程执行完成后及时被清理
|
||||||
|
Loading…
Reference in New Issue
Block a user