lint issues resolved

This commit is contained in:
maryamsaleem 2025-02-06 14:57:09 +05:00
parent 8704b12fae
commit 70d1d9a964
5 changed files with 202 additions and 146 deletions

View file

@ -5,7 +5,7 @@ const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, MAX_INTERVAL_SECOND, MI
SQL_DATETIME_FORMAT, evaluateJsonQuery SQL_DATETIME_FORMAT, evaluateJsonQuery
} = require("../../src/util"); } = require("../../src/util");
const { tcping, ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, setSetting, httpNtlm, radius, grpcQuery, const { tcping, ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, setSetting, httpNtlm, radius, grpcQuery,
redisPingAsync, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal, sipRegisterRequest,sipOptionRequest redisPingAsync, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal, sipRegisterRequest, sipOptionRequest
} = require("../util-server"); } = require("../util-server");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const { BeanModel } = require("redbean-node/dist/bean-model"); const { BeanModel } = require("redbean-node/dist/bean-model");
@ -315,9 +315,9 @@ class Monitor extends BeanModel {
sipUrl: this.sipUrl, sipUrl: this.sipUrl,
sipPort: this.sipPort, sipPort: this.sipPort,
sipProtocol: this.sipProtocol, sipProtocol: this.sipProtocol,
sipMethod: this.sipMethod, sipMethod: this.sipMethod,
sipMaintainence: this.isSipMaintainence(), sipMaintainence: this.isSipMaintainence(),
sipAuthMethod: this.sipAuthMethod, sipAuthMethod: this.sipAuthMethod,
}; };
if (includeSensitiveData) { if (includeSensitiveData) {
@ -483,6 +483,7 @@ class Monitor extends BeanModel {
getKafkaProducerAllowAutoTopicCreation() { getKafkaProducerAllowAutoTopicCreation() {
return Boolean(this.kafkaProducerAllowAutoTopicCreation); return Boolean(this.kafkaProducerAllowAutoTopicCreation);
} }
/** /**
* Parse to boolean * Parse to boolean
* @returns {boolean} Sip Allow Maintainenece Option * @returns {boolean} Sip Allow Maintainenece Option
@ -490,6 +491,7 @@ class Monitor extends BeanModel {
isSipMaintainence() { isSipMaintainence() {
return Boolean(this.sipMaintainence); return Boolean(this.sipMaintainence);
} }
/** /**
* Start monitor * Start monitor
* @param {Server} io Socket server instance * @param {Server} io Socket server instance
@ -1052,12 +1054,11 @@ class Monitor extends BeanModel {
let sipMessage; let sipMessage;
let startTime = dayjs().valueOf(); let startTime = dayjs().valueOf();
let totalResponseTime; let totalResponseTime;
let requestCount;
if (this.sipMethod !== "OPTIONS") { if (this.sipMethod !== "OPTIONS") {
sipResponse = await sipRegisterRequest(this.sipUrl, this.sipPort, this.sipProtocol, this.sip_basic_auth_user, this.sip_basic_auth_pass, version); sipResponse = await sipRegisterRequest(this.sipUrl, this.sipPort, this.sipProtocol, this.sip_basic_auth_user, this.sip_basic_auth_pass, version);
let sipResponseTime = dayjs().valueOf() - startTime; let sipResponseTime = dayjs().valueOf() - startTime;
totalResponseTime += sipResponseTime; totalResponseTime += sipResponseTime;
console.log("sipResponse", sipResponse); console.log("sipResponse", totalResponseTime);
console.log("this.sipMaintainence", this.sipMaintainence); console.log("this.sipMaintainence", this.sipMaintainence);
const matchingStatus = sipStatusCodes.find(code => code.status === sipResponse?.status); const matchingStatus = sipStatusCodes.find(code => code.status === sipResponse?.status);
if (matchingStatus) { if (matchingStatus) {
@ -1066,7 +1067,7 @@ class Monitor extends BeanModel {
bean.status = sipResponse?.status === 200 ? UP : DOWN; bean.status = sipResponse?.status === 200 ? UP : DOWN;
console.log("sipResponse?.status", sipResponse?.status); console.log("sipResponse?.status", sipResponse?.status);
// Additional check for 503 status within matchingStatus // Additional check for 503 status within matchingStatus
if (sipResponse?.status === 503 && this.sipMaintainence == 1) { if (sipResponse?.status === 503 && this.sipMaintainence === 1) {
sipMessage = "Monitor under maintenance"; sipMessage = "Monitor under maintenance";
bean.status = MAINTENANCE; bean.status = MAINTENANCE;
} }
@ -1074,12 +1075,9 @@ class Monitor extends BeanModel {
sipMessage = ` ${sipResponse?.status}-Not Ok`; sipMessage = ` ${sipResponse?.status}-Not Ok`;
bean.status = DOWN; bean.status = DOWN;
} }
} else if (this.sipMethod === "OPTIONS") { } else if (this.sipMethod === "OPTIONS") {
sipResponse = await sipOptionRequest(this.sipUrl, this.sipPort, this.sipProtocol, this.sip_basic_auth_user, this.sip_basic_auth_pass, version); sipResponse = await sipOptionRequest(this.sipUrl, this.sipPort, this.sipProtocol, this.sip_basic_auth_user, this.sip_basic_auth_pass, version);
let sipOptionsResponseTime = dayjs().valueOf() - startTime;
totalResponseTime = sipOptionsResponseTime;
requestCount++;
console.log("=====resposne status", sipResponse?.status); console.log("=====resposne status", sipResponse?.status);
console.log("this.sipMaintainence", this.sipMaintainence); console.log("this.sipMaintainence", this.sipMaintainence);
const matchingStatus = sipStatusCodes.find(code => code.status === sipResponse?.status); const matchingStatus = sipStatusCodes.find(code => code.status === sipResponse?.status);
@ -1089,7 +1087,7 @@ class Monitor extends BeanModel {
bean.status = sipResponse?.status === 200 ? UP : DOWN; bean.status = sipResponse?.status === 200 ? UP : DOWN;
// Additional check for 503 status within matchingStatus // Additional check for 503 status within matchingStatus
if (sipResponse?.status === 503 && this.sipMaintainence == 1) { if (sipResponse?.status === 503 && this.sipMaintainence === 1) {
sipMessage = "Monitor under maintenance"; sipMessage = "Monitor under maintenance";
bean.status = MAINTENANCE; bean.status = MAINTENANCE;
} }
@ -1105,8 +1103,7 @@ class Monitor extends BeanModel {
bean.msg = `Error: ${error.message}`; bean.msg = `Error: ${error.message}`;
bean.status = DOWN; bean.status = DOWN;
} }
} } else {
else {
throw new Error("Unknown Monitor Type"); throw new Error("Unknown Monitor Type");
} }

View file

@ -2,14 +2,29 @@ const NotificationProvider = require("./notification-provider");
class SIP extends NotificationProvider { class SIP extends NotificationProvider {
name = "sip"; name = "sip";
/**
* Sends a SIP notification message.
* @param {object} notification - SIP notification configuration.
* @param {string} msg - The message content.
* @param {object | null} monitorJSON - The monitor data (if available).
* @param {object | null} heartbeatJSON - The heartbeat data (if available).
* @returns {Promise<string>} - Confirmation message if successful.
* @throws {Error} - If sending the SIP message fails.
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let monitorName = monitorJSON ? monitorJSON["name"] : "Unknown Monitor"; let monitorName = monitorJSON ? monitorJSON["name"] : "Unknown Monitor";
let subject = this.updateSubject(msg, monitorName); let body = "";
let body;
if (heartbeatJSON) { if (heartbeatJSON) {
body += `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; body += `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;
} }
try { try {
console.log("Sending SIP message:", { notification,
msg,
monitorName,
body });
return "SIP Message Sent Successfully."; return "SIP Message Sent Successfully.";
} catch (error) { } catch (error) {
console.error("Error sending SIP message:", error); console.error("Error sending SIP message:", error);
@ -17,44 +32,58 @@ class SIP extends NotificationProvider {
} }
} }
/**
* Generates a subject line based on the message content.
* @param {string} message - The incoming status message.
* @param {string} monitorName - The name of the monitored service.
* @returns {string} - The formatted subject line.
*/
updateSubject(message, monitorName) { updateSubject(message, monitorName) {
if (!message) return "Default Subject"; // Handle null/undefined message if (!message) {
return "Default Subject";
}
message = message.toLowerCase(); // Normalize input message = message.toLowerCase(); // Normalize input
if (/\bdown\b/i.test(message) || message.includes("offline")) { if (/\bdown\b/i.test(message) || message.includes("offline")) {
return `🚨 ❌ Service Impacted...`; return "🚨 ❌ Service Impacted...";
} }
if (/\bup\b/i.test(message) || message.includes("online")) { if (/\bup\b/i.test(message) || message.includes("online")) {
return `🚨 ✅ Service Restored...`; return "🚨 ✅ Service Restored...";
} }
if (message.includes("maintenance")) { if (message.includes("maintenance")) {
if (message.includes("begin")) { if (message.includes("begin")) {
return `🚧 🔧 ❌ Maintenance Start...`; return "🚧 🔧 ❌ Maintenance Start...";
} }
if (/\bend\b/i.test(message)) { if (/\bend\b/i.test(message)) {
return `🚧 🔧 ✅ Maintenance Complete...`; return "🚧 🔧 ✅ Maintenance Complete...";
} }
if (message.includes("scheduled")) { if (message.includes("scheduled")) {
return `🚧 🪟 📆 Maintenance Window Scheduled...`; return "🚧 🪟 📆 Maintenance Window Scheduled...";
} }
if (message.includes("window begin")) { if (message.includes("window begin")) {
return `🚧 🪟 🛑 Maintenance Window Start...`; return "🚧 🪟 🛑 Maintenance Window Start...";
} }
if (message.includes("window end")) { if (message.includes("window end")) {
return `🚧 🪟 ✅ Maintenance Window Complete...`; return "🚧 🪟 ✅ Maintenance Window Complete...";
} }
} }
if (message.includes("started on node")) { if (message.includes("started on node")) {
return `📈 🔬 ✅ Monitoring Start...`; return "📈 🔬 ✅ Monitoring Start...";
} }
if (message.includes("started")) { if (message.includes("started")) {
return `📈 🔬 ✅ ${monitorName}`; return `📈 🔬 ✅ ${monitorName}`;
} }
return "Default Subject"; return "Default Subject";
} }
/**
* Sends a SIP message using the provided notification configuration.
* @param {object} notification - SIP notification settings.
* @param {string} sipMessage - The message content to send.
* @returns {void}
*/
async sendSIPMessage(notification, sipMessage) { async sendSIPMessage(notification, sipMessage) {
console.log("Sending SIP message with config:", notification); console.log("Sending SIP message with config:", notification);
console.log("Message:", sipMessage); console.log("Message:", sipMessage);

View file

@ -33,8 +33,6 @@ const { Kafka, SASLOptions } = require("kafkajs");
const crypto = require("crypto"); const crypto = require("crypto");
let sip = require("sip"); let sip = require("sip");
const uuid = require("uuid"); const uuid = require("uuid");
let sharedSipServer;
const SERVER_PORT = 25060;
const isWindows = process.platform === /^win/.test(process.platform); const isWindows = process.platform === /^win/.test(process.platform);
/** /**
@ -266,23 +264,28 @@ exports.kafkaProducerAsync = function (brokers, topic, message, options = {}, sa
/** /**
* Sends a SIP REGISTER request * Sends a SIP REGISTER request
* @param {string} sipServer The SIP server to register with * @param {string} sipServer The SIP server to register with
* @param {number} sipPort The port of the SIP server
* @param {string} transport The transport protocol to use (e.g., 'udp' or 'tcp') * @param {string} transport The transport protocol to use (e.g., 'udp' or 'tcp')
* @returns {Promise<void>} * @param {string} username The username for registration
* @param {string} password The password for registration
* @param {string} version The version of the SIP health monitor
* @returns {Promise<object>} The response from the SIP REGISTER request
*/ */
exports.sipRegisterRequest = function (sipServer, sipPort, transport, username, password, version) { exports.sipRegisterRequest = function (sipServer, sipPort, transport, username, password, version) {
// eslint-disable-next-line no-async-promise-executor // eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
const registerRequest = { const registerRequest = {
method: 'REGISTER', method: "REGISTER",
uri: `sip:${sipServer}:${sipPort}`, uri: `sip:${sipServer}:${sipPort}`,
headers: { headers: {
to: { uri: `sip:${sipServer}:${sipPort}` }, to: { uri: `sip:${sipServer}:${sipPort}` },
from: { uri: `sip:${username}` }, from: { uri: `sip:${username}` },
'call-id': uuid.v4(), "call-id": uuid.v4(),
cseq: { method: 'REGISTER', seq: 1 }, cseq: { method: "REGISTER",
'content-length': 0, seq: 1 },
"content-length": 0,
contact: { uri: `sip:${username}` }, contact: { uri: `sip:${username}` },
"User-Agent": "SIP Health Monitor " + version, "User-Agent": "SIP Health Monitor " + version,
"Expires": 60, "Expires": 60,
@ -321,9 +324,16 @@ exports.sipRegister = function (registerRequest) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timeout = 5000; // Timeout duration in milliseconds const timeout = 5000; // Timeout duration in milliseconds
let timeoutID; let timeoutID;
// Cleanup function to clear the timeout and destroy the server // Cleanup function to ensure proper resource management
/**
* Clears the timeout and destroys the SIP server instance.
* This function is called to prevent memory leaks and ensure that no lingering processes are left running.
* @returns {void} This function does not return any value.
*/
function cleanup() { function cleanup() {
if (timeoutID) clearTimeout(timeoutID); if (timeoutID) {
clearTimeout(timeoutID);
}
if (server && server.destroy) { if (server && server.destroy) {
server.destroy(); server.destroy();
console.log("SIP server destroyed."); console.log("SIP server destroyed.");
@ -378,8 +388,12 @@ exports.constructAuthorizedRequest = function (request, username, password, prox
/** /**
* Sends a SIP OPTIONS request * Sends a SIP OPTIONS request
* @param {string} sipServer The SIP server to send OPTIONS to * @param {string} sipServer The SIP server to send OPTIONS to
* @param {number} sipPort The port of the SIP server
* @param {string} transport The transport protocol to use (e.g., 'udp' or 'tcp') * @param {string} transport The transport protocol to use (e.g., 'udp' or 'tcp')
* @returns {Promise<void>} * @param {string} username The username for authentication (optional)
* @param {string} password The password for authentication (optional)
* @param {string} version The version of the SIP Health Monitor
* @returns {Promise<object>} The response from the SIP OPTIONS request
*/ */
exports.sipOptionRequest = function (sipServer, sipPort, transport, username, password, version) { exports.sipOptionRequest = function (sipServer, sipPort, transport, username, password, version) {
const publicIP = process.env.PUBLIC_IP; const publicIP = process.env.PUBLIC_IP;
@ -387,28 +401,28 @@ exports.sipOptionRequest = function (sipServer, sipPort, transport, username, pa
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
const optionsRequest = { const optionsRequest = {
method: 'OPTIONS', method: "OPTIONS",
uri: `sip:${sipServer}:${sipPort}`,//hostname uri: `sip:${sipServer}:${sipPort}`, //hostname
headers: { headers: {
to: { uri: `sip:${sipServer}:${sipPort}` },//hostname to: { uri: `sip:${sipServer}:${sipPort}` }, //hostname
from: { uri: `sip:${publicIP}` },//live ip || primary url from: { uri: `sip:${publicIP}` }, //live ip || primary url
'call-id': 1234, "call-id": 1234,
cseq: { method: 'OPTIONS', seq: 1 }, cseq: { method: "OPTIONS",
'content-length': 0, seq: 1 },
contact: [ { uri: `sip:${publicIP}` }], "content-length": 0,
contact: [{ uri: `sip:${publicIP}` }],
"User-Agent": "SIP Health Monitor" + version, "User-Agent": "SIP Health Monitor" + version,
}, },
transport: transport, transport: transport,
}; };
let optionResponse let optionResponse;
if(!username) { if (!username) {
console.log("will only send ok") console.log("will only send ok");
const optionResponse = await exports.sipOption(optionsRequest); const optionResponse = await exports.sipOption(optionsRequest);
console.log("optionResponse", optionResponse); console.log("optionResponse", optionResponse);
resolve(optionResponse) resolve(optionResponse);
} } else {
else {
optionResponse = await exports.sipRegister(optionsRequest); optionResponse = await exports.sipRegister(optionsRequest);
console.log("optionResponse", optionResponse); console.log("optionResponse", optionResponse);
if (optionResponse.status === 407 && optionResponse.headers["proxy-authenticate"]) { if (optionResponse.status === 407 && optionResponse.headers["proxy-authenticate"]) {
@ -419,12 +433,12 @@ exports.sipOptionRequest = function (sipServer, sipPort, transport, username, pa
password, password,
proxyAuthenticateHeader proxyAuthenticateHeader
); );
const secondResponse = await exports.sipOption(authorizedOptionRequest); const secondResponse = await exports.sipOption(authorizedOptionRequest);
resolve(secondResponse); resolve(secondResponse);
} }
} }
} catch (error) { } catch (error) {
console.error("Error:", error.message); console.error("Error:", error.message);
reject(error); reject(error);
@ -439,18 +453,24 @@ exports.sipOption = function (optionsRequest) {
console.log("SIP server created:", server); console.log("SIP server created:", server);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timeout = 5000; // Timeout duration in milliseconds
let timeoutID; let timeoutID;
// Cleanup function to clear the timeout and destroy the server // Cleanup function to ensure proper resource management
/**
* Clears the timeout and destroys the SIP server instance.
* This function is called to prevent memory leaks and ensure that no lingering processes are left running.
* @returns {void} This function does not return any value.
*/
function cleanup() { function cleanup() {
if (timeoutID) clearTimeout(timeoutID); if (timeoutID) {
clearTimeout(timeoutID);
}
if (server) { if (server) {
server.destroy(); server.destroy();
console.log("SIP server destroyed."); console.log("SIP server destroyed.");
} }
} }
try { try {
// Send the SIP options request // Send the SIP options request
server.send(optionsRequest, (response) => { server.send(optionsRequest, (response) => {

View file

@ -1,12 +1,12 @@
import { PluginFunc, ConfigType } from 'dayjs/esm' import { PluginFunc, ConfigType } from "dayjs/esm";
declare const plugin: PluginFunc declare const plugin: PluginFunc;
export = plugin export = plugin
declare module 'dayjs/esm' { declare module "dayjs/esm" {
interface Dayjs { interface Dayjs {
tz(timezone?: string, keepLocalTime?: boolean): Dayjs tz(timezone?: string, keepLocalTime?: boolean): Dayjs
offsetName(type?: 'short' | 'long'): string | undefined offsetName(type?: "short" | "long"): string | undefined
} }
interface DayjsTimezone { interface DayjsTimezone {
@ -16,5 +16,5 @@ declare module 'dayjs/esm' {
setDefault(timezone?: string): void setDefault(timezone?: string): void
} }
const tz: DayjsTimezone const tz: DayjsTimezone;
} }

View file

@ -91,7 +91,7 @@
<option v-if="!$root.info.isContainer" value="tailscale-ping"> <option v-if="!$root.info.isContainer" value="tailscale-ping">
Tailscale Ping Tailscale Ping
</option> </option>
<option value="sip">SIP</option> <option value="sip">SIP</option>
</optgroup> </optgroup>
</select> </select>
<i18n-t v-if="monitor.type === 'rabbitmq'" keypath="rabbitmqHelpText" tag="div" class="form-text"> <i18n-t v-if="monitor.type === 'rabbitmq'" keypath="rabbitmqHelpText" tag="div" class="form-text">
@ -121,10 +121,10 @@
<!--SIP--> <!--SIP-->
<div v-if="monitor.type === 'sip'" class="my-3"> <div v-if="monitor.type === 'sip'" class="my-3">
<label for="sipprotocol" class="form-label">{{ $t("SipProtocol") }}</label> <label for="sipprotocol" class="form-label">{{ $t("SipProtocol") }}</label>
<select id="sipprotocol" class="form-select" required v-model="monitor.sipProtocol"> <select id="sipprotocol" v-model="monitor.sipProtocol" class="form-select" required>
<option value="UDP">UDP</option> <option value="UDP">UDP</option>
<option value="TCP">TCP</option> <option value="TCP">TCP</option>
<option value="TLS">TLS</option> <option value="TLS">TLS</option>
</select> </select>
</div> </div>
<!-- gRPC URL --> <!-- gRPC URL -->
@ -175,8 +175,10 @@
</div> </div>
<div v-if="monitor.type === 'sip'" class="my-3"> <div v-if="monitor.type === 'sip'" class="my-3">
<label for="sipport" class="form-label mt-3">{{ $t("SipPort") }}</label> <label for="sipport" class="form-label mt-3">{{ $t("SipPort") }}</label>
<input v-if="monitor.sipProtocol !== 'SRV'" id="sipport" type="number" class="form-control" <input
v-model="monitor.sipPort" placeholder="Enter SIP Port"> v-if="monitor.sipProtocol !== 'SRV'" id="sipport" v-model="monitor.sipPort" type="number"
class="form-control" placeholder="Enter SIP Port"
>
</div> </div>
<!-- Remote Browser --> <!-- Remote Browser -->
<div v-if="monitor.type === 'real-browser'" class="my-3"> <div v-if="monitor.type === 'real-browser'" class="my-3">
@ -637,7 +639,7 @@
<input id="expiry-notification" v-model="monitor.expiryNotification" class="form-check-input" type="checkbox" :disabled="monitor.ignoreTls"> <input id="expiry-notification" v-model="monitor.expiryNotification" class="form-check-input" type="checkbox" :disabled="monitor.ignoreTls">
<label class="form-check-label" for="expiry-notification"> <label class="form-check-label" for="expiry-notification">
{{ $t("Certificate Expiry Notification") }} {{ $t("Certificate Expiry Notification") }}
</label> </label>
<div class="form-text"> <div class="form-text">
</div> </div>
</div> </div>
@ -681,8 +683,8 @@
<label class="form-check-label" for="process-503-as-maintenance"> <label class="form-check-label" for="process-503-as-maintenance">
{{ $t("process503AsMaintenanceLabel") }} {{ $t("process503AsMaintenanceLabel") }}
</label> </label>
</div> </div>
<div v-if="monitor.type === 'gamedig'" class="my-3 form-check"> <div v-if="monitor.type === 'gamedig'" class="my-3 form-check">
<input id="gamedig-guess-port" v-model="monitor.gamedigGivenPortOnly" :true-value="false" :false-value="true" class="form-check-input" type="checkbox"> <input id="gamedig-guess-port" v-model="monitor.gamedigGivenPortOnly" :true-value="false" :false-value="true" class="form-check-input" type="checkbox">
<label class="form-check-label" for="gamedig-guess-port"> <label class="form-check-label" for="gamedig-guess-port">
@ -858,83 +860,91 @@
</div> </div>
</div> </div>
</template> </template>
<!-- SIP Options --> <!-- SIP Options -->
<template v-if="monitor.type === 'sip'
">
<h2 class="mt-5 mb-2">{{ $t("SIP Options") }}</h2>
<!-- Method --> <template
<div class="my-3"> v-if="monitor.type === 'sip'
<label for="method" class="form-label">{{ "
$t("Method") >
}}</label> <h2 class="mt-5 mb-2">{{ $t("SIP Options") }}</h2>
<select id="method" v-model="monitor.sipMethod" class="form-select">
<option value="REGISTER">REGISTER</option>
<option value="OPTIONS">OPTIONS</option>
</select>
</div>
<!-- Encoding --> <!-- Method -->
<div class="my-3"> <div class="my-3">
<label for="httpBodyEncoding" class="form-label">{{ <label for="method" class="form-label">{{
$t("Body Encoding") $t("Method")
}}</label> }}</label>
<select id="httpBodyEncoding" v-model="monitor.httpBodyEncoding" class="form-select"> <select id="method" v-model="monitor.sipMethod" class="form-select">
<option value="json">JSON</option> <option value="REGISTER">REGISTER</option>
<option value="xml">XML</option> <option value="OPTIONS">OPTIONS</option>
</select> </select>
</div> </div>
<!-- Body --> <!-- Encoding -->
<div class="my-3"> <div class="my-3">
<label for="body" class="form-label">{{ $t("Body") }}</label> <label for="httpBodyEncoding" class="form-label">{{
<textarea id="body" v-model="monitor.body" class="form-control" $t("Body Encoding")
:placeholder="bodyPlaceholder"></textarea> }}</label>
</div> <select id="httpBodyEncoding" v-model="monitor.httpBodyEncoding" class="form-select">
<option value="json">JSON</option>
<option value="xml">XML</option>
</select>
</div>
<!-- Headers --> <!-- Body -->
<div class="my-3"> <div class="my-3">
<label for="headers" class="form-label">{{ <label for="body" class="form-label">{{ $t("Body") }}</label>
$t("Headers") <textarea
}}</label> id="body" v-model="monitor.body" class="form-control"
<textarea id="headers" v-model="monitor.headers" class="form-control" :placeholder="bodyPlaceholder"
:placeholder="headersPlaceholder"></textarea> ></textarea>
</div> </div>
<!-- HTTP Auth --> <!-- Headers -->
<h4 class="mt-5 mb-2">{{ $t("Authentication") }}</h4> <div class="my-3">
<label for="headers" class="form-label">{{
$t("Headers")
}}</label>
<textarea
id="headers" v-model="monitor.headers" class="form-control"
:placeholder="headersPlaceholder"
></textarea>
</div>
<!-- Method --> <!-- HTTP Auth -->
<div class="my-3"> <h4 class="mt-5 mb-2">{{ $t("Authentication") }}</h4>
<label for="authmethod" class="form-label">{{
$t("Method")
}}</label>
<select id="authsipmethod" v-model="monitor.sipAuthMethod" class="form-select">
<option :value="null">
{{ $t("None") }}
</option>
<option value="basic">
{{ $t("SIP Basic Auth") }}
</option>
</select>
</div>
<template v-if="monitor.sipAuthMethod === 'basic'">
<div class="my-3">
<label for="basicauth-user" class="form-label">{{ $t("Username") }}</label>
<input id="basicauth-user" v-model="monitor.sip_basic_auth_user" type="text" class="form-control"
:placeholder="$t('Username')" />
</div>
<div class="my-3"> <!-- Method -->
<label for="basicauth-pass" class="form-label">{{ $t("Password") }}</label> <div class="my-3">
<input id="basicauth-pass" v-model="monitor.sip_basic_auth_pass" type="password" autocomplete="new-password" <label for="authmethod" class="form-label">{{
class="form-control" :placeholder="$t('Password')" /> $t("Method")
</div> }}</label>
</template> <select id="authsipmethod" v-model="monitor.sipAuthMethod" class="form-select">
</template> <option :value="null">
{{ $t("None") }}
</option>
<option value="basic">
{{ $t("SIP Basic Auth") }}
</option>
</select>
</div>
<template v-if="monitor.sipAuthMethod === 'basic'">
<div class="my-3">
<label for="basicauth-user" class="form-label">{{ $t("Username") }}</label>
<input
id="basicauth-user" v-model="monitor.sip_basic_auth_user" type="text" class="form-control"
:placeholder="$t('Username')"
/>
</div>
<div class="my-3">
<label for="basicauth-pass" class="form-label">{{ $t("Password") }}</label>
<input
id="basicauth-pass" v-model="monitor.sip_basic_auth_pass" type="password" autocomplete="new-password"
class="form-control" :placeholder="$t('Password')"
/>
</div>
</template>
</template>
<!-- HTTP Options --> <!-- HTTP Options -->
<template v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' "> <template v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' ">
<h2 class="mt-5 mb-2">{{ $t("HTTP Options") }}</h2> <h2 class="mt-5 mb-2">{{ $t("HTTP Options") }}</h2>
@ -1223,10 +1233,10 @@ const monitorDefaults = {
conditions: [], conditions: [],
sipProtocol: "UDP", sipProtocol: "UDP",
sipPort: 5060, sipPort: 5060,
sipUrl:null, sipUrl: null,
sipMethod: "OPTIONS", sipMethod: "OPTIONS",
sipMaintainence:false, sipMaintainence: false,
sipAuthMethod: null, sipAuthMethod: null,
}; };
export default { export default {