diff --git a/src/api/controllers/chat.ts b/src/api/controllers/chat.ts index a0435a8..2d16630 100644 --- a/src/api/controllers/chat.ts +++ b/src/api/controllers/chat.ts @@ -16,9 +16,18 @@ const MODEL_NAME = 'kimi'; const ACCESS_TOKEN_EXPIRES = 300; // 伪装headers const FAKE_HEADERS = { + 'Accept': '*/*', + 'Accept-Encoding': 'gzip, deflate, br, zstd', + 'Accept-Language': 'zh-CN,zh;q=0.9', + 'Origin': 'https://kimi.moonshot.cn', + 'Cookie': util.generateCookie(), + 'R-Timezone': 'Asia/Shanghai', 'Sec-Ch-Ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Windows"', + 'Sec-Fetch-Dest': 'empty', + 'Sec-Fetch-Mode': 'cors', + 'Sec-Fetch-Site': 'same-origin', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36' }; // 文件最大大小 diff --git a/src/index.ts b/src/index.ts index b5e960e..93ba327 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,6 @@ import "@/lib/initialize.ts"; import server from "@/lib/server.ts"; import routes from "@/api/routes/index.ts"; import logger from "@/lib/logger.ts"; -import util from "@/lib/util.ts"; const startupTime = performance.now(); diff --git a/src/lib/util.ts b/src/lib/util.ts index c15706c..3c143b2 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -47,6 +47,20 @@ const util = { return value.headers ? (value.headers["content-type"] || value.headers["Content-Type"]) : null; }, + generateCookie() { + const timestamp = util.unixTimestamp(); + const items = [ + `Hm_lvt_4532beacc312859e0aa3e4a80566b706=${timestamp - Math.round(Math.random() * 2592000)}`, + `Hm_lvt_358cae4815e85d48f7e8ab7f3680a74b=${timestamp - Math.round(Math.random() * 2592000)}`, + `_ga=GA1.1.${util.generateRandomString({ length: 10, charset: 'numeric' })}.${timestamp - Math.round(Math.random() * 2592000)}`, + `_ga_31QPQG2YYD=GS1.1.${timestamp - Math.round(Math.random() * 2592000)}.17.0.${timestamp - Math.round(Math.random() * 2592000)}.0.0.0`, + `Hm_lpvt_4532beacc312859e0aa3e4a80566b706=${timestamp - Math.round(Math.random() * 2592000)}`, + `Hm_lpvt_358cae4815e85d48f7e8ab7f3680a74b=${timestamp - Math.round(Math.random() * 2592000)}`, + `_ga_YXD8W70SZP=GS1.1.${timestamp - Math.round(Math.random() * 2592000)}.35.1.${timestamp - Math.round(Math.random() * 2592000)}.0.0.0` + ]; + return items.join('; '); + }, + mimeToExtension(value: string) { let extension = mime.getExtension(value); if(extension == "mpga")