# Conflicts: # src/lang/en.jsonpull/3357/head
commit
7f68e4a987
@ -0,0 +1,90 @@
|
|||||||
|
#
|
||||||
|
# /etc/nscd.conf
|
||||||
|
#
|
||||||
|
# An example Name Service Cache config file. This file is needed by nscd.
|
||||||
|
#
|
||||||
|
# Legal entries are:
|
||||||
|
#
|
||||||
|
# logfile <file>
|
||||||
|
# debug-level <level>
|
||||||
|
# threads <initial #threads to use>
|
||||||
|
# max-threads <maximum #threads to use>
|
||||||
|
# server-user <user to run server as instead of root>
|
||||||
|
# server-user is ignored if nscd is started with -S parameters
|
||||||
|
# stat-user <user who is allowed to request statistics>
|
||||||
|
# reload-count unlimited|<number>
|
||||||
|
# paranoia <yes|no>
|
||||||
|
# restart-interval <time in seconds>
|
||||||
|
#
|
||||||
|
# enable-cache <service> <yes|no>
|
||||||
|
# positive-time-to-live <service> <time in seconds>
|
||||||
|
# negative-time-to-live <service> <time in seconds>
|
||||||
|
# suggested-size <service> <prime number>
|
||||||
|
# check-files <service> <yes|no>
|
||||||
|
# persistent <service> <yes|no>
|
||||||
|
# shared <service> <yes|no>
|
||||||
|
# max-db-size <service> <number bytes>
|
||||||
|
# auto-propagate <service> <yes|no>
|
||||||
|
#
|
||||||
|
# Currently supported cache names (services): passwd, group, hosts, services
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# logfile /var/log/nscd.log
|
||||||
|
# threads 4
|
||||||
|
# max-threads 32
|
||||||
|
# server-user node
|
||||||
|
# stat-user somebody
|
||||||
|
debug-level 0
|
||||||
|
# reload-count 5
|
||||||
|
paranoia no
|
||||||
|
# restart-interval 3600
|
||||||
|
|
||||||
|
enable-cache passwd no
|
||||||
|
positive-time-to-live passwd 600
|
||||||
|
negative-time-to-live passwd 20
|
||||||
|
suggested-size passwd 211
|
||||||
|
check-files passwd yes
|
||||||
|
persistent passwd yes
|
||||||
|
shared passwd yes
|
||||||
|
max-db-size passwd 33554432
|
||||||
|
auto-propagate passwd yes
|
||||||
|
|
||||||
|
enable-cache group no
|
||||||
|
positive-time-to-live group 3600
|
||||||
|
negative-time-to-live group 60
|
||||||
|
suggested-size group 211
|
||||||
|
check-files group yes
|
||||||
|
persistent group yes
|
||||||
|
shared group yes
|
||||||
|
max-db-size group 33554432
|
||||||
|
auto-propagate group yes
|
||||||
|
|
||||||
|
enable-cache hosts yes
|
||||||
|
positive-time-to-live hosts 3600
|
||||||
|
negative-time-to-live hosts 20
|
||||||
|
suggested-size hosts 211
|
||||||
|
check-files hosts yes
|
||||||
|
persistent hosts yes
|
||||||
|
# Set shared to "no" to display stats in `nscd -g`
|
||||||
|
# Read more: https://stackoverflow.com/questions/40429245/nscdcentos7curl-0-dns-cache-hit-rate
|
||||||
|
shared hosts no
|
||||||
|
max-db-size hosts 33554432
|
||||||
|
|
||||||
|
enable-cache services no
|
||||||
|
positive-time-to-live services 28800
|
||||||
|
negative-time-to-live services 20
|
||||||
|
suggested-size services 211
|
||||||
|
check-files services yes
|
||||||
|
persistent services yes
|
||||||
|
shared services yes
|
||||||
|
max-db-size services 33554432
|
||||||
|
|
||||||
|
enable-cache netgroup no
|
||||||
|
positive-time-to-live netgroup 28800
|
||||||
|
negative-time-to-live netgroup 20
|
||||||
|
suggested-size netgroup 211
|
||||||
|
check-files netgroup yes
|
||||||
|
persistent netgroup yes
|
||||||
|
shared netgroup yes
|
||||||
|
max-db-size netgroup 33554432
|
@ -0,0 +1,31 @@
|
|||||||
|
#
|
||||||
|
# This file MUST be edited with the 'visudo' command as root.
|
||||||
|
#
|
||||||
|
# Please consider adding local content in /etc/sudoers.d/ instead of
|
||||||
|
# directly modifying this file.
|
||||||
|
#
|
||||||
|
# See the man page for details on how to write a sudoers file.
|
||||||
|
#
|
||||||
|
Defaults env_reset
|
||||||
|
Defaults mail_badpass
|
||||||
|
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
|
# Host alias specification
|
||||||
|
|
||||||
|
# User alias specification
|
||||||
|
|
||||||
|
# Cmnd alias specification
|
||||||
|
|
||||||
|
# User privilege specification
|
||||||
|
root ALL=(ALL:ALL) ALL
|
||||||
|
|
||||||
|
# Allow members of group sudo to execute any command
|
||||||
|
%sudo ALL=(ALL:ALL) ALL
|
||||||
|
|
||||||
|
# See sudoers(5) for more information on "#include" directives:
|
||||||
|
|
||||||
|
#includedir /etc/sudoers.d
|
||||||
|
|
||||||
|
# Allow `node` to control service (mainly for nscd)
|
||||||
|
node ALL=(root) NOPASSWD: /usr/sbin/nscdservice
|
||||||
|
node ALL=(root) NOPASSWD: /usr/sbin/service
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,95 @@
|
|||||||
|
const { MonitorType } = require("./monitor-type");
|
||||||
|
const { UP, log } = require("../../src/util");
|
||||||
|
const exec = require("child_process").exec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A TailscalePing class extends the MonitorType.
|
||||||
|
* It runs Tailscale ping to monitor the status of a specific node.
|
||||||
|
*/
|
||||||
|
class TailscalePing extends MonitorType {
|
||||||
|
|
||||||
|
name = "tailscale-ping";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the ping status of the URL associated with the monitor.
|
||||||
|
* It then parses the Tailscale ping command output to update the heatrbeat.
|
||||||
|
*
|
||||||
|
* @param {Object} monitor - The monitor object associated with the check.
|
||||||
|
* @param {Object} heartbeat - The heartbeat object to update.
|
||||||
|
* @throws Will throw an error if checking Tailscale ping encounters any error
|
||||||
|
*/
|
||||||
|
async check(monitor, heartbeat) {
|
||||||
|
try {
|
||||||
|
let tailscaleOutput = await this.runTailscalePing(monitor.hostname, monitor.interval);
|
||||||
|
this.parseTailscaleOutput(tailscaleOutput, heartbeat);
|
||||||
|
} catch (err) {
|
||||||
|
log.debug("Tailscale", err);
|
||||||
|
// trigger log function somewhere to display a notification or alert to the user (but how?)
|
||||||
|
throw new Error(`Error checking Tailscale ping: ${err}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the Tailscale ping command to the given URL.
|
||||||
|
*
|
||||||
|
* @param {string} hostname - The hostname to ping.
|
||||||
|
* @returns {Promise<string>} - A Promise that resolves to the output of the Tailscale ping command
|
||||||
|
* @throws Will throw an error if the command execution encounters any error.
|
||||||
|
*/
|
||||||
|
async runTailscalePing(hostname, interval) {
|
||||||
|
let cmd = `tailscale ping ${hostname}`;
|
||||||
|
|
||||||
|
log.debug("Tailscale", cmd);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let timeout = interval * 1000 * 0.8;
|
||||||
|
exec(cmd, { timeout: timeout }, (error, stdout, stderr) => {
|
||||||
|
// we may need to handle more cases if tailscale reports an error that isn't necessarily an error (such as not-logged in or DERP health-related issues)
|
||||||
|
if (error) {
|
||||||
|
reject(`Execution error: ${error.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
reject(`Error in output: ${stderr}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(stdout);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the output of the Tailscale ping command to update the heartbeat.
|
||||||
|
*
|
||||||
|
* @param {string} tailscaleOutput - The output of the Tailscale ping command.
|
||||||
|
* @param {Object} heartbeat - The heartbeat object to update.
|
||||||
|
* @throws Will throw an eror if the output contains any unexpected string.
|
||||||
|
*/
|
||||||
|
parseTailscaleOutput(tailscaleOutput, heartbeat) {
|
||||||
|
let lines = tailscaleOutput.split("\n");
|
||||||
|
|
||||||
|
for (let line of lines) {
|
||||||
|
if (line.includes("pong from")) {
|
||||||
|
heartbeat.status = UP;
|
||||||
|
let time = line.split(" in ")[1].split(" ")[0];
|
||||||
|
heartbeat.ping = parseInt(time);
|
||||||
|
heartbeat.msg = line;
|
||||||
|
break;
|
||||||
|
} else if (line.includes("timed out")) {
|
||||||
|
throw new Error(`Ping timed out: "${line}"`);
|
||||||
|
// Immediately throws upon "timed out" message, the server is expected to re-call the check function
|
||||||
|
} else if (line.includes("no matching peer")) {
|
||||||
|
throw new Error(`Nonexistant or inaccessible due to ACLs: "${line}"`);
|
||||||
|
} else if (line.includes("is local Tailscale IP")) {
|
||||||
|
throw new Error(`Tailscale only works if used on other machines: "${line}"`);
|
||||||
|
} else if (line !== "") {
|
||||||
|
throw new Error(`Unexpected output: "${line}"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
TailscalePing,
|
||||||
|
};
|
@ -0,0 +1,119 @@
|
|||||||
|
const { log } = require("../../src/util");
|
||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const {
|
||||||
|
relayInit,
|
||||||
|
getPublicKey,
|
||||||
|
getEventHash,
|
||||||
|
getSignature,
|
||||||
|
nip04,
|
||||||
|
nip19
|
||||||
|
} = require("nostr-tools");
|
||||||
|
|
||||||
|
// polyfills for node versions
|
||||||
|
const semver = require("semver");
|
||||||
|
const nodeVersion = process.version;
|
||||||
|
if (semver.lt(nodeVersion, "16.0.0")) {
|
||||||
|
log.warn("monitor", "Node <= 16 is unsupported for nostr, sorry :(");
|
||||||
|
} else if (semver.lt(nodeVersion, "18.0.0")) {
|
||||||
|
// polyfills for node 16
|
||||||
|
global.crypto = require("crypto");
|
||||||
|
global.WebSocket = require("isomorphic-ws");
|
||||||
|
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
|
||||||
|
crypto.subtle = crypto.webcrypto.subtle;
|
||||||
|
}
|
||||||
|
} else if (semver.lt(nodeVersion, "20.0.0")) {
|
||||||
|
// polyfills for node 18
|
||||||
|
global.crypto = require("crypto");
|
||||||
|
global.WebSocket = require("isomorphic-ws");
|
||||||
|
} else {
|
||||||
|
// polyfills for node 20
|
||||||
|
global.WebSocket = require("isomorphic-ws");
|
||||||
|
}
|
||||||
|
|
||||||
|
class Nostr extends NotificationProvider {
|
||||||
|
name = "nostr";
|
||||||
|
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
// All DMs should have same timestamp
|
||||||
|
const createdAt = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
|
const senderPrivateKey = await this.getPrivateKey(notification.sender);
|
||||||
|
const senderPublicKey = getPublicKey(senderPrivateKey);
|
||||||
|
const recipientsPublicKeys = await this.getPublicKeys(notification.recipients);
|
||||||
|
|
||||||
|
// Create NIP-04 encrypted direct message event for each recipient
|
||||||
|
const events = [];
|
||||||
|
for (const recipientPublicKey of recipientsPublicKeys) {
|
||||||
|
const ciphertext = await nip04.encrypt(senderPrivateKey, recipientPublicKey, msg);
|
||||||
|
let event = {
|
||||||
|
kind: 4,
|
||||||
|
pubkey: senderPublicKey,
|
||||||
|
created_at: createdAt,
|
||||||
|
tags: [[ "p", recipientPublicKey ]],
|
||||||
|
content: ciphertext,
|
||||||
|
};
|
||||||
|
event.id = getEventHash(event);
|
||||||
|
event.sig = getSignature(event, senderPrivateKey);
|
||||||
|
events.push(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Publish events to each relay
|
||||||
|
const relays = notification.relays.split("\n");
|
||||||
|
let successfulRelays = 0;
|
||||||
|
|
||||||
|
// Connect to each relay
|
||||||
|
for (const relayUrl of relays) {
|
||||||
|
const relay = relayInit(relayUrl);
|
||||||
|
try {
|
||||||
|
await relay.connect();
|
||||||
|
successfulRelays++;
|
||||||
|
|
||||||
|
// Publish events
|
||||||
|
for (const event of events) {
|
||||||
|
relay.publish(event);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
continue;
|
||||||
|
} finally {
|
||||||
|
relay.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Report success or failure
|
||||||
|
if (successfulRelays === 0) {
|
||||||
|
throw Error("Failed to connect to any relays.");
|
||||||
|
}
|
||||||
|
return `${successfulRelays}/${relays.length} relays connected.`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPrivateKey(sender) {
|
||||||
|
try {
|
||||||
|
const senderDecodeResult = await nip19.decode(sender);
|
||||||
|
const { data } = senderDecodeResult;
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to get private key: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPublicKeys(recipients) {
|
||||||
|
const recipientsList = recipients.split("\n");
|
||||||
|
const publicKeys = [];
|
||||||
|
for (const recipient of recipientsList) {
|
||||||
|
try {
|
||||||
|
const recipientDecodeResult = await nip19.decode(recipient);
|
||||||
|
const { type, data } = recipientDecodeResult;
|
||||||
|
if (type === "npub") {
|
||||||
|
publicKeys.push(data);
|
||||||
|
} else {
|
||||||
|
throw new Error("not an npub");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Error decoding recipient: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return publicKeys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Nostr;
|
@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nostr-relays" class="form-label">{{ $t("nostrRelays") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<textarea id="nostr-relays" v-model="$parent.notification.relays" class="form-control" :required="true" placeholder="wss://127.0.0.1:7777/"></textarea>
|
||||||
|
<small class="form-text text-muted">{{ $t("nostrRelaysHelp") }}</small>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nostr-sender" class="form-label">{{ $t("nostrSender") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<HiddenInput id="nostr-sender" v-model="$parent.notification.sender" autocomplete="new-password" :required="true"></HiddenInput>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nostr-recipients" class="form-label">{{ $t("nostrRecipients") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<textarea id="nostr-recipients" v-model="$parent.notification.recipients" class="form-control" :required="true" placeholder="npub123... npub789..."></textarea>
|
||||||
|
<small class="form-text text-muted">{{ $t("nostrRecipientsHelp") }}</small>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
HiddenInput,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,10 @@
|
|||||||
|
FROM debian:buster-slim
|
||||||
|
|
||||||
|
# Test invalid node version, these commands install nodejs 10
|
||||||
|
# RUN apt-get update
|
||||||
|
# RUN apt --yes install nodejs
|
||||||
|
# RUN ln -s /usr/bin/nodejs /usr/bin/node
|
||||||
|
# RUN node -v
|
||||||
|
|
||||||
|
COPY ./install.sh .
|
||||||
|
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
@ -1,4 +1,4 @@
|
|||||||
FROM centos:8
|
FROM rockylinux:9
|
||||||
|
|
||||||
COPY ./install.sh .
|
COPY ./install.sh .
|
||||||
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
@ -1,10 +1,9 @@
|
|||||||
FROM ubuntu:16.04
|
FROM ubuntu:16.04
|
||||||
RUN apt-get update
|
|
||||||
RUN apt --yes install curl
|
|
||||||
|
|
||||||
# Test invalid node version, these commands install nodejs 10
|
# Test invalid node version, these commands install nodejs 10
|
||||||
#RUN apt --yes install nodejs
|
#RUN apt --yes install nodejs
|
||||||
# RUN ln -s /usr/bin/nodejs /usr/bin/node
|
# RUN ln -s /usr/bin/nodejs /usr/bin/node
|
||||||
# RUN node -v
|
# RUN node -v
|
||||||
|
|
||||||
RUN curl -o kuma_install.sh http://git.kuma.pet/install.sh && bash kuma_install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
COPY ./install.sh .
|
||||||
|
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
|
COPY ./install.sh .
|
||||||
|
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
@ -1,10 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
WORKDIR /app
|
|
||||||
RUN apt update && apt --yes install git curl
|
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
|
|
||||||
RUN apt --yes install nodejs
|
|
||||||
RUN git clone https://github.com/louislam/uptime-kuma.git .
|
|
||||||
RUN npm run setup
|
|
||||||
|
|
||||||
# Option 1. Try it
|
|
||||||
RUN node server/server.js
|
|
Loading…
Reference in new issue