现在官方会对ip地址进行限速,所以增加代理服务器功能

This commit is contained in:
1e0n
2025-10-24 12:34:21 +08:00
parent c60a12064c
commit 7d037a6e9a
9 changed files with 188 additions and 13 deletions

12
auth.js
View File

@@ -3,6 +3,7 @@ import path from 'path';
import os from 'os';
import fetch from 'node-fetch';
import { logDebug, logError, logInfo } from './logger.js';
import { getNextProxyAgent } from './proxy-manager.js';
// State management for API key and refresh
let currentApiKey = null;
@@ -134,13 +135,20 @@ async function refreshApiKey() {
formData.append('refresh_token', currentRefreshToken);
formData.append('client_id', clientId);
const response = await fetch(REFRESH_URL, {
const proxyAgentInfo = getNextProxyAgent(REFRESH_URL);
const fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: formData.toString()
});
};
if (proxyAgentInfo?.agent) {
fetchOptions.agent = proxyAgentInfo.agent;
}
const response = await fetch(REFRESH_URL, fetchOptions);
if (!response.ok) {
const errorText = await response.text();