mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 23:04:04 +00:00
Compare commits
6 commits
3a0492d57f
...
3b9f6f9690
Author | SHA1 | Date | |
---|---|---|---|
|
3b9f6f9690 | ||
|
d2f71d11d6 | ||
|
fd05aad398 | ||
|
a70a2c6b35 | ||
|
2f5a6d9648 | ||
|
21a6b4a131 |
5 changed files with 23 additions and 15 deletions
|
@ -1,10 +1,10 @@
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const https = require("https");
|
const https = require("https");
|
||||||
const fs = require("fs");
|
const fs = require("fs/promises");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const Database = require("./database");
|
const Database = require("./database");
|
||||||
const { axiosAbortSignal } = require("./util-server");
|
const { axiosAbortSignal, fileExists } = require("./util-server");
|
||||||
|
|
||||||
class DockerHost {
|
class DockerHost {
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class DockerHost {
|
||||||
options.socketPath = dockerHost.dockerDaemon;
|
options.socketPath = dockerHost.dockerDaemon;
|
||||||
} else if (dockerHost.dockerType === "tcp") {
|
} else if (dockerHost.dockerType === "tcp") {
|
||||||
options.baseURL = DockerHost.patchDockerURL(dockerHost.dockerDaemon);
|
options.baseURL = DockerHost.patchDockerURL(dockerHost.dockerDaemon);
|
||||||
options.httpsAgent = new https.Agent(DockerHost.getHttpsAgentOptions(dockerHost.dockerType, options.baseURL));
|
options.httpsAgent = new https.Agent(await DockerHost.getHttpsAgentOptions(dockerHost.dockerType, options.baseURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -143,7 +143,7 @@ class DockerHost {
|
||||||
* @param {string} url The docker host URL rewritten to https://
|
* @param {string} url The docker host URL rewritten to https://
|
||||||
* @returns {object} HTTP agent options
|
* @returns {object} HTTP agent options
|
||||||
*/
|
*/
|
||||||
static getHttpsAgentOptions(dockerType, url) {
|
static async getHttpsAgentOptions(dockerType, url) {
|
||||||
let baseOptions = {
|
let baseOptions = {
|
||||||
maxCachedSessions: 0,
|
maxCachedSessions: 0,
|
||||||
rejectUnauthorized: true
|
rejectUnauthorized: true
|
||||||
|
@ -156,10 +156,10 @@ class DockerHost {
|
||||||
let certPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameCert);
|
let certPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameCert);
|
||||||
let keyPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameKey);
|
let keyPath = path.join(Database.dockerTLSDir, dirName, DockerHost.CertificateFileNameKey);
|
||||||
|
|
||||||
if (dockerType === "tcp" && fs.existsSync(caPath) && fs.existsSync(certPath) && fs.existsSync(keyPath)) {
|
if (dockerType === "tcp" && await fileExists(caPath) && await fileExists(certPath) && await fileExists(keyPath)) {
|
||||||
let ca = fs.readFileSync(caPath);
|
let ca = await fs.readFile(caPath);
|
||||||
let key = fs.readFileSync(keyPath);
|
let key = await fs.readFile(keyPath);
|
||||||
let cert = fs.readFileSync(certPath);
|
let cert = await fs.readFile(certPath);
|
||||||
certOptions = {
|
certOptions = {
|
||||||
ca,
|
ca,
|
||||||
key,
|
key,
|
||||||
|
|
|
@ -739,7 +739,7 @@ class Monitor extends BeanModel {
|
||||||
} else if (dockerHost._dockerType === "tcp") {
|
} else if (dockerHost._dockerType === "tcp") {
|
||||||
options.baseURL = DockerHost.patchDockerURL(dockerHost._dockerDaemon);
|
options.baseURL = DockerHost.patchDockerURL(dockerHost._dockerDaemon);
|
||||||
options.httpsAgent = new https.Agent(
|
options.httpsAgent = new https.Agent(
|
||||||
DockerHost.getHttpsAgentOptions(dockerHost._dockerType, options.baseURL)
|
await DockerHost.getHttpsAgentOptions(dockerHost._dockerType, options.baseURL)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,9 @@ class ServerChan extends NotificationProvider {
|
||||||
const okMsg = "Sent Successfully.";
|
const okMsg = "Sent Successfully.";
|
||||||
|
|
||||||
// serverchan3 requires sending via ft07.com
|
// serverchan3 requires sending via ft07.com
|
||||||
const url = String(notification.serverChanSendKey).startsWith("sctp")
|
const matchResult = String(notification.serverChanSendKey).match(/^sctp(\d+)t/i);
|
||||||
? `https://${notification.serverChanSendKey}.push.ft07.com/send`
|
const url = matchResult && matchResult[1]
|
||||||
|
? `https://${matchResult[1]}.push.ft07.com/send/${notification.serverChanSendKey}.send`
|
||||||
: `https://sctapi.ftqq.com/${notification.serverChanSendKey}.send`;
|
: `https://sctapi.ftqq.com/${notification.serverChanSendKey}.send`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,7 +4,7 @@ const { sendInfo } = require("../client");
|
||||||
const { checkLogin } = require("../util-server");
|
const { checkLogin } = require("../util-server");
|
||||||
const GameResolver = require("gamedig/lib/GameResolver");
|
const GameResolver = require("gamedig/lib/GameResolver");
|
||||||
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
|
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
|
||||||
const fs = require("fs");
|
const fs = require("fs/promises");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
let gameResolver = new GameResolver();
|
let gameResolver = new GameResolver();
|
||||||
|
@ -90,17 +90,17 @@ module.exports.generalSocketHandler = (socket, server) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("getPushExample", (language, callback) => {
|
socket.on("getPushExample", async (language, callback) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dir = path.join("./extra/push-examples", language);
|
let dir = path.join("./extra/push-examples", language);
|
||||||
let files = fs.readdirSync(dir);
|
let files = await fs.readdir(dir);
|
||||||
|
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
if (file.startsWith("index.")) {
|
if (file.startsWith("index.")) {
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
code: fs.readFileSync(path.join(dir, file), "utf8"),
|
code: await fs.readFile(path.join(dir, file), "utf8"),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ const radiusClient = require("node-radius-client");
|
||||||
const redis = require("redis");
|
const redis = require("redis");
|
||||||
const oidc = require("openid-client");
|
const oidc = require("openid-client");
|
||||||
const tls = require("tls");
|
const tls = require("tls");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
dictionaries: {
|
dictionaries: {
|
||||||
|
@ -1062,3 +1063,9 @@ module.exports.axiosAbortSignal = (timeoutMs) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.fileExists = (file) => {
|
||||||
|
return fs.promises.access(file, fs.constants.F_OK)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue