*Remove dns module for now, will refactor this back later
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Derrick Hammer 2022-12-18 14:44:39 -05:00
parent b50b8e8ced
commit 480bfdd0d0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 0 additions and 60 deletions

View File

@ -4,7 +4,6 @@ import { start as startApp } from "./modules/app";
import log from "loglevel"; import log from "loglevel";
import config from "./config.js"; import config from "./config.js";
import { loadPlugins } from "./modules/plugin.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 startSSl } from "./modules/ssl.js";
import { start as startSwarm } from "./modules/swarm.js"; import { start as startSwarm } from "./modules/swarm.js";
import * as bip39 from "@scure/bip39"; import * as bip39 from "@scure/bip39";
@ -23,7 +22,6 @@ async function boot() {
await loadPlugins(); await loadPlugins();
await startApp(); await startApp();
await startRpc(); await startRpc();
await startDns();
await startSSl(); await startSSl();
await startRelay(); await startRelay();
} }

View File

@ -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();
}