From f65aebffb134701c1b7c12963c95ced991be24a7 Mon Sep 17 00:00:00 2001 From: mamoyal <97595015+MatanAmoyal1@users.noreply.github.com> Date: Tue, 30 Sep 2025 13:50:37 +0300 Subject: [PATCH] feature: Add an option to enable Telegram to work behind a proxy. (#6125) Co-authored-by: Frank Elsinga --- package-lock.json | 469 +++++++++++++++++- package.json | 1 + server/notification-providers/46elks.js | 4 +- server/notification-providers/alerta.js | 2 + server/notification-providers/alertnow.js | 4 +- server/notification-providers/aliyun-sms.js | 2 + server/notification-providers/bark.js | 5 +- server/notification-providers/bitrix24.js | 3 +- server/notification-providers/brevo.js | 1 + server/notification-providers/call-me-bot.js | 3 +- server/notification-providers/cellsynt.js | 3 +- server/notification-providers/clicksendsms.js | 1 + server/notification-providers/dingding.js | 1 + server/notification-providers/discord.js | 9 +- server/notification-providers/evolution.js | 3 +- server/notification-providers/feishu.js | 7 +- server/notification-providers/freemobile.js | 3 +- server/notification-providers/goalert.js | 1 + server/notification-providers/google-chat.js | 5 +- server/notification-providers/gorush.js | 3 +- server/notification-providers/gotify.js | 3 +- .../notification-providers/grafana-oncall.js | 7 +- .../notification-providers/gtx-messaging.js | 3 +- server/notification-providers/heii-oncall.js | 3 +- .../notification-providers/home-assistant.js | 16 +- server/notification-providers/keep.js | 2 + server/notification-providers/kook.js | 1 + server/notification-providers/line.js | 1 + server/notification-providers/linenotify.js | 1 + server/notification-providers/lunasea.js | 7 +- server/notification-providers/matrix.js | 1 + server/notification-providers/mattermost.js | 5 +- server/notification-providers/notifery.js | 3 +- .../notification-provider.js | 17 + server/notification-providers/ntfy.js | 6 +- server/notification-providers/octopush.js | 2 + server/notification-providers/onebot.js | 1 + server/notification-providers/onechat.js | 3 +- server/notification-providers/onesender.js | 1 + server/notification-providers/opsgenie.js | 1 + server/notification-providers/promosms.js | 1 + server/notification-providers/pumble.js | 5 +- server/notification-providers/pushbullet.js | 1 + server/notification-providers/pushdeer.js | 3 +- server/notification-providers/pushover.js | 5 +- server/notification-providers/pushplus.js | 3 +- server/notification-providers/pushy.js | 3 +- server/notification-providers/rocket-chat.js | 5 +- server/notification-providers/send-grid.js | 2 +- server/notification-providers/serverchan.js | 3 +- server/notification-providers/serwersms.js | 1 + server/notification-providers/sevenio.js | 3 +- server/notification-providers/signal.js | 2 +- server/notification-providers/signl4.js | 3 +- server/notification-providers/slack.js | 5 +- server/notification-providers/sms-planet.js | 1 + server/notification-providers/smsc.js | 1 + server/notification-providers/smseagle.js | 2 + server/notification-providers/smsmanager.js | 3 +- server/notification-providers/smspartner.js | 1 + server/notification-providers/spugpush.js | 3 +- server/notification-providers/squadcast.js | 1 + server/notification-providers/stackfield.js | 3 +- server/notification-providers/teams.js | 3 +- .../notification-providers/techulus-push.js | 3 +- server/notification-providers/telegram.js | 6 +- server/notification-providers/threema.js | 3 +- server/notification-providers/twilio.js | 1 + server/notification-providers/waha.js | 3 +- server/notification-providers/webhook.js | 1 + server/notification-providers/wecom.js | 1 + server/notification-providers/whapi.js | 3 +- server/notification-providers/wpush.js | 3 +- server/notification-providers/yzj.js | 3 +- server/notification-providers/zoho-cliq.js | 3 +- 75 files changed, 627 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50221dced..229151874 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,6 +73,7 @@ "prometheus-api-metrics": "~3.2.1", "promisify-child-process": "~4.1.2", "protobufjs": "~7.2.4", + "proxy-agent": "^5.0.0", "qs": "~6.10.4", "redbean-node": "~0.3.0", "redis": "~4.5.1", @@ -4346,7 +4347,6 @@ "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "license": "MIT", - "optional": true, "engines": { "node": ">= 6" } @@ -5294,7 +5294,6 @@ "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", - "dev": true, "license": "MIT", "bin": { "acorn": "bin/acorn" @@ -5313,6 +5312,18 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/aedes": { "version": "0.46.3", "resolved": "https://registry.npmjs.org/aedes/-/aedes-0.46.3.tgz", @@ -5778,6 +5789,18 @@ "integrity": "sha512-CbNem/7hxrjSiOAOOTX4iZxu+0m3jiLqlsERQwwPM1IDR/22M8IPpA1VVndCLw5KtjRYyRODbvAEIfuTogNDng==", "license": "MIT" }, + "node_modules/ast-types": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", + "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", @@ -7454,6 +7477,15 @@ "dev": true, "license": "MIT" }, + "node_modules/data-uri-to-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", + "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, "node_modules/data-view-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", @@ -7629,7 +7661,6 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true, "license": "MIT" }, "node_modules/default-browser": { @@ -7715,6 +7746,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/degenerator": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.4.tgz", + "integrity": "sha512-Z66uPeBfHZAHVmue3HPfyKu2Q0rC2cRxbTOsvmU/po5fvvcx27W4mIu9n0PUlQih4oUYvcG1BsbtVv8x7KDOSw==", + "license": "MIT", + "dependencies": { + "ast-types": "^0.13.2", + "escodegen": "^1.8.1", + "esprima": "^4.0.0", + "vm2": "^3.9.17" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/delay": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", @@ -8521,6 +8567,97 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/escodegen": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "license": "BSD-2-Clause", + "dependencies": { + "esprima": "^4.0.1", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=4.0" + }, + "optionalDependencies": { + "source-map": "~0.6.1" + } + }, + "node_modules/escodegen/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/escodegen/node_modules/levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", + "license": "MIT", + "dependencies": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/escodegen/node_modules/optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "license": "MIT", + "dependencies": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/escodegen/node_modules/prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/escodegen/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "license": "BSD-3-Clause", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/escodegen/node_modules/type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", + "license": "MIT", + "dependencies": { + "prelude-ls": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/eslint": { "version": "8.14.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.14.0.tgz", @@ -8730,6 +8867,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/esquery": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", @@ -8777,7 +8927,6 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.10.0" @@ -9049,7 +9198,6 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true, "license": "MIT" }, "node_modules/fast-uri": { @@ -9187,6 +9335,15 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-uri-to-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", + "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -9492,6 +9649,42 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/ftp": { + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", + "integrity": "sha512-faFVML1aBx2UoDStmLwv2Wptt4vw5x03xxX172nhA5Y5HBshW5JweqQ2W4xL4dezQTG8inJsuYcpPHHU3X5OTQ==", + "dependencies": { + "readable-stream": "1.1.x", + "xregexp": "2.0.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/ftp/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "license": "MIT" + }, + "node_modules/ftp/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/ftp/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "license": "MIT" + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -9876,6 +10069,55 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-uri": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", + "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", + "license": "MIT", + "dependencies": { + "@tootallnate/once": "1", + "data-uri-to-buffer": "3", + "debug": "4", + "file-uri-to-path": "2", + "fs-extra": "^8.1.0", + "ftp": "^0.3.10" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/get-uri/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/get-uri/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "license": "MIT", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/get-uri/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/getopts": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz", @@ -10083,7 +10325,6 @@ "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "devOptional": true, "license": "ISC" }, "node_modules/graphemer": { @@ -10552,6 +10793,12 @@ "node": ">= 0.10" } }, + "node_modules/ip": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.9.tgz", + "integrity": "sha512-cyRxvOEpNHNtchU3Ln9KC/auJgup87llfQpQ+t5ghoC/UhL16SWzbueiCsdTnWmqAWl7LadfuwhlqmtOaqMHdQ==", + "license": "MIT" + }, "node_modules/ip-address": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.0.1.tgz", @@ -12560,6 +12807,15 @@ "smart-buffer": "^4.1.0" } }, + "node_modules/netmask": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", + "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/node-addon-api": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", @@ -13138,6 +13394,93 @@ "node": ">=6" } }, + "node_modules/pac-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", + "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", + "license": "MIT", + "dependencies": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4", + "get-uri": "3", + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "5", + "pac-resolver": "^5.0.0", + "raw-body": "^2.2.0", + "socks-proxy-agent": "5" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/pac-proxy-agent/node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/pac-proxy-agent/node_modules/http-proxy-agent": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", + "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "license": "MIT", + "dependencies": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pac-proxy-agent/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pac-proxy-agent/node_modules/socks-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", + "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", + "license": "MIT", + "dependencies": { + "agent-base": "^6.0.2", + "debug": "4", + "socks": "^2.3.3" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pac-resolver": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.1.tgz", + "integrity": "sha512-cy7u00ko2KVgBAjuhevqpPeHIkCIqPe1v24cydhWjmeuzaBfmUWFCZJ1iAh5TuVzVZoUzXIW7K8sMYOZ84uZ9Q==", + "license": "MIT", + "dependencies": { + "degenerator": "^3.0.2", + "ip": "^1.1.5", + "netmask": "^2.0.2" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", @@ -13909,6 +14252,93 @@ "node": ">= 0.10" } }, + "node_modules/proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", + "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", + "license": "MIT", + "dependencies": { + "agent-base": "^6.0.0", + "debug": "4", + "http-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", + "lru-cache": "^5.1.1", + "pac-proxy-agent": "^5.0.0", + "proxy-from-env": "^1.0.0", + "socks-proxy-agent": "^5.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/proxy-agent/node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/proxy-agent/node_modules/http-proxy-agent": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", + "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "license": "MIT", + "dependencies": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/proxy-agent/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/proxy-agent/node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/proxy-agent/node_modules/socks-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", + "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", + "license": "MIT", + "dependencies": { + "agent-base": "^6.0.2", + "debug": "4", + "socks": "^2.3.3" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/proxy-agent/node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "license": "ISC" + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", @@ -17305,6 +17735,23 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/vm2": { + "version": "3.9.19", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.19.tgz", + "integrity": "sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==", + "deprecated": "The library contains critical security issues and should not be used for production! The maintenance of the project has been discontinued. Consider migrating your code to isolated-vm.", + "license": "MIT", + "dependencies": { + "acorn": "^8.7.0", + "acorn-walk": "^8.2.0" + }, + "bin": { + "vm2": "bin/vm2" + }, + "engines": { + "node": ">=6.0" + } + }, "node_modules/vue": { "version": "3.4.38", "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.38.tgz", @@ -17749,7 +18196,6 @@ "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -17923,6 +18369,15 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "license": "ISC" }, + "node_modules/xregexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", + "integrity": "sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index cc276933b..987537428 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,7 @@ "prometheus-api-metrics": "~3.2.1", "promisify-child-process": "~4.1.2", "protobufjs": "~7.2.4", + "proxy-agent": "^5.0.0", "qs": "~6.10.4", "redbean-node": "~0.3.0", "redis": "~4.5.1", diff --git a/server/notification-providers/46elks.js b/server/notification-providers/46elks.js index 4b15e9fad..6f4a94793 100644 --- a/server/notification-providers/46elks.js +++ b/server/notification-providers/46elks.js @@ -17,12 +17,14 @@ class Elks extends NotificationProvider { data.append("to", notification.elksToNumber ); data.append("message", msg); - const config = { + let config = { headers: { "Authorization": "Basic " + Buffer.from(`${notification.elksUsername}:${notification.elksAuthToken}`).toString("base64") } }; + config = this.getAxiosConfigWithProxy(config); + await axios.post(url, data, config); return okMsg; diff --git a/server/notification-providers/alerta.js b/server/notification-providers/alerta.js index f9a273b49..37e223d86 100644 --- a/server/notification-providers/alerta.js +++ b/server/notification-providers/alerta.js @@ -30,6 +30,8 @@ class Alerta extends NotificationProvider { type: "exceptionAlert", }; + config = this.getAxiosConfigWithProxy(config); + if (heartbeatJSON == null) { let postData = Object.assign({ event: "msg", diff --git a/server/notification-providers/alertnow.js b/server/notification-providers/alertnow.js index 4257ca9cd..90efa274f 100644 --- a/server/notification-providers/alertnow.js +++ b/server/notification-providers/alertnow.js @@ -41,7 +41,9 @@ class AlertNow extends NotificationProvider { "event_id": eventId, }; - await axios.post(notification.alertNowWebhookURL, data); + let config = this.getAxiosConfigWithProxy({}); + + await axios.post(notification.alertNowWebhookURL, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index e18602bdc..59560599f 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -72,6 +72,8 @@ class AliyunSMS extends NotificationProvider { data: qs.stringify(params), }; + config = this.getAxiosConfigWithProxy(config); + let result = await axios(config); if (result.data.Message === "OK") { return true; diff --git a/server/notification-providers/bark.js b/server/notification-providers/bark.js index 0907d5f10..a47df52fc 100644 --- a/server/notification-providers/bark.js +++ b/server/notification-providers/bark.js @@ -96,12 +96,13 @@ class Bark extends NotificationProvider { */ async postNotification(notification, title, subtitle, endpoint) { let result; + let config = this.getAxiosConfigWithProxy({}); if (notification.apiVersion === "v1" || notification.apiVersion == null) { // url encode title and subtitle title = encodeURIComponent(title); subtitle = encodeURIComponent(subtitle); const params = this.additionalParameters(notification); - result = await axios.get(`${endpoint}/${title}/${subtitle}${params}`); + result = await axios.get(`${endpoint}/${title}/${subtitle}${params}`, config); } else { result = await axios.post(`${endpoint}/push`, { title, @@ -109,7 +110,7 @@ class Bark extends NotificationProvider { icon: barkNotificationAvatar, sound: notification.barkSound || "telegraph", // default sound is telegraph group: notification.barkGroup || "UptimeKuma", // default group is UptimeKuma - }); + }, config); } this.checkResult(result); if (result.statusText != null) { diff --git a/server/notification-providers/bitrix24.js b/server/notification-providers/bitrix24.js index ba12126c5..1228e08d8 100644 --- a/server/notification-providers/bitrix24.js +++ b/server/notification-providers/bitrix24.js @@ -19,7 +19,8 @@ class Bitrix24 extends NotificationProvider { "ATTACH[BLOCKS][0][MESSAGE]": msg }; - await axios.get(`${notification.bitrix24WebhookURL}/im.notify.system.add.json`, { params }); + let config = this.getAxiosConfigWithProxy({ params }); + await axios.get(`${notification.bitrix24WebhookURL}/im.notify.system.add.json`, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/brevo.js b/server/notification-providers/brevo.js index b896f81c3..dd5097635 100644 --- a/server/notification-providers/brevo.js +++ b/server/notification-providers/brevo.js @@ -18,6 +18,7 @@ class Brevo extends NotificationProvider { "api-key": notification.brevoApiKey, }, }; + config = this.getAxiosConfigWithProxy(config); let to = [{ email: notification.brevoToEmail }]; diff --git a/server/notification-providers/call-me-bot.js b/server/notification-providers/call-me-bot.js index daa9ccdeb..c0541ae6f 100644 --- a/server/notification-providers/call-me-bot.js +++ b/server/notification-providers/call-me-bot.js @@ -12,7 +12,8 @@ class CallMeBot extends NotificationProvider { try { const url = new URL(notification.callMeBotEndpoint); url.searchParams.set("text", msg); - await axios.get(url.toString()); + let config = this.getAxiosConfigWithProxy({}); + await axios.get(url.toString(), config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/cellsynt.js b/server/notification-providers/cellsynt.js index e842237b6..a3546a3c2 100644 --- a/server/notification-providers/cellsynt.js +++ b/server/notification-providers/cellsynt.js @@ -22,7 +22,8 @@ class Cellsynt extends NotificationProvider { } }; try { - const resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, data); + let config = this.getAxiosConfigWithProxy(data); + const resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, config); if (resp.data == null ) { throw new Error("Could not connect to Cellsynt, please try again."); } else if (resp.data.includes("Error:")) { diff --git a/server/notification-providers/clicksendsms.js b/server/notification-providers/clicksendsms.js index c090b7f36..bb1f1762e 100644 --- a/server/notification-providers/clicksendsms.js +++ b/server/notification-providers/clicksendsms.js @@ -29,6 +29,7 @@ class ClickSendSMS extends NotificationProvider { } ] }; + config = this.getAxiosConfigWithProxy(config); let resp = await axios.post(url, data, config); if (resp.data.data.messages[0].status !== "SUCCESS") { let error = "Something gone wrong. Api returned " + resp.data.data.messages[0].status + "."; diff --git a/server/notification-providers/dingding.js b/server/notification-providers/dingding.js index c66f270a7..be861e990 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -60,6 +60,7 @@ class DingDing extends NotificationProvider { url: `${notification.webHookUrl}×tamp=${timestamp}&sign=${encodeURIComponent(this.sign(timestamp, notification.secretKey))}`, data: JSON.stringify(params), }; + config = this.getAxiosConfigWithProxy(config); let result = await axios(config); if (result.data.errmsg === "ok") { diff --git a/server/notification-providers/discord.js b/server/notification-providers/discord.js index 446784bb4..98e97b85f 100644 --- a/server/notification-providers/discord.js +++ b/server/notification-providers/discord.js @@ -12,6 +12,7 @@ class Discord extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); const discordDisplayName = notification.discordUsername || "Uptime Kuma"; const webhookUrl = new URL(notification.discordWebhookUrl); if (notification.discordChannelType === "postToThread") { @@ -21,7 +22,7 @@ class Discord extends NotificationProvider { // Check if the webhook has an avatar let webhookHasAvatar = true; try { - const webhookInfo = await axios.get(webhookUrl.toString()); + const webhookInfo = await axios.get(webhookUrl.toString(), config); webhookHasAvatar = !!webhookInfo.data.avatar; } catch (e) { // If we can't verify, we assume he has an avatar to avoid forcing the default avatar @@ -40,7 +41,7 @@ class Discord extends NotificationProvider { if (notification.discordChannelType === "createNewForumPost") { discordtestdata.thread_name = notification.postName; } - await axios.post(webhookUrl.toString(), discordtestdata); + await axios.post(webhookUrl.toString(), discordtestdata, config); return okMsg; } @@ -82,7 +83,7 @@ class Discord extends NotificationProvider { discorddowndata.content = notification.discordPrefixMessage; } - await axios.post(webhookUrl.toString(), discorddowndata); + await axios.post(webhookUrl.toString(), discorddowndata, config); return okMsg; } else if (heartbeatJSON["status"] === UP) { @@ -124,7 +125,7 @@ class Discord extends NotificationProvider { discordupdata.content = notification.discordPrefixMessage; } - await axios.post(webhookUrl.toString(), discordupdata); + await axios.post(webhookUrl.toString(), discordupdata, config); return okMsg; } } catch (error) { diff --git a/server/notification-providers/evolution.js b/server/notification-providers/evolution.js index 72ccf57c0..50ede9685 100644 --- a/server/notification-providers/evolution.js +++ b/server/notification-providers/evolution.js @@ -11,13 +11,14 @@ class Evolution extends NotificationProvider { const okMsg = "Sent Successfully."; try { - const config = { + let config = { headers: { "Accept": "application/json", "Content-Type": "application/json", "apikey": notification.evolutionAuthToken, } }; + config = this.getAxiosConfigWithProxy(config); let data = { "number": notification.evolutionRecipient, diff --git a/server/notification-providers/feishu.js b/server/notification-providers/feishu.js index cd5331d2a..81569ecd3 100644 --- a/server/notification-providers/feishu.js +++ b/server/notification-providers/feishu.js @@ -12,6 +12,7 @@ class Feishu extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); if (heartbeatJSON == null) { let testdata = { msg_type: "text", @@ -19,7 +20,7 @@ class Feishu extends NotificationProvider { text: msg, }, }; - await axios.post(notification.feishuWebHookUrl, testdata); + await axios.post(notification.feishuWebHookUrl, testdata, config); return okMsg; } @@ -49,7 +50,7 @@ class Feishu extends NotificationProvider { ] } }; - await axios.post(notification.feishuWebHookUrl, downdata); + await axios.post(notification.feishuWebHookUrl, downdata, config); return okMsg; } @@ -79,7 +80,7 @@ class Feishu extends NotificationProvider { ] } }; - await axios.post(notification.feishuWebHookUrl, updata); + await axios.post(notification.feishuWebHookUrl, updata, config); return okMsg; } } catch (error) { diff --git a/server/notification-providers/freemobile.js b/server/notification-providers/freemobile.js index 4de45acdd..7ec10e90f 100644 --- a/server/notification-providers/freemobile.js +++ b/server/notification-providers/freemobile.js @@ -11,10 +11,11 @@ class FreeMobile extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); await axios.post(`https://smsapi.free-mobile.fr/sendmsg?msg=${encodeURIComponent(msg.replace("🔴", "⛔️"))}`, { "user": notification.freemobileUser, "pass": notification.freemobilePass, - }); + }, config); return okMsg; diff --git a/server/notification-providers/goalert.js b/server/notification-providers/goalert.js index 847c6a003..f3e33b902 100644 --- a/server/notification-providers/goalert.js +++ b/server/notification-providers/goalert.js @@ -24,6 +24,7 @@ class GoAlert extends NotificationProvider { let config = { headers: headers }; + config = this.getAxiosConfigWithProxy(config); await axios.post(`${notification.goAlertBaseURL}/api/v2/generic/incoming?token=${notification.goAlertToken}`, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/google-chat.js b/server/notification-providers/google-chat.js index 93bee604f..1e2eb3507 100644 --- a/server/notification-providers/google-chat.js +++ b/server/notification-providers/google-chat.js @@ -13,6 +13,7 @@ class GoogleChat extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); // Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic if (notification.googleChatUseTemplate && notification.googleChatTemplate) { // Send message using template @@ -23,7 +24,7 @@ class GoogleChat extends NotificationProvider { heartbeatJSON ); const data = { "text": renderedText }; - await axios.post(notification.googleChatWebhookURL, data); + await axios.post(notification.googleChatWebhookURL, data, config); return okMsg; } @@ -95,7 +96,7 @@ class GoogleChat extends NotificationProvider { ], }; - await axios.post(notification.googleChatWebhookURL, data); + await axios.post(notification.googleChatWebhookURL, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/gorush.js b/server/notification-providers/gorush.js index ba9d470f7..6da702360 100644 --- a/server/notification-providers/gorush.js +++ b/server/notification-providers/gorush.js @@ -31,8 +31,7 @@ class Gorush extends NotificationProvider { } ] }; - let config = {}; - + let config = this.getAxiosConfigWithProxy({}); await axios.post(`${notification.gorushServerURL}/api/push`, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/gotify.js b/server/notification-providers/gotify.js index a52ef511a..ec8773adf 100644 --- a/server/notification-providers/gotify.js +++ b/server/notification-providers/gotify.js @@ -11,6 +11,7 @@ class Gotify extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); if (notification.gotifyserverurl && notification.gotifyserverurl.endsWith("/")) { notification.gotifyserverurl = notification.gotifyserverurl.slice(0, -1); } @@ -18,7 +19,7 @@ class Gotify extends NotificationProvider { "message": msg, "priority": notification.gotifyPriority || 8, "title": "Uptime-Kuma", - }); + }, config); return okMsg; diff --git a/server/notification-providers/grafana-oncall.js b/server/notification-providers/grafana-oncall.js index e93c77cd9..a28468861 100644 --- a/server/notification-providers/grafana-oncall.js +++ b/server/notification-providers/grafana-oncall.js @@ -16,13 +16,14 @@ class GrafanaOncall extends NotificationProvider { } try { + let config = this.getAxiosConfigWithProxy({}); if (heartbeatJSON === null) { let grafanaupdata = { title: "General notification", message: msg, state: "alerting", }; - await axios.post(notification.GrafanaOncallURL, grafanaupdata); + await axios.post(notification.GrafanaOncallURL, grafanaupdata, config); return okMsg; } else if (heartbeatJSON["status"] === DOWN) { let grafanadowndata = { @@ -30,7 +31,7 @@ class GrafanaOncall extends NotificationProvider { message: heartbeatJSON["msg"], state: "alerting", }; - await axios.post(notification.GrafanaOncallURL, grafanadowndata); + await axios.post(notification.GrafanaOncallURL, grafanadowndata, config); return okMsg; } else if (heartbeatJSON["status"] === UP) { let grafanaupdata = { @@ -38,7 +39,7 @@ class GrafanaOncall extends NotificationProvider { message: heartbeatJSON["msg"], state: "ok", }; - await axios.post(notification.GrafanaOncallURL, grafanaupdata); + await axios.post(notification.GrafanaOncallURL, grafanaupdata, config); return okMsg; } } catch (error) { diff --git a/server/notification-providers/gtx-messaging.js b/server/notification-providers/gtx-messaging.js index 1ff97d11f..f8715c1fc 100644 --- a/server/notification-providers/gtx-messaging.js +++ b/server/notification-providers/gtx-messaging.js @@ -14,6 +14,7 @@ class GtxMessaging extends NotificationProvider { const text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", ""); try { + let config = this.getAxiosConfigWithProxy({}); const data = new URLSearchParams(); data.append("from", notification.gtxMessagingFrom.trim()); data.append("to", notification.gtxMessagingTo.trim()); @@ -21,7 +22,7 @@ class GtxMessaging extends NotificationProvider { const url = `https://rest.gtx-messaging.net/smsc/sendsms/${notification.gtxMessagingApiKey}/json`; - await axios.post(url, data); + await axios.post(url, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/heii-oncall.js b/server/notification-providers/heii-oncall.js index 20b53e6af..1e66f0d72 100644 --- a/server/notification-providers/heii-oncall.js +++ b/server/notification-providers/heii-oncall.js @@ -18,7 +18,7 @@ class HeiiOnCall extends NotificationProvider { payload["url"] = baseURL + getMonitorRelativeURL(monitorJSON.id); } - const config = { + let config = { headers: { Accept: "application/json", "Content-Type": "application/json", @@ -28,6 +28,7 @@ class HeiiOnCall extends NotificationProvider { const heiiUrl = `https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/`; // docs https://heiioncall.com/docs#manual-triggers try { + config = this.getAxiosConfigWithProxy(config); if (!heartbeatJSON) { // Testing or general notification like certificate expiry payload["msg"] = msg; diff --git a/server/notification-providers/home-assistant.js b/server/notification-providers/home-assistant.js index 4536b2a43..770980ae3 100644 --- a/server/notification-providers/home-assistant.js +++ b/server/notification-providers/home-assistant.js @@ -15,6 +15,13 @@ class HomeAssistant extends NotificationProvider { const notificationService = notification?.notificationService || defaultNotificationService; try { + let config = { + headers: { + Authorization: `Bearer ${notification.longLivedAccessToken}`, + "Content-Type": "application/json", + }, + }; + config = this.getAxiosConfigWithProxy(config); await axios.post( `${notification.homeAssistantUrl.trim().replace(/\/*$/, "")}/api/services/notify/${notificationService}`, { @@ -26,14 +33,7 @@ class HomeAssistant extends NotificationProvider { channel: "Uptime Kuma", icon_url: "https://github.com/louislam/uptime-kuma/blob/master/public/icon.png?raw=true", } }), - }, - { - headers: { - Authorization: `Bearer ${notification.longLivedAccessToken}`, - "Content-Type": "application/json", - }, - } - ); + }, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/keep.js b/server/notification-providers/keep.js index aa65a867b..69740a210 100644 --- a/server/notification-providers/keep.js +++ b/server/notification-providers/keep.js @@ -31,6 +31,8 @@ class Keep extends NotificationProvider { let webhookURL = url + "/alerts/event/uptimekuma"; + config = this.getAxiosConfigWithProxy(config); + await axios.post(webhookURL, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/kook.js b/server/notification-providers/kook.js index dab19513a..244dbd6c1 100644 --- a/server/notification-providers/kook.js +++ b/server/notification-providers/kook.js @@ -22,6 +22,7 @@ class Kook extends NotificationProvider { }, }; try { + config = this.getAxiosConfigWithProxy(config); await axios.post(url, data, config); return okMsg; diff --git a/server/notification-providers/line.js b/server/notification-providers/line.js index 57dc87e78..8a637a7c4 100644 --- a/server/notification-providers/line.js +++ b/server/notification-providers/line.js @@ -19,6 +19,7 @@ class Line extends NotificationProvider { "Authorization": "Bearer " + notification.lineChannelAccessToken } }; + config = this.getAxiosConfigWithProxy(config); if (heartbeatJSON == null) { let testMessage = { "to": notification.lineUserID, diff --git a/server/notification-providers/linenotify.js b/server/notification-providers/linenotify.js index 2622e3f1c..30b2e800d 100644 --- a/server/notification-providers/linenotify.js +++ b/server/notification-providers/linenotify.js @@ -20,6 +20,7 @@ class LineNotify extends NotificationProvider { "Authorization": "Bearer " + notification.lineNotifyAccessToken } }; + config = this.getAxiosConfigWithProxy(config); if (heartbeatJSON == null) { let testMessage = { "message": msg, diff --git a/server/notification-providers/lunasea.js b/server/notification-providers/lunasea.js index 787a704a9..2e68972f2 100644 --- a/server/notification-providers/lunasea.js +++ b/server/notification-providers/lunasea.js @@ -13,13 +13,14 @@ class LunaSea extends NotificationProvider { const url = "https://notify.lunasea.app/v1"; try { + let config = this.getAxiosConfigWithProxy({}); const target = this.getTarget(notification); if (heartbeatJSON == null) { let testdata = { "title": "Uptime Kuma Alert", "body": msg, }; - await axios.post(`${url}/custom/${target}`, testdata); + await axios.post(`${url}/custom/${target}`, testdata, config); return okMsg; } @@ -30,7 +31,7 @@ class LunaSea extends NotificationProvider { heartbeatJSON["msg"] + `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}` }; - await axios.post(`${url}/custom/${target}`, downdata); + await axios.post(`${url}/custom/${target}`, downdata, config); return okMsg; } @@ -41,7 +42,7 @@ class LunaSea extends NotificationProvider { heartbeatJSON["msg"] + `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}` }; - await axios.post(`${url}/custom/${target}`, updata); + await axios.post(`${url}/custom/${target}`, updata, config); return okMsg; } diff --git a/server/notification-providers/matrix.js b/server/notification-providers/matrix.js index 805a49470..1a849a08f 100644 --- a/server/notification-providers/matrix.js +++ b/server/notification-providers/matrix.js @@ -37,6 +37,7 @@ class Matrix extends NotificationProvider { "body": msg }; + config = this.getAxiosConfigWithProxy(config); await axios.put(`${notification.homeserverUrl}/_matrix/client/r0/rooms/${roomId}/send/m.room.message/${randomString}`, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/mattermost.js b/server/notification-providers/mattermost.js index 9946d02b2..63d39a148 100644 --- a/server/notification-providers/mattermost.js +++ b/server/notification-providers/mattermost.js @@ -12,6 +12,7 @@ class Mattermost extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); const mattermostUserName = notification.mattermostusername || "Uptime Kuma"; // If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing. if (heartbeatJSON == null) { @@ -19,7 +20,7 @@ class Mattermost extends NotificationProvider { username: mattermostUserName, text: msg, }; - await axios.post(notification.mattermostWebhookUrl, mattermostTestData); + await axios.post(notification.mattermostWebhookUrl, mattermostTestData, config); return okMsg; } @@ -98,7 +99,7 @@ class Mattermost extends NotificationProvider { }, ], }; - await axios.post(notification.mattermostWebhookUrl, mattermostdata); + await axios.post(notification.mattermostWebhookUrl, mattermostdata, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/notifery.js b/server/notification-providers/notifery.js index 772556497..99cc7bed2 100644 --- a/server/notification-providers/notifery.js +++ b/server/notification-providers/notifery.js @@ -42,7 +42,8 @@ class Notifery extends NotificationProvider { "x-api-key": notification.notiferyApiKey, }; - await axios.post(url, data, { headers }); + let config = this.getAxiosConfigWithProxy({ headers }); + await axios.post(url, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/notification-provider.js b/server/notification-providers/notification-provider.js index 42e8e616d..4d2587b82 100644 --- a/server/notification-providers/notification-provider.js +++ b/server/notification-providers/notification-provider.js @@ -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; diff --git a/server/notification-providers/ntfy.js b/server/notification-providers/ntfy.js index e44e7e868..9fe7fa2aa 100644 --- a/server/notification-providers/ntfy.js +++ b/server/notification-providers/ntfy.js @@ -22,6 +22,8 @@ class Ntfy extends NotificationProvider { "Authorization": "Bearer " + notification.ntfyaccesstoken, }; } + let config = { headers }; + config = this.getAxiosConfigWithProxy(config); // If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing. if (heartbeatJSON == null) { let ntfyTestData = { @@ -31,7 +33,7 @@ class Ntfy extends NotificationProvider { "priority": notification.ntfyPriority, "tags": [ "test_tube" ], }; - await axios.post(notification.ntfyserverurl, ntfyTestData, { headers: headers }); + await axios.post(notification.ntfyserverurl, ntfyTestData, config); return okMsg; } let tags = []; @@ -70,7 +72,7 @@ class Ntfy extends NotificationProvider { data.icon = notification.ntfyIcon; } - await axios.post(notification.ntfyserverurl, data, { headers: headers }); + await axios.post(notification.ntfyserverurl, data, config); return okMsg; diff --git a/server/notification-providers/octopush.js b/server/notification-providers/octopush.js index 7576e0ad6..14bb103a3 100644 --- a/server/notification-providers/octopush.js +++ b/server/notification-providers/octopush.js @@ -22,6 +22,7 @@ class Octopush extends NotificationProvider { "cache-control": "no-cache" } }; + config = this.getAxiosConfigWithProxy(config); let data = { "recipients": [ { @@ -53,6 +54,7 @@ class Octopush extends NotificationProvider { }, params: data }; + config = this.getAxiosConfigWithProxy(config); // V1 API returns 200 even on error so we must check // response data diff --git a/server/notification-providers/onebot.js b/server/notification-providers/onebot.js index b04794dee..6b2bc5aa7 100644 --- a/server/notification-providers/onebot.js +++ b/server/notification-providers/onebot.js @@ -25,6 +25,7 @@ class OneBot extends NotificationProvider { "Authorization": "Bearer " + notification.accessToken, } }; + config = this.getAxiosConfigWithProxy(config); let pushText = "UptimeKuma Alert: " + msg; let data = { "auto_escape": true, diff --git a/server/notification-providers/onechat.js b/server/notification-providers/onechat.js index 2d6ea1d5b..6a20f7aa6 100644 --- a/server/notification-providers/onechat.js +++ b/server/notification-providers/onechat.js @@ -13,12 +13,13 @@ class OneChat extends NotificationProvider { const url = "https://chat-api.one.th/message/api/v1/push_message"; try { - const config = { + let config = { headers: { "Content-Type": "application/json", Authorization: "Bearer " + notification.accessToken, }, }; + config = this.getAxiosConfigWithProxy(config); if (heartbeatJSON == null) { const testMessage = { to: notification.recieverId, diff --git a/server/notification-providers/onesender.js b/server/notification-providers/onesender.js index 4a33931a2..faa1d64ba 100644 --- a/server/notification-providers/onesender.js +++ b/server/notification-providers/onesender.js @@ -33,6 +33,7 @@ class Onesender extends NotificationProvider { "Authorization": "Bearer " + notification.onesenderToken, } }; + config = this.getAxiosConfigWithProxy(config); await axios.post(notification.onesenderURL, data, config); return okMsg; diff --git a/server/notification-providers/opsgenie.js b/server/notification-providers/opsgenie.js index 59a797055..9dac564a7 100644 --- a/server/notification-providers/opsgenie.js +++ b/server/notification-providers/opsgenie.js @@ -80,6 +80,7 @@ class Opsgenie extends NotificationProvider { "Authorization": `GenieKey ${notification.opsgenieApiKey}`, } }; + config = this.getAxiosConfigWithProxy(config); let res = await axios.post(url, data, config); if (res.status == null) { diff --git a/server/notification-providers/promosms.js b/server/notification-providers/promosms.js index 36b7ecb33..8c977cf0d 100644 --- a/server/notification-providers/promosms.js +++ b/server/notification-providers/promosms.js @@ -27,6 +27,7 @@ class PromoSMS extends NotificationProvider { "Accept": "text/json", } }; + config = this.getAxiosConfigWithProxy(config); let data = { "recipients": [ notification.promosmsPhoneNumber ], //Trim message to maximum length of 1 SMS or 4 if we allowed long messages diff --git a/server/notification-providers/pumble.js b/server/notification-providers/pumble.js index e1731c0ab..5261a0939 100644 --- a/server/notification-providers/pumble.js +++ b/server/notification-providers/pumble.js @@ -12,6 +12,7 @@ class Pumble extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); if (heartbeatJSON === null && monitorJSON === null) { let data = { "attachments": [ @@ -23,7 +24,7 @@ class Pumble extends NotificationProvider { ] }; - await axios.post(notification.webhookURL, data); + await axios.post(notification.webhookURL, data, config); return okMsg; } @@ -37,7 +38,7 @@ class Pumble extends NotificationProvider { ] }; - await axios.post(notification.webhookURL, data); + await axios.post(notification.webhookURL, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/pushbullet.js b/server/notification-providers/pushbullet.js index 0b7303103..e8cb2f1cf 100644 --- a/server/notification-providers/pushbullet.js +++ b/server/notification-providers/pushbullet.js @@ -20,6 +20,7 @@ class Pushbullet extends NotificationProvider { "Content-Type": "application/json" } }; + config = this.getAxiosConfigWithProxy(config); if (heartbeatJSON == null) { let data = { "type": "note", diff --git a/server/notification-providers/pushdeer.js b/server/notification-providers/pushdeer.js index 33d195f43..bb89c9167 100644 --- a/server/notification-providers/pushdeer.js +++ b/server/notification-providers/pushdeer.js @@ -33,7 +33,8 @@ class PushDeer extends NotificationProvider { }; try { - let res = await axios.post(url, data); + let config = this.getAxiosConfigWithProxy({}); + let res = await axios.post(url, data, config); if ("error" in res.data) { let error = res.data.error; diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index fdceeaa44..7080087a7 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -41,8 +41,9 @@ class Pushover extends NotificationProvider { } try { + let config = this.getAxiosConfigWithProxy({}); if (heartbeatJSON == null) { - await axios.post(url, data); + await axios.post(url, data, config); return okMsg; } @@ -52,7 +53,7 @@ class Pushover extends NotificationProvider { } data.message += `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; - await axios.post(url, data); + await axios.post(url, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/pushplus.js b/server/notification-providers/pushplus.js index a26ba176f..647c99eab 100644 --- a/server/notification-providers/pushplus.js +++ b/server/notification-providers/pushplus.js @@ -17,11 +17,12 @@ class PushPlus extends NotificationProvider { const okMsg = "Sent Successfully."; const url = "https://www.pushplus.plus/send"; try { - const config = { + let config = { headers: { "Content-Type": "application/json", }, }; + config = this.getAxiosConfigWithProxy(config); const params = { "token": notification.pushPlusSendKey, "title": this.checkStatus(heartbeatJSON, monitorJSON), diff --git a/server/notification-providers/pushy.js b/server/notification-providers/pushy.js index cb700229a..acd45a839 100644 --- a/server/notification-providers/pushy.js +++ b/server/notification-providers/pushy.js @@ -11,6 +11,7 @@ class Pushy extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, { "to": notification.pushyToken, "data": { @@ -21,7 +22,7 @@ class Pushy extends NotificationProvider { "badge": 1, "sound": "ping.aiff" } - }); + }, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/rocket-chat.js b/server/notification-providers/rocket-chat.js index 690e33a86..36daab3f9 100644 --- a/server/notification-providers/rocket-chat.js +++ b/server/notification-providers/rocket-chat.js @@ -14,6 +14,7 @@ class RocketChat extends NotificationProvider { const okMsg = "Sent Successfully."; try { + let config = this.getAxiosConfigWithProxy({}); if (heartbeatJSON == null) { let data = { "text": msg, @@ -21,7 +22,7 @@ class RocketChat extends NotificationProvider { "username": notification.rocketusername, "icon_emoji": notification.rocketiconemo, }; - await axios.post(notification.rocketwebhookURL, data); + await axios.post(notification.rocketwebhookURL, data, config); return okMsg; } @@ -55,7 +56,7 @@ class RocketChat extends NotificationProvider { data.attachments[0].title_link = baseURL + getMonitorRelativeURL(monitorJSON.id); } - await axios.post(notification.rocketwebhookURL, data); + await axios.post(notification.rocketwebhookURL, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/send-grid.js b/server/notification-providers/send-grid.js index 3489f6385..600afb116 100644 --- a/server/notification-providers/send-grid.js +++ b/server/notification-providers/send-grid.js @@ -17,7 +17,7 @@ class SendGrid extends NotificationProvider { Authorization: `Bearer ${notification.sendgridApiKey}`, }, }; - + config = this.getAxiosConfigWithProxy(config); let personalizations = { to: [{ email: notification.sendgridToEmail }], }; diff --git a/server/notification-providers/serverchan.js b/server/notification-providers/serverchan.js index aee22f83f..c7f15d4e3 100644 --- a/server/notification-providers/serverchan.js +++ b/server/notification-providers/serverchan.js @@ -18,10 +18,11 @@ class ServerChan extends NotificationProvider { : `https://sctapi.ftqq.com/${notification.serverChanSendKey}.send`; try { + let config = this.getAxiosConfigWithProxy({}); await axios.post(url, { "title": this.checkStatus(heartbeatJSON, monitorJSON), "desp": msg, - }); + }, config); return okMsg; diff --git a/server/notification-providers/serwersms.js b/server/notification-providers/serwersms.js index f7c8644af..24f4ed5c0 100644 --- a/server/notification-providers/serwersms.js +++ b/server/notification-providers/serwersms.js @@ -17,6 +17,7 @@ class SerwerSMS extends NotificationProvider { "Content-Type": "application/json", } }; + config = this.getAxiosConfigWithProxy(config); let data = { "username": notification.serwersmsUsername, "password": notification.serwersmsPassword, diff --git a/server/notification-providers/sevenio.js b/server/notification-providers/sevenio.js index eac38a26e..57a0a06cf 100644 --- a/server/notification-providers/sevenio.js +++ b/server/notification-providers/sevenio.js @@ -17,7 +17,7 @@ class SevenIO extends NotificationProvider { text: msg, }; - const config = { + let config = { baseURL: "https://gateway.seven.io/api/", headers: { "Content-Type": "application/json", @@ -26,6 +26,7 @@ class SevenIO extends NotificationProvider { }; try { + config = this.getAxiosConfigWithProxy(config); // testing or certificate expiry notification if (heartbeatJSON == null) { await axios.post("sms", data, config); diff --git a/server/notification-providers/signal.js b/server/notification-providers/signal.js index 9702d06bb..d826eb5c8 100644 --- a/server/notification-providers/signal.js +++ b/server/notification-providers/signal.js @@ -17,7 +17,7 @@ class Signal extends NotificationProvider { "recipients": notification.signalRecipients.replace(/\s/g, "").split(","), }; let config = {}; - + config = this.getAxiosConfigWithProxy(config); await axios.post(notification.signalURL, data, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/signl4.js b/server/notification-providers/signl4.js index 8261a73f3..8bedfc4a6 100644 --- a/server/notification-providers/signl4.js +++ b/server/notification-providers/signl4.js @@ -21,11 +21,12 @@ class SIGNL4 extends NotificationProvider { monitorUrl: this.extractAddress(monitorJSON), }; - const config = { + let config = { headers: { "Content-Type": "application/json" } }; + config = this.getAxiosConfigWithProxy(config); if (heartbeatJSON == null) { // Test alert diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index 33bd4fa81..d06740c62 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -131,6 +131,7 @@ class Slack extends NotificationProvider { } try { + let config = this.getAxiosConfigWithProxy({}); if (heartbeatJSON == null) { let data = { "text": msg, @@ -138,7 +139,7 @@ class Slack extends NotificationProvider { "username": notification.slackusername, "icon_emoji": notification.slackiconemo, }; - await axios.post(notification.slackwebhookURL, data); + await axios.post(notification.slackwebhookURL, data, config); return okMsg; } @@ -168,7 +169,7 @@ class Slack extends NotificationProvider { await Slack.deprecateURL(notification.slackbutton); } - await axios.post(notification.slackwebhookURL, data); + await axios.post(notification.slackwebhookURL, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/sms-planet.js b/server/notification-providers/sms-planet.js index 97e9e715e..f822720d6 100644 --- a/server/notification-providers/sms-planet.js +++ b/server/notification-providers/sms-planet.js @@ -18,6 +18,7 @@ class SMSPlanet extends NotificationProvider { "content-type": "multipart/form-data" } }; + config = this.getAxiosConfigWithProxy(config); let data = { "from": notification.smsplanetSenderName, diff --git a/server/notification-providers/smsc.js b/server/notification-providers/smsc.js index 89f01d01d..a0f869e4f 100644 --- a/server/notification-providers/smsc.js +++ b/server/notification-providers/smsc.js @@ -18,6 +18,7 @@ class SMSC extends NotificationProvider { "Accept": "text/json", } }; + config = this.getAxiosConfigWithProxy(config); let getArray = [ "fmt=3", diff --git a/server/notification-providers/smseagle.js b/server/notification-providers/smseagle.js index a123243a4..6e347a72c 100644 --- a/server/notification-providers/smseagle.js +++ b/server/notification-providers/smseagle.js @@ -17,6 +17,7 @@ class SMSEagle extends NotificationProvider { "Content-Type": "application/x-www-form-urlencoded", } }; + config = this.getAxiosConfigWithProxy(config); let sendMethod; let recipientType; @@ -78,6 +79,7 @@ class SMSEagle extends NotificationProvider { "Content-Type": "application/json", } }; + config = this.getAxiosConfigWithProxy(config); let encoding = (notification.smseagleEncoding) ? "unicode" : "standard"; let priority = (notification.smseaglePriority) ?? 0; diff --git a/server/notification-providers/smsmanager.js b/server/notification-providers/smsmanager.js index d01285d88..aa72229e6 100644 --- a/server/notification-providers/smsmanager.js +++ b/server/notification-providers/smsmanager.js @@ -18,7 +18,8 @@ class SMSManager extends NotificationProvider { number: notification.numbers, gateway: notification.messageType, }; - await axios.get(`${url}?apikey=${data.apikey}&message=${data.message}&number=${data.number}&gateway=${data.messageType}`); + let config = this.getAxiosConfigWithProxy({}); + await axios.get(`${url}?apikey=${data.apikey}&message=${data.message}&number=${data.number}&gateway=${data.messageType}`, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/smspartner.js b/server/notification-providers/smspartner.js index 5595217a4..6b58e402b 100644 --- a/server/notification-providers/smspartner.js +++ b/server/notification-providers/smspartner.js @@ -29,6 +29,7 @@ class SMSPartner extends NotificationProvider { "Accept": "application/json", } }; + config = this.getAxiosConfigWithProxy(config); let resp = await axios.post(url, data, config); diff --git a/server/notification-providers/spugpush.js b/server/notification-providers/spugpush.js index b04a20cac..1e459bc16 100644 --- a/server/notification-providers/spugpush.js +++ b/server/notification-providers/spugpush.js @@ -26,7 +26,8 @@ class SpugPush extends NotificationProvider { } } const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`; - await axios.post(apiUrl, formData); + let config = this.getAxiosConfigWithProxy({}); + await axios.post(apiUrl, formData, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/squadcast.js b/server/notification-providers/squadcast.js index 5713783c0..6db789c55 100644 --- a/server/notification-providers/squadcast.js +++ b/server/notification-providers/squadcast.js @@ -45,6 +45,7 @@ class Squadcast extends NotificationProvider { } }); } + config = this.getAxiosConfigWithProxy(config); await axios.post(notification.squadcastWebhookURL, data, config); return okMsg; diff --git a/server/notification-providers/stackfield.js b/server/notification-providers/stackfield.js index 65a92459a..3bcd252b6 100644 --- a/server/notification-providers/stackfield.js +++ b/server/notification-providers/stackfield.js @@ -31,8 +31,9 @@ class Stackfield extends NotificationProvider { const data = { "Title": textMsg, }; + let config = this.getAxiosConfigWithProxy({}); - await axios.post(notification.stackfieldwebhookURL, data); + await axios.post(notification.stackfieldwebhookURL, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/teams.js b/server/notification-providers/teams.js index 2793604cc..a208f26bc 100644 --- a/server/notification-providers/teams.js +++ b/server/notification-providers/teams.js @@ -185,7 +185,8 @@ class Teams extends NotificationProvider { * @returns {Promise} */ _sendNotification = async (webhookUrl, payload) => { - await axios.post(webhookUrl, payload); + let config = this.getAxiosConfigWithProxy({}); + await axios.post(webhookUrl, payload, config); }; /** diff --git a/server/notification-providers/techulus-push.js b/server/notification-providers/techulus-push.js index bf688b194..7c33bc125 100644 --- a/server/notification-providers/techulus-push.js +++ b/server/notification-providers/techulus-push.js @@ -25,7 +25,8 @@ class TechulusPush extends NotificationProvider { } try { - await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, data); + let config = this.getAxiosConfigWithProxy({}); + await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, data, config); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/telegram.js b/server/notification-providers/telegram.js index 04117e65a..1cee5c11c 100644 --- a/server/notification-providers/telegram.js +++ b/server/notification-providers/telegram.js @@ -30,9 +30,9 @@ class Telegram extends NotificationProvider { } } - await axios.get(`${url}/bot${notification.telegramBotToken}/sendMessage`, { - params: params, - }); + let config = this.getAxiosConfigWithProxy({ params }); + + await axios.get(`${url}/bot${notification.telegramBotToken}/sendMessage`, config); return okMsg; } catch (error) { diff --git a/server/notification-providers/threema.js b/server/notification-providers/threema.js index 07a54ab6e..13db4cb0c 100644 --- a/server/notification-providers/threema.js +++ b/server/notification-providers/threema.js @@ -10,12 +10,13 @@ class Threema extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { const url = "https://msgapi.threema.ch/send_simple"; - const config = { + let config = { headers: { "Accept": "*/*", "Content-Type": "application/x-www-form-urlencoded; charset=utf-8" } }; + config = this.getAxiosConfigWithProxy(config); const data = { from: notification.threemaSenderIdentity, diff --git a/server/notification-providers/twilio.js b/server/notification-providers/twilio.js index c38a6d7ed..f198f3623 100644 --- a/server/notification-providers/twilio.js +++ b/server/notification-providers/twilio.js @@ -19,6 +19,7 @@ class Twilio extends NotificationProvider { "Authorization": "Basic " + Buffer.from(apiKey + ":" + notification.twilioAuthToken).toString("base64"), } }; + config = this.getAxiosConfigWithProxy(config); let data = new URLSearchParams(); data.append("To", notification.twilioToNumber); diff --git a/server/notification-providers/waha.js b/server/notification-providers/waha.js index b075f33f0..6bd857d5b 100644 --- a/server/notification-providers/waha.js +++ b/server/notification-providers/waha.js @@ -11,13 +11,14 @@ class WAHA extends NotificationProvider { const okMsg = "Sent Successfully."; try { - const config = { + let config = { headers: { "Accept": "application/json", "Content-Type": "application/json", "X-Api-Key": notification.wahaApiKey, } }; + config = this.getAxiosConfigWithProxy(config); let data = { "session": notification.wahaSession, diff --git a/server/notification-providers/webhook.js b/server/notification-providers/webhook.js index 537f94bd5..77ce229d8 100644 --- a/server/notification-providers/webhook.js +++ b/server/notification-providers/webhook.js @@ -41,6 +41,7 @@ class Webhook extends NotificationProvider { } } + config = this.getAxiosConfigWithProxy(config); await axios.post(notification.webhookURL, data, config); return okMsg; diff --git a/server/notification-providers/wecom.js b/server/notification-providers/wecom.js index 1eb069095..3b0d48971 100644 --- a/server/notification-providers/wecom.js +++ b/server/notification-providers/wecom.js @@ -17,6 +17,7 @@ class WeCom extends NotificationProvider { "Content-Type": "application/json" } }; + config = this.getAxiosConfigWithProxy(config); let body = this.composeMessage(heartbeatJSON, msg); await axios.post(`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${notification.weComBotKey}`, body, config); return okMsg; diff --git a/server/notification-providers/whapi.js b/server/notification-providers/whapi.js index d83dc470f..8866e9ec7 100644 --- a/server/notification-providers/whapi.js +++ b/server/notification-providers/whapi.js @@ -11,13 +11,14 @@ class Whapi extends NotificationProvider { const okMsg = "Sent Successfully."; try { - const config = { + let config = { headers: { "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Bearer " + notification.whapiAuthToken, } }; + config = this.getAxiosConfigWithProxy(config); let data = { "to": notification.whapiRecipient, diff --git a/server/notification-providers/wpush.js b/server/notification-providers/wpush.js index db043f9c5..1af90992c 100644 --- a/server/notification-providers/wpush.js +++ b/server/notification-providers/wpush.js @@ -18,7 +18,8 @@ class WPush extends NotificationProvider { "apikey": notification.wpushAPIkey, "channel": notification.wpushChannel }; - const result = await axios.post("https://api.wpush.cn/api/v1/send", context); + let config = this.getAxiosConfigWithProxy({}); + const result = await axios.post("https://api.wpush.cn/api/v1/send", context, config); if (result.data.code !== 0) { throw result.data.message; } diff --git a/server/notification-providers/yzj.js b/server/notification-providers/yzj.js index 6bd3cba51..7b39e6385 100644 --- a/server/notification-providers/yzj.js +++ b/server/notification-providers/yzj.js @@ -16,7 +16,7 @@ class YZJ extends NotificationProvider { msg = `${this.statusToString(heartbeatJSON["status"])} ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; } - const config = { + let config = { headers: { "Content-Type": "application/json", }, @@ -26,6 +26,7 @@ class YZJ extends NotificationProvider { }; // yzjtype=0 => general robot const url = `${notification.yzjWebHookUrl}?yzjtype=0&yzjtoken=${notification.yzjToken}`; + config = this.getAxiosConfigWithProxy(config); const result = await axios.post(url, params, config); if (!result.data?.success) { diff --git a/server/notification-providers/zoho-cliq.js b/server/notification-providers/zoho-cliq.js index 3a504de8c..44a0fcac4 100644 --- a/server/notification-providers/zoho-cliq.js +++ b/server/notification-providers/zoho-cliq.js @@ -27,7 +27,8 @@ class ZohoCliq extends NotificationProvider { * @returns {Promise} */ _sendNotification = async (webhookUrl, payload) => { - await axios.post(webhookUrl, { text: payload.join("\n") }); + let config = this.getAxiosConfigWithProxy({}); + await axios.post(webhookUrl, { text: payload.join("\n") }, config); }; /**