*Define new api to check ssl on boot and on demand
This commit is contained in:
parent
2aa8300ec6
commit
f4211342e1
|
@ -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> {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue