feat:自动更换ip+流量监控
This commit is contained in:
24
services/aws_region.py
Normal file
24
services/aws_region.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""AWS 区域验证"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
|
||||
_AWS_REGION_RE = re.compile(r"^[a-z]{2}(-gov)?-[a-z]+-\d+$")
|
||||
_AWS_AZ_RE = re.compile(r"^([a-z]{2}(-gov)?-[a-z]+-\d+)[a-z]$")
|
||||
|
||||
|
||||
def normalize_aws_region(value: str | None) -> str:
|
||||
raw = (value or "").strip().lower()
|
||||
if not raw:
|
||||
return ""
|
||||
m = _AWS_AZ_RE.match(raw)
|
||||
if m:
|
||||
return m.group(1)
|
||||
return raw
|
||||
|
||||
|
||||
def is_valid_aws_region(value: str | None) -> bool:
|
||||
if not value:
|
||||
return False
|
||||
return bool(_AWS_REGION_RE.match(value.strip().lower()))
|
||||
Reference in New Issue
Block a user