fix: 域名格式错误
This commit is contained in:
parent
31ccea32c1
commit
b5fdc15dd9
15
main.py
15
main.py
@ -292,9 +292,6 @@ async def query_api(
|
||||
if not domain:
|
||||
raise HTTPException(status_code=400, detail="Missing 'domain' parameter")
|
||||
|
||||
# 添加域名判断
|
||||
# 域名格式正则:只允许字母、数字、连字符和点,必须有一个点,不能以点或连字符开始或结束
|
||||
domain_pattern = r'^(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.(?!-)[A-Za-z0-9-]{1,63}(?<!-)$'
|
||||
|
||||
# 检查是否包含协议
|
||||
if '://' in domain:
|
||||
@ -307,10 +304,14 @@ async def query_api(
|
||||
# 检查是否包含路径
|
||||
if '/' in domain:
|
||||
raise HTTPException(status_code=400, detail="域名不能包含路径")
|
||||
|
||||
# 检查域名格式
|
||||
if not re.match(domain_pattern, domain):
|
||||
raise HTTPException(status_code=400, detail="域名格式不正确,请使用正确的域名格式(如 example.com)")
|
||||
|
||||
|
||||
# 域名至少包含一个 .
|
||||
if '.' not in domain:
|
||||
raise HTTPException(status_code=400, detail="域名格式错误")
|
||||
|
||||
|
||||
|
||||
|
||||
# 从缓存中获取数据
|
||||
cached_data = load_from_cache(domain)
|
||||
|
@ -31,7 +31,7 @@ spec:
|
||||
runtimeClassName: "nvidia"
|
||||
containers:
|
||||
- name: icp-api
|
||||
image: leafdev.top/leaf/icp-api:v0.0.2
|
||||
image: leafdev.top/leaf/icp-api:v0.0.2-fix-1
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
|
Loading…
Reference in New Issue
Block a user