Refactor constants and update HTTP client config

Added type annotations to constants in constants.py and set IS_CN default to True. Updated main.py to use 'flag' instead of 'ip_flag' from API response. Removed 'verify=False' and 'proxy=None' from httpx.AsyncClient initialization in client.py for improved security and clarity.
This commit is contained in:
ikun0014
2025-09-20 18:32:28 +08:00
parent 09f94c5f11
commit 1a6cf47882
3 changed files with 7 additions and 8 deletions

View File

@@ -2,13 +2,13 @@
from pathlib import Path
LOG_DIR = Path("logs")
IS_CN = False
CONFIG_FILE = Path("config.json")
LOG_DIR: Path = Path("logs")
IS_CN: bool = True
CONFIG_FILE: Path = Path("config.json")
STEAM_API_BASE = "https://steam.ikunshare.com/api"
STEAM_CACHE_CDN_LIST = (
STEAM_API_BASE: str = "https://steam.ikunshare.com/api"
STEAM_CACHE_CDN_LIST: list = (
[
"http://alibaba.cdn.steampipe.steamcontent.com",
"http://steampipe.steamcontent.tnkjmec.com",

View File

@@ -26,7 +26,7 @@ class OnekeyApp:
)
req.raise_for_status()
body = req.json()
constants.IS_CN = bool(body["ip_flag"])
constants.IS_CN = bool(body["flag"])
async def fetch_key(self):
trans = {

View File

@@ -8,7 +8,7 @@ class HttpClient:
"""HTTP客户端封装"""
def __init__(self):
self._client = httpx.AsyncClient(verify=False, timeout=60, proxy=None)
self._client = httpx.AsyncClient(timeout=60)
async def get(self, url: str, headers: Optional[Dict] = None) -> httpx.Response:
"""GET请求"""
@@ -23,4 +23,3 @@ class HttpClient:
async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.close()