fix: 域名格式错误
This commit is contained in:
parent
31ccea32c1
commit
b5fdc15dd9
13
main.py
13
main.py
@ -292,9 +292,6 @@ async def query_api(
|
|||||||
if not domain:
|
if not domain:
|
||||||
raise HTTPException(status_code=400, detail="Missing 'domain' parameter")
|
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:
|
if '://' in domain:
|
||||||
@ -308,9 +305,13 @@ async def query_api(
|
|||||||
if '/' in domain:
|
if '/' in domain:
|
||||||
raise HTTPException(status_code=400, detail="域名不能包含路径")
|
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)
|
cached_data = load_from_cache(domain)
|
||||||
|
@ -31,7 +31,7 @@ spec:
|
|||||||
runtimeClassName: "nvidia"
|
runtimeClassName: "nvidia"
|
||||||
containers:
|
containers:
|
||||||
- name: icp-api
|
- name: icp-api
|
||||||
image: leafdev.top/leaf/icp-api:v0.0.2
|
image: leafdev.top/leaf/icp-api:v0.0.2-fix-1
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
|
Loading…
Reference in New Issue
Block a user