*Define new api to check ssl on boot and on demand

This commit is contained in:
Derrick Hammer 2022-09-21 07:31:29 -04:00
parent 2aa8300ec6
commit f4211342e1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 15 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import { overwriteRegistryEntry } from "libskynetnode";
import type { DnsProvider } from "@lumeweb/relay-types";
// @ts-ignore
import { hashDataKey } from "@lumeweb/kernel-utils";
import { getSslCheck } from "./ssl";
let activeIp: string;
const REGISTRY_NODE_KEY = "lumeweb-dht-node";
@ -52,6 +53,9 @@ export async function start() {
);
cron.schedule("0 * * * *", ipUpdate);
if (config.bool("ssl") && getSslCheck()) {
await getSslCheck()();
}
}
async function getCurrentIp(): Promise<string> {

View File

@ -10,6 +10,7 @@ import {
getSslContext,
saveSSl,
setSsl,
setSSlCheck,
setSslContext,
} from "./ssl.js";
import log from "loglevel";
@ -89,6 +90,7 @@ export class PluginApiManager {
set: setSsl,
get: getSsl,
save: saveSSl,
setCheck: setSSlCheck,
},
files: {
createIndependentFileSmall,

View File

@ -17,6 +17,7 @@ import type {
let sslCtx: tls.SecureContext = tls.createSecureContext();
let sslObject: SslData = {};
let sslChecker: () => Promise<void>;
const FILE_CERT_NAME = "/lumeweb/relay/ssl.crt";
const FILE_KEY_NAME = "/lumeweb/relay/ssl.key";
@ -134,3 +135,11 @@ async function getSslFile(
return file;
}
export function setSSlCheck(checker: () => Promise<void>): void {
sslChecker = checker;
}
export function getSslCheck(): () => Promise<void> {
return sslChecker;
}