mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-14 12:15:21 +00:00
feat: support external proxies (#588)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import cors from "cors";
|
||||
import rateLimit from "express-rate-limit";
|
||||
import { setGlobalDispatcher, ProxyAgent } from "undici";
|
||||
|
||||
import { env, version } from "../modules/config.js";
|
||||
|
||||
@@ -208,6 +209,14 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
|
||||
randomizeCiphers();
|
||||
setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes
|
||||
|
||||
if (env.externalProxy) {
|
||||
if (env.freebindCIDR) {
|
||||
throw new Error('Freebind is not available when external proxy is enabled')
|
||||
}
|
||||
|
||||
setGlobalDispatcher(new ProxyAgent(env.externalProxy))
|
||||
}
|
||||
|
||||
app.listen(env.apiPort, env.listenAddress, () => {
|
||||
console.log(`\n` +
|
||||
`${Cyan("cobalt")} API ${Bright(`v.${version}-${gitCommit} (${gitBranch})`)}\n` +
|
||||
|
||||
@@ -48,7 +48,9 @@ const
|
||||
|
||||
processingPriority: process.platform !== 'win32'
|
||||
&& process.env.PROCESSING_PRIORITY
|
||||
&& parseInt(process.env.PROCESSING_PRIORITY)
|
||||
&& parseInt(process.env.PROCESSING_PRIORITY),
|
||||
|
||||
externalProxy: process.env.API_EXTERNAL_PROXY,
|
||||
}
|
||||
|
||||
export const
|
||||
|
||||
Reference in New Issue
Block a user