*Remove dns module for now, will refactor this back later
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
b50b8e8ced
commit
480bfdd0d0
|
@ -4,7 +4,6 @@ import { start as startApp } from "./modules/app";
|
|||
import log from "loglevel";
|
||||
import config from "./config.js";
|
||||
import { loadPlugins } from "./modules/plugin.js";
|
||||
import { start as startDns } from "./modules/dns.js";
|
||||
import { start as startSSl } from "./modules/ssl.js";
|
||||
import { start as startSwarm } from "./modules/swarm.js";
|
||||
import * as bip39 from "@scure/bip39";
|
||||
|
@ -23,7 +22,6 @@ async function boot() {
|
|||
await loadPlugins();
|
||||
await startApp();
|
||||
await startRpc();
|
||||
await startDns();
|
||||
await startSSl();
|
||||
await startRelay();
|
||||
}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
import cron from "node-cron";
|
||||
import { get as getSwarm } from "./swarm.js";
|
||||
import { Buffer } from "buffer";
|
||||
import { pack } from "msgpackr";
|
||||
import config from "../config.js";
|
||||
import log from "loglevel";
|
||||
import fetch from "node-fetch";
|
||||
import { overwriteRegistryEntry } from "libskynetnode";
|
||||
import type { DnsProvider } from "@lumeweb/relay-types";
|
||||
// @ts-ignore
|
||||
import { hashDataKey } from "@lumeweb/kernel-utils";
|
||||
|
||||
let activeIp: string;
|
||||
const REGISTRY_NODE_KEY = "lumeweb-dht-node";
|
||||
|
||||
let dnsProvider: DnsProvider = async (ip) => {};
|
||||
|
||||
export function setDnsProvider(provider: DnsProvider) {
|
||||
dnsProvider = provider;
|
||||
}
|
||||
|
||||
async function ipUpdate() {
|
||||
let currentIp = await getCurrentIp();
|
||||
|
||||
if (activeIp && currentIp === activeIp) {
|
||||
return;
|
||||
}
|
||||
|
||||
const domain = config.str("domain");
|
||||
|
||||
await dnsProvider(currentIp, domain);
|
||||
|
||||
activeIp = currentIp;
|
||||
|
||||
log.info(`Updated DynDNS hostname ${domain} to ${activeIp}`);
|
||||
}
|
||||
|
||||
export async function start() {
|
||||
if (!config.str("domain")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const swarm = getSwarm();
|
||||
|
||||
await ipUpdate();
|
||||
|
||||
await overwriteRegistryEntry(
|
||||
swarm.dht.defaultKeyPair,
|
||||
hashDataKey(REGISTRY_NODE_KEY),
|
||||
pack(`${config.str("domain")}:${config.uint("port")}`)
|
||||
);
|
||||
|
||||
cron.schedule("0 * * * *", ipUpdate);
|
||||
}
|
||||
|
||||
async function getCurrentIp(): Promise<string> {
|
||||
return await (await fetch("http://ip1.dynupdate.no-ip.com/")).text();
|
||||
}
|
Loading…
Reference in New Issue