feat(proxy): allow socks proxy for the notifications#7088
feat(proxy): allow socks proxy for the notifications#7088CommanderStorm merged 1 commit intolouislam:masterfrom
Conversation
|
Hello and thanks for lending a paw to Uptime Kuma! 🐻👋 |
There was a problem hiding this comment.
Pull request overview
Adds SOCKS proxy support for notification HTTP requests by extending the existing NOTIFICATION_PROXY / notification_proxy env-based proxy handling in the backend notification provider.
Changes:
- Import
SocksProxyAgentfor SOCKS proxy support. - Extend
getAxiosConfigWithProxy()to detect SOCKS protocols (socks/socks4/socks5/socks5h) and apply the appropriate agent.
| } else if (["socks:", "socks4:", "socks5:", "socks5h:"].includes(proxyUrl.protocol)) { | ||
| const agent = new SocksProxyAgent(proxyEnv); | ||
| axiosConfig.httpAgent = agent; | ||
| axiosConfig.httpsAgent = agent; |
There was a problem hiding this comment.
The list of supported SOCKS protocols is hard-coded here, while similar protocol support is also maintained in server/proxy.js (Proxy.SUPPORTED_PROXY_PROTOCOLS). This duplication can drift over time (e.g., if supported proxy protocols are expanded/renamed in one place but not the other). Consider centralizing the supported-protocol mapping (or deriving the ...: URL protocol list from the shared constant) so notification proxy handling stays consistent with the rest of the proxy implementation.
| } else if (["socks:", "socks4:", "socks5:", "socks5h:"].includes(proxyUrl.protocol)) { | ||
| const agent = new SocksProxyAgent(proxyEnv); | ||
| axiosConfig.httpAgent = agent; | ||
| axiosConfig.httpsAgent = agent; |
There was a problem hiding this comment.
SOCKS proxy support is newly added here, but there are no backend tests asserting that getAxiosConfigWithProxy() configures the correct agent for socks/socks4/socks5/socks5h URLs (and that existing http/https behavior is unchanged). Adding a small unit test that sets process.env.NOTIFICATION_PROXY to a SOCKS URL and verifies axiosConfig.httpAgent/httpsAgent are instances of the expected agent would help prevent regressions.
|
@ASLanin congrats on your first contribution to Uptime Kuma! 🐻 |
Summary
In this pull request, the following changes are made:
Parsing
NOTIFICATION_PROXYandnotification_proxyenv for known socks protocols and set appropriate agent.in two words:
Simple
else ifadded to the notification_proxy variable checking.To be honest I tested on the socks5 only, relying on
socks-proxy-agentpackage that way.Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
Screenshots for Visual Changes
no changes