feature: Add an option to enable Telegram to work behind a proxy. (#6125)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
mamoyal
2025-09-30 13:50:37 +03:00
committed by GitHub
parent f3bbddc287
commit f65aebffb1
75 changed files with 627 additions and 80 deletions

View File

@@ -1,5 +1,6 @@
const { Liquid } = require("liquidjs");
const { DOWN } = require("../../src/util");
const ProxyAgent = require("proxy-agent");
class NotificationProvider {
@@ -115,6 +116,22 @@ class NotificationProvider {
throw new Error(msg);
}
/**
* Returns axios config with proxy agent if proxy env is set.
* @param {object} axiosConfig - Axios config containing params
* @returns {object} Axios config
*/
getAxiosConfigWithProxy(axiosConfig = {}) {
const proxyEnv = process.env.notification_proxy || process.env.NOTIFICATION_PROXY;
if (proxyEnv) {
const agent = new ProxyAgent(proxyEnv);
axiosConfig.httpsAgent = agent;
axiosConfig.httpAgent = agent;
axiosConfig.proxy = false;
}
return axiosConfig;
}
}
module.exports = NotificationProvider;