mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-12 20:34:46 +00:00
merge wsurl with url
This commit is contained in:
parent
5bca760d58
commit
2ad0d7805a
6 changed files with 12 additions and 24 deletions
|
@ -1,15 +1,13 @@
|
||||||
// Add websocket URL
|
// Add websocket ignore headers
|
||||||
exports.up = function (knex) {
|
exports.up = function (knex) {
|
||||||
return knex.schema
|
return knex.schema
|
||||||
.alterTable("monitor", function (table) {
|
.alterTable("monitor", function (table) {
|
||||||
table.text("wsurl");
|
|
||||||
table.boolean("ws_ignore_headers").notNullable().defaultTo(false);
|
table.boolean("ws_ignore_headers").notNullable().defaultTo(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.down = function (knex) {
|
exports.down = function (knex) {
|
||||||
return knex.schema.alterTable("monitor", function (table) {
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
table.dropColumn("wsurl");
|
|
||||||
table.dropColumn("ws_ignore_headers");
|
table.dropColumn("ws_ignore_headers");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,7 +96,6 @@ class Monitor extends BeanModel {
|
||||||
parent: this.parent,
|
parent: this.parent,
|
||||||
childrenIDs: preloadData.childrenIDs.get(this.id) || [],
|
childrenIDs: preloadData.childrenIDs.get(this.id) || [],
|
||||||
url: this.url,
|
url: this.url,
|
||||||
wsurl: this.wsurl,
|
|
||||||
wsIgnoreHeaders: this.getWsIgnoreHeaders(),
|
wsIgnoreHeaders: this.getWsIgnoreHeaders(),
|
||||||
method: this.method,
|
method: this.method,
|
||||||
hostname: this.hostname,
|
hostname: this.hostname,
|
||||||
|
|
|
@ -21,7 +21,7 @@ class WebSocketMonitorType extends MonitorType {
|
||||||
*/
|
*/
|
||||||
async attemptUpgrade(monitor) {
|
async attemptUpgrade(monitor) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const ws = new WebSocket(monitor.wsurl);
|
const ws = new WebSocket(monitor.url);
|
||||||
|
|
||||||
ws.addEventListener("open", (event) => {
|
ws.addEventListener("open", (event) => {
|
||||||
// Immediately close the connection
|
// Immediately close the connection
|
||||||
|
|
|
@ -790,7 +790,6 @@ let needSetup = false;
|
||||||
bean.parent = monitor.parent;
|
bean.parent = monitor.parent;
|
||||||
bean.type = monitor.type;
|
bean.type = monitor.type;
|
||||||
bean.url = monitor.url;
|
bean.url = monitor.url;
|
||||||
bean.wsurl = monitor.wsurl;
|
|
||||||
bean.wsIgnoreHeaders = monitor.wsIgnoreHeaders;
|
bean.wsIgnoreHeaders = monitor.wsIgnoreHeaders;
|
||||||
bean.method = monitor.method;
|
bean.method = monitor.method;
|
||||||
bean.body = monitor.body;
|
bean.body = monitor.body;
|
||||||
|
|
|
@ -117,15 +117,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- URL -->
|
<!-- URL -->
|
||||||
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3">
|
<div v-if="monitor.type === 'websocket-upgrade' || monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3">
|
||||||
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
||||||
<input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required data-testid="url-input">
|
<input id="url" v-model="monitor.url" type="url" class="form-control" :pattern="monitor.type !== 'websocket-upgrade' ? 'https?://.+' : 'wss?://.+'" required data-testid="url-input">
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Websocket -->
|
|
||||||
<div v-if="monitor.type === 'websocket-upgrade'" class="my-3">
|
|
||||||
<label for="wsurl" class="form-label">{{ $t("URL") }}</label>
|
|
||||||
<input id="wsurl" v-model="monitor.wsurl" type="wsurl" class="form-control" pattern="wss?://.+" required data-testid="url-input">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- gRPC URL -->
|
<!-- gRPC URL -->
|
||||||
|
@ -1094,7 +1088,6 @@ const monitorDefaults = {
|
||||||
name: "",
|
name: "",
|
||||||
parent: null,
|
parent: null,
|
||||||
url: "https://",
|
url: "https://",
|
||||||
wsurl: "wss://",
|
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
interval: 60,
|
interval: 60,
|
||||||
|
@ -1444,6 +1437,9 @@ message HealthCheckResponse {
|
||||||
},
|
},
|
||||||
|
|
||||||
"monitor.type"(newType, oldType) {
|
"monitor.type"(newType, oldType) {
|
||||||
|
if (oldType && this.monitor.type === "websocket-upgrade") {
|
||||||
|
this.monitor.url = "wss://";
|
||||||
|
}
|
||||||
if (this.monitor.type === "push") {
|
if (this.monitor.type === "push") {
|
||||||
if (! this.monitor.pushToken) {
|
if (! this.monitor.pushToken) {
|
||||||
// ideally this would require checking if the generated token is already used
|
// ideally this would require checking if the generated token is already used
|
||||||
|
@ -1749,10 +1745,6 @@ message HealthCheckResponse {
|
||||||
this.monitor.url = this.monitor.url.trim();
|
this.monitor.url = this.monitor.url.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.monitor.wsurl) {
|
|
||||||
this.monitor.wsurl = this.monitor.wsurl.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
let createdNewParent = false;
|
let createdNewParent = false;
|
||||||
|
|
||||||
if (this.draftGroupName && this.monitor.parent === -1) {
|
if (this.draftGroupName && this.monitor.parent === -1) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe("Websocket Test", {
|
||||||
const websocketMonitor = new WebSocketMonitorType();
|
const websocketMonitor = new WebSocketMonitorType();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "wss://example.org",
|
url: "wss://example.org",
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ describe("Websocket Test", {
|
||||||
const websocketMonitor = new WebSocketMonitorType();
|
const websocketMonitor = new WebSocketMonitorType();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "wss://echo.websocket.org",
|
url: "wss://echo.websocket.org",
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe("Websocket Test", {
|
||||||
const wss = new WebSocketServer({ port: 8080 });
|
const wss = new WebSocketServer({ port: 8080 });
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "ws://localhost:8080",
|
url: "ws://localhost:8080",
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ describe("Websocket Test", {
|
||||||
const websocketMonitor = new WebSocketMonitorType();
|
const websocketMonitor = new WebSocketMonitorType();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
url: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
||||||
wsIgnoreHeaders: false,
|
wsIgnoreHeaders: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ describe("Websocket Test", {
|
||||||
const websocketMonitor = new WebSocketMonitorType();
|
const websocketMonitor = new WebSocketMonitorType();
|
||||||
|
|
||||||
const monitor = {
|
const monitor = {
|
||||||
wsurl: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
url: "wss://c.img-cdn.net/yE4s7KehTFyj/",
|
||||||
wsIgnoreHeaders: true,
|
wsIgnoreHeaders: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue