mirror of
https://github.com/ikunshare/Onekey.git
synced 2026-01-12 16:25:53 +08:00
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:
@@ -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",
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user