mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-18 23:34:04 +02:00
moved to auth side aand fix of path
This commit is contained in:
parent
279ca266d9
commit
6020cb9e8d
3 changed files with 114 additions and 17 deletions
|
@ -879,7 +879,7 @@ let needSetup = false;
|
|||
bean.manual_status = monitor.manual_status;
|
||||
bean.rtspUsername = monitor.rtspUsername;
|
||||
bean.rtspPassword = monitor.rtspPassword;
|
||||
bean.rtspPath = monitor.path;
|
||||
bean.rtspPath = monitor.rtspPath;
|
||||
|
||||
// ping advanced options
|
||||
bean.ping_numeric = monitor.ping_numeric;
|
||||
|
|
|
@ -518,22 +518,6 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="monitor.type === 'rtsp'">
|
||||
<div class="my-3">
|
||||
<label for="rtspUsername" class="form-label">RTSP {{ $t("Username") }}</label>
|
||||
<input id="rtspUsername" v-model="monitor.rtspUsername" type="text" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="my-3">
|
||||
<label for="rtspPassword" class="form-label">RTSP {{ $t("Password") }}</label>
|
||||
<input id="rtspPassword" v-model="monitor.rtspPassword" type="password" class="form-control">
|
||||
</div>
|
||||
<div class="my-3">
|
||||
<label for="rtspPath" class="form-label">RTSP {{ $t("path") }}</label>
|
||||
<input id="rtspPath" v-model="monitor.rtspPath" type="text" class="form-control">
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="monitor.type === 'radius'">
|
||||
<div class="my-3">
|
||||
<label for="radius_username" class="form-label">Radius {{ $t("Username") }}</label>
|
||||
|
@ -1071,6 +1055,26 @@
|
|||
</template>
|
||||
</template>
|
||||
|
||||
<template v-if="monitor.type === 'rtsp'">
|
||||
<h4 class="mt-5 mb-2">{{ $t("Authentication") }}</h4>
|
||||
|
||||
<div class="my-3">
|
||||
<label for="rtspUsername" class="form-label">RTSP {{ $t("Username") }}</label>
|
||||
<input
|
||||
id="rtspUsername" v-model="monitor.rtspUsername" :placeholder="$t('Username')" type="text" class="form-control"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="my-3">
|
||||
<label for="rtspPassword" class="form-label">RTSP {{ $t("Password") }}</label>
|
||||
<input id="rtspPassword" v-model="monitor.rtspPassword" :placeholder="$t('Password')" type="password" class="form-control">
|
||||
</div>
|
||||
<div class="my-3">
|
||||
<label for="rtspPath" class="form-label">RTSP {{ $t("path") }}</label>
|
||||
<input id="rtspPath" v-model="monitor.rtspPath" :placeholder="$t('Path')" type="text" class="form-control">
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- gRPC Options -->
|
||||
<template v-if="monitor.type === 'grpc-keyword' ">
|
||||
<!-- Proto service enable TLS -->
|
||||
|
|
93
test/backend-test/test-rtsp.js
Normal file
93
test/backend-test/test-rtsp.js
Normal file
|
@ -0,0 +1,93 @@
|
|||
const { describe, test } = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const { RtspMonitorType } = require("../../server/monitor-types/rtsp");
|
||||
const { UP, DOWN, PENDING } = require("../../src/util");
|
||||
const RTSPClient = require("rtsp-client");
|
||||
|
||||
describe("RTSP Monitor", {
|
||||
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
|
||||
}, () => {
|
||||
test("RTSP stream is accessible", async () => {
|
||||
const rtspMonitor = new RtspMonitorType();
|
||||
const monitor = {
|
||||
hostname: "localhost",
|
||||
port: 8554,
|
||||
rtspPath: "/teststream",
|
||||
rtspUsername: "user",
|
||||
rtspPassword: "pass",
|
||||
name: "RTSP Test Monitor",
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
msg: "",
|
||||
status: PENDING,
|
||||
};
|
||||
|
||||
RTSPClient.prototype.connect = async () => {};
|
||||
RTSPClient.prototype.describe = async () => ({
|
||||
statusCode: 200,
|
||||
statusMessage: "OK",
|
||||
});
|
||||
RTSPClient.prototype.close = async () => {};
|
||||
|
||||
await rtspMonitor.check(monitor, heartbeat, {});
|
||||
assert.strictEqual(heartbeat.status, UP);
|
||||
assert.strictEqual(heartbeat.msg, "RTSP stream is accessible");
|
||||
});
|
||||
|
||||
test("RTSP stream is not accessible", async () => {
|
||||
const rtspMonitor = new RtspMonitorType();
|
||||
const monitor = {
|
||||
hostname: "localhost",
|
||||
port: 9999,
|
||||
rtspPath: "/teststream",
|
||||
rtspUsername: "user",
|
||||
rtspPassword: "pass",
|
||||
name: "RTSP Test Monitor",
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
msg: "",
|
||||
status: PENDING,
|
||||
};
|
||||
|
||||
RTSPClient.prototype.connect = async () => {
|
||||
throw new Error("Connection refused");
|
||||
};
|
||||
RTSPClient.prototype.close = async () => {};
|
||||
|
||||
await rtspMonitor.check(monitor, heartbeat, {});
|
||||
assert.strictEqual(heartbeat.status, DOWN);
|
||||
assert.match(heartbeat.msg, /RTSP check failed: Connection refused/);
|
||||
});
|
||||
|
||||
test("RTSP stream returns 503 error", async () => {
|
||||
const rtspMonitor = new RtspMonitorType();
|
||||
const monitor = {
|
||||
hostname: "localhost",
|
||||
port: 8554,
|
||||
rtspPath: "/teststream",
|
||||
rtspUsername: "user",
|
||||
rtspPassword: "pass",
|
||||
name: "RTSP Test Monitor",
|
||||
};
|
||||
|
||||
const heartbeat = {
|
||||
msg: "",
|
||||
status: PENDING,
|
||||
};
|
||||
|
||||
RTSPClient.prototype.connect = async () => {};
|
||||
RTSPClient.prototype.describe = async () => ({
|
||||
statusCode: 503,
|
||||
statusMessage: "Service Unavailable",
|
||||
body: { reason: "Server overloaded" },
|
||||
});
|
||||
RTSPClient.prototype.close = async () => {};
|
||||
|
||||
await rtspMonitor.check(monitor, heartbeat, {});
|
||||
assert.strictEqual(heartbeat.status, DOWN);
|
||||
assert.strictEqual(heartbeat.msg, "Server overloaded");
|
||||
});
|
||||
});
|
||||
|
Loading…
Add table
Reference in a new issue