diff --git a/Dockerfile b/Dockerfile index 75da340cb..47947a410 100644 --- a/Dockerfile +++ b/Dockerfile @@ -158,15 +158,10 @@ WORKDIR /usr/src/app # TODO: consider moving all these binaries to the build-binaries stage RUN apk add --no-cache bind-dev xz libltdl miniupnpc zip unzip dbus bind avahi-tools -# Copy docker -COPY docker/rndc.conf /etc/bind/ -COPY docker/update_local_dyndns.sh /usr/local/bin/update_local_dyndns - # Copy git data COPY --from=git-data /usr/src/app/.git-data.json $GIT_DATA_PATH # Copy binaries -COPY --from=build-binaries /usr/bin/nsupdate /usr/bin/nsupdate COPY --from=build-binaries /usr/bin/docker /usr/bin/docker COPY --from=build-binaries /usr/local/bin/docker-compose /usr/local/bin/docker-compose diff --git a/Dockerfile.dev b/Dockerfile.dev index 92a69328c..f59345274 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -139,24 +139,16 @@ ENV REACT_APP_API_URL / RUN yarn build # Results in build/* -# Copy docker -COPY docker/rndc.conf /etc/bind/ -COPY docker/update_local_dyndns.sh /usr/local/bin/update_local_dyndns - # Copy git data COPY --from=git-data /usr/src/app/.git-data.json $GIT_DATA_PATH # Copy binaries -COPY --from=build-binaries /usr/bin/nsupdate /usr/bin/nsupdate COPY --from=build-binaries /usr/bin/docker /usr/bin/docker COPY --from=build-binaries /usr/local/bin/docker-compose /usr/local/bin/docker-compose # Copy the src last as it's the layer most likely to change COPY packages/hostScripts/hostScripts /usr/src/app/hostScripts -COPY docker/rndc.conf /etc/bind/ -COPY docker/update_local_dyndns.sh /usr/local/bin/update_local_dyndns - WORKDIR /app COPY docker/start_dev.sh /usr/src/app/start_dev.sh ENTRYPOINT [ "/usr/src/app/start_dev.sh" ] \ No newline at end of file diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index d22423959..0d97fc1da 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -26,7 +26,6 @@ services: - ETH_MAINNET_RPC_URL_REMOTE= - IPFS_HOST= - DISABLE_UPNP= - dns: 172.33.1.2 networks: dncore_network: ipv4_address: 172.33.1.7 diff --git a/docker-compose.yml b/docker-compose.yml index fc245516a..c02ed6b21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,6 @@ services: - ETH_MAINNET_RPC_URL_REMOTE= - IPFS_HOST= - DISABLE_UPNP= - dns: 172.33.1.2 networks: dncore_network: ipv4_address: 172.33.1.7 diff --git a/docker/rndc.conf b/docker/rndc.conf deleted file mode 100644 index c6f3aa313..000000000 --- a/docker/rndc.conf +++ /dev/null @@ -1,12 +0,0 @@ -# Start of rndc.conf -key "rndc-key" { - algorithm hmac-sha256; - secret "8iFQ835rdmRdxEJaIFIJDpata5mL6kYFncd6F9Mn150="; -}; - -options { - default-key "rndc-key"; - default-server 172.33.1.2; - default-port 953; -}; -# End of rndc.conf \ No newline at end of file diff --git a/packages/dappmanager/src/daemons/index.ts b/packages/dappmanager/src/daemons/index.ts index a70025faa..bff4afc8f 100644 --- a/packages/dappmanager/src/daemons/index.ts +++ b/packages/dappmanager/src/daemons/index.ts @@ -4,7 +4,6 @@ import { startDynDnsDaemon } from "./dyndns/index.js"; import { startEthMultiClientDaemon } from "./ethMultiClient/index.js"; import { startEthicalMetricsDaemon } from "./ethicalMetrics/index.js"; import { startNatRenewalDaemon } from "./natRenewal/index.js"; -import { startNsUpdateDaemon } from "./nsupdate/index.js"; import { startStakerDaemon } from "./stakerConfig/index.js"; import { startTelegramBotDaemon } from "./telegramBot/index.js"; @@ -15,7 +14,6 @@ export function startDaemons(signal: AbortSignal): void { startEthMultiClientDaemon(signal); startEthicalMetricsDaemon(signal); startNatRenewalDaemon(signal); - startNsUpdateDaemon(signal); startStakerDaemon(); startTelegramBotDaemon(); } diff --git a/packages/dappmanager/src/daemons/nsupdate/index.ts b/packages/dappmanager/src/daemons/nsupdate/index.ts deleted file mode 100644 index a5977c0cc..000000000 --- a/packages/dappmanager/src/daemons/nsupdate/index.ts +++ /dev/null @@ -1,84 +0,0 @@ -import retry from "async-retry"; -import { eventBus } from "@dappnode/eventbus"; -import * as db from "@dappnode/db"; -import { params } from "@dappnode/params"; -import { listPackageContainers } from "@dappnode/dockerapi"; -import { getNsupdateTxts, execNsupdate } from "../../modules/nsupdate/index.js"; -import { runAtMostEveryIntervals } from "../../utils/asyncFlows.js"; -import { logs } from "@dappnode/logger"; - -const nsupdateInterval = params.NSUPDATE_DAEMON_INTERVAL || 60 * 60 * 1000; -let firstRun = true; - -async function runNsupdate({ - dnpNames, - removeOnly -}: { - dnpNames?: string[]; - removeOnly?: boolean; -}): Promise { - try { - const containers = await listPackageContainers(); - - // Load domain alias from db - const domainAliases = { - fullnode: db.fullnodeDomainTarget.get() - }; - - const nsupdateTxts = getNsupdateTxts({ - containers, - domainAliases, - dnpNames, - removeOnly - }); - - for (const nsupdateTxt of nsupdateTxts) - await retry(() => execNsupdate(nsupdateTxt)); - - if (dnpNames) { - if (removeOnly) logs.info("nsupdate delete", dnpNames); - else logs.info("nsupdate add", dnpNames); - } else if (firstRun) { - logs.info(`Successful initial nsupdate call for all DNPs`); - firstRun = false; - } - } catch (e) { - logs.error("Error on nsupdate interval", e); - } -} - -/** - * nsupdate daemon. - * Makes sure all package domains are mapped to their current IP - */ -export function startNsUpdateDaemon(signal: AbortSignal): void { - eventBus.packagesModified.on(({ dnpNames, removed }) => { - if (dnpNames.includes(params.bindDnpName)) { - // When the BIND is re-created, run nsupdate on all domains. Wait 5s to be active - setTimeout(() => runNsupdate({}), 5000); - } else { - // React immediatelly to new installs - if (removed) runNsupdate({ dnpNames, removeOnly: true }); - else runNsupdate({ dnpNames }); - } - }); - - // Every interval - runAtMostEveryIntervals( - async () => runNsupdate({}), - [ - // There may be a race condition between the DAPPMANAGER and the BIND - // On an update, if the DAPPMANAGER restarts first and then the BIND, - // there might be a potential window of `nsupdateInterval` hasn't applied - // the dynamic nsupdates provided by the DAPPMANAGER - // Since doing an nsupdate is cheap this increase in refresh frequency - // after a restart wants to prevents a potential issue by the race condition - 1 * 60 * 1000, // 1 min - 5 * 60 * 1000, // 5 min - nsupdateInterval / 4, // 15 min - nsupdateInterval / 2, // 30 min - nsupdateInterval // 60 min - ], - signal - ); -} diff --git a/packages/dappmanager/src/initializeDb.ts b/packages/dappmanager/src/initializeDb.ts index 65fadaf5b..ea66f07f4 100644 --- a/packages/dappmanager/src/initializeDb.ts +++ b/packages/dappmanager/src/initializeDb.ts @@ -11,7 +11,6 @@ import getPublicIpFromUrls from "./utils/getPublicIpFromUrls.js"; import { params } from "@dappnode/params"; import ping from "./utils/ping.js"; import { pause } from "./utils/asyncFlows.js"; -import retry from "async-retry"; import { shell } from "@dappnode/utils"; import { IdentityInterface } from "@dappnode/common"; import { logs } from "@dappnode/logger"; @@ -171,7 +170,7 @@ export default async function initializeDb(): Promise { // and the external IP from UPnP command succeeded const upnpAvailable = Boolean(publicIp && externalIp && internalIp !== publicIp) && - (await isUpnpAvailable()) + (await isUpnpAvailable()) ? true : false; @@ -211,33 +210,6 @@ export default async function initializeDb(): Promise { // - Updates the domain: db.domain.set(domain); dyndns.generateKeys(); // Auto-checks if keys are already generated - /** - * Set the domain of this DAppNode to point to the internal IP for better UX - * on Wifi connections, only if the internal IP !== public IP - * MUST be run after key generation `dyndns.generateKeys()` - * NOTE: Runs as a forked process with retry and a try / catch block - * > update_local_dyndns abcd1234abcd1234.dyndns.dappnode.io 192.168.1.12 - */ - try { - await retry(async function updateLocalDyndnsCall(): Promise { - const domain = db.domain.get(); - const publicIp = db.publicIp.get(); - const internalIp = db.internalIp.get(); - if (internalIp !== publicIp && internalIp && domain) { - try { - await shell(`update_local_dyndns ${domain} ${internalIp}`); - logs.info(`Updated local dyndns: ${domain} ${internalIp}`); - } catch (e) { - // Log the error in each attempt for transparency / debugging - logs.warn(`Error on updateLocalDyndns attempt: ${e.message}`); - throw e; - } - } - }); - } catch (e) { - logs.error("Error on update local dyndns", e); - } - /** * After initializing all the internal params (hostname, internal_ip, etc) * Persist them to the global ENVs file so other packages can consume it diff --git a/packages/dappmanager/src/modules/ethClient/apiUrl.ts b/packages/dappmanager/src/modules/ethClient/apiUrl.ts index 4c5befdd2..d65b6bab8 100644 --- a/packages/dappmanager/src/modules/ethClient/apiUrl.ts +++ b/packages/dappmanager/src/modules/ethClient/apiUrl.ts @@ -9,7 +9,6 @@ import { listPackageNoThrow } from "@dappnode/dockerapi"; */ export function getEthExecClientApiUrl(dnpName: string, port = 8545): string { /** - * Binded to the domain mapper module 'nsupdate' * ``` * domain = "bitcoin.dappnode", "other.public.dappnode" * ``` diff --git a/packages/dappmanager/src/modules/nsupdate/execNsupdate.ts b/packages/dappmanager/src/modules/nsupdate/execNsupdate.ts deleted file mode 100644 index 57e120673..000000000 --- a/packages/dappmanager/src/modules/nsupdate/execNsupdate.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { exec } from "child_process"; - -/** - * Calls `nsupdate` and passes the contents of an nsupdate via stdin - * - * @param nsupdateTxt nsupdate.txt contents - * - * server 172.33.1.2 - * debug yes - * zone dappnode. - * update delete bitcoin.dappnode A - * update add bitcoin.dappnode 60 A 172.33.0.2 - * update delete monero.dappnode A - * update add monero.dappnode 60 A 172.33.0.3 - * show - * send - */ -export function execNsupdate(nsupdateTxt: string): Promise { - return new Promise((resolve, reject): void => { - const child = exec("nsupdate -v", (error, stdout, stderr) => { - if (error) reject(error); - else resolve(stdout || stderr); - }); - - if (!child.stdin) - return reject(Error("Process has no stdin stream available")); - - child.stdin.write(nsupdateTxt); - child.stdin.end(); // this call seems necessary, at least with plain node.js executable - }); -} diff --git a/packages/dappmanager/src/modules/nsupdate/index.ts b/packages/dappmanager/src/modules/nsupdate/index.ts deleted file mode 100644 index 3ebd1dbe7..000000000 --- a/packages/dappmanager/src/modules/nsupdate/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./execNsupdate.js"; -export * from "./utils.js"; diff --git a/packages/dappmanager/src/modules/nsupdate/utils.ts b/packages/dappmanager/src/modules/nsupdate/utils.ts deleted file mode 100644 index f0fac5cee..000000000 --- a/packages/dappmanager/src/modules/nsupdate/utils.ts +++ /dev/null @@ -1,204 +0,0 @@ -import { isEmpty } from "lodash-es"; -import { ContainerNames, PackageContainer } from "@dappnode/common"; -import { params } from "@dappnode/params"; -import { getContainerDomain } from "@dappnode/types"; -import { buildNetworkAlias, removeUnderscores } from "@dappnode/utils"; - -const TTL = 60; -const ethZone = "eth."; -const dappnodeZone = "dappnode."; - -interface DomainMap { - [domain: string]: string; // ip -} - -interface PackageContainerWithIp extends PackageContainer { - ip: string; -} - -interface AliasMap { - [domainAlias: string]: string; // dnpName -} - -/** - * Rules for allowing or forbidding alias requested by the packages - * @param alias "fullnode" - * @param dnp Package object - */ -function isAliasAllowed(alias: string, dnp: PackageContainerWithIp): boolean { - // For now only allow known aliases - switch (alias) { - case "fullnode": - // Only allow "fullnode" if the package declares itself as an ethereum node - return dnp.chain === "ethereum"; - } - return false; -} - -/** - * Constructs a nsupdate.txt file contents - * - * @param domains [ - * { domain: "bitcoin.dappnode", ip: "172.33.0.2" }, - * { domain: "monero.dappnode", ip: "172.33.0.3" } - * ] - * @param zone "dappnode." - * @returns nsupdate.txt contents - * - * server 172.33.1.2 - * debug yes - * zone dappnode. - * update delete bitcoin.dappnode A - * update add bitcoin.dappnode 60 A 172.33.0.2 - * update delete monero.dappnode A - * update add monero.dappnode 60 A 172.33.0.3 - * show - * send - */ -function getNsupdateTxt( - domains: DomainMap, - zone: string, - removeOnly: boolean -): string { - const nsupdateInstructions = Object.entries(domains) - .map(([domain, ip]) => { - const rm = `update delete ${domain} A`; - const add = `update add ${domain} ${TTL} A ${ip}`; - return removeOnly ? rm : [rm, add].join("\n"); - }) - .join("\n"); - - return ` -server 172.33.1.2 -debug yes -zone ${zone} -${nsupdateInstructions} -show -send -`.trim(); -} - -/** - * @param name "bitcoin.dnp.dappnode.eth" - * @returns "my.bitcoin.dnp.dappnode.eth" - */ -export function getMyDotEthdomain(dnpName: string): string { - return "my." + removeUnderscores(dnpName); -} - -/** - * @param name "bitcoin.dnp.dappnode.eth" - * @returns "bitcoin" - * - "bitcoin.dnp.dappnode.eth" > "bitcoin.dappnode" - * - "other.public.dappnode.eth" > "other.public.dappnode" - */ -export function getDotDappnodeDomain( - container: ContainerNames, - isMainOrMonoservice: boolean -): string { - const { dnpName, serviceName } = container; - return buildNetworkAlias({ - dnpName, - serviceName, - isMainOrMonoservice - }); -} - -/** - * @param alias "fullnode" - * @returns "fullnode.dappnode" - */ -function aliasToDappnodeDomain(alias: string): string { - return alias + ".dappnode"; -} - -/** - * Returns an array of nsupdate.txt files ready for nsupdate - * If no update must happen, it returns an empty array - * - * Note: This call is abstracted for testability - */ -export function getNsupdateTxts({ - containers, - domainAliases, - dnpNames, - removeOnly = false -}: { - containers: PackageContainer[]; - domainAliases: AliasMap; - dnpNames?: string[]; - removeOnly?: boolean; -}): string[] { - const containersToUpdate: PackageContainerWithIp[] = []; - // `dnp.ip` = Necessary to satisfy the typscript compiler - for (const container of containers) - if ( - container.ip && - container.isDnp && - (!dnpNames || !dnpNames.length || dnpNames.includes(container.dnpName)) - ) - containersToUpdate.push({ ...container, ip: container.ip }); - - if (!containersToUpdate.length) return []; - - const eth: DomainMap = {}; - const dappnode: DomainMap = {}; - - // Add domains from installed package names - - // container can have the following states: - // 1: monoservice => short + full alias - // 2: multiservice && !isMain => full alias - // 3: multiservice && isMain => short + full alias - - for (const container of containersToUpdate) { - const fullEns = getContainerDomain(container); - eth[getMyDotEthdomain(fullEns)] = container.ip; - - // it used to return sometimes the full alias and sometimes the short alias. - // we need to know if container is mono or multiservice, but "isMain" can be undefined - dappnode[getDotDappnodeDomain(container, false)] = container.ip; - - // Add multilabel IPFS domains to the IPFS container IP - if (container.dnpName === params.ipfsDnpName) { - dappnode[`*.${getDotDappnodeDomain(container, true)}`] = container.ip; - } - - // For multi-service DNPs, link the main container to the root URL - if (container.isMain) { - const rootNames = { - dnpName: container.dnpName, - serviceName: container.dnpName - }; - eth[getMyDotEthdomain(getContainerDomain(rootNames))] = container.ip; - //this is okay, we always wanted to return the full alias here - dappnode[getDotDappnodeDomain(container, true)] = container.ip; - } - } - - // Add dappnode domain alias from installed packages - for (const container of containersToUpdate) - if (container.domainAlias) - for (const alias of container.domainAlias) - if (isAliasAllowed(alias, container)) - dappnode[aliasToDappnodeDomain(alias)] = container.ip; - - // Add .dappnode domain alias from db (such as fullnode.dappnode) - for (const [alias, dnpName] of Object.entries(domainAliases)) { - const container = containersToUpdate.find( - c => dnpName && c.dnpName === dnpName - ); - if (container) dappnode[aliasToDappnodeDomain(alias)] = container.ip; - } - - return ( - [ - { zone: ethZone, domains: eth }, - { zone: dappnodeZone, domains: dappnode } - ] - // Only process zones that have domains / entries - .filter(({ domains }) => !isEmpty(domains)) - // Convert domain maps to nsupdate txts - .map(({ zone, domains }) => getNsupdateTxt(domains, zone, removeOnly)) - ); -} diff --git a/packages/dappmanager/test/integration/migrations/composeMigration.test.int.ts b/packages/dappmanager/test/integration/migrations/composeMigration.test.int.ts index 6a1d05c5b..1f2b61c23 100644 --- a/packages/dappmanager/test/integration/migrations/composeMigration.test.int.ts +++ b/packages/dappmanager/test/integration/migrations/composeMigration.test.int.ts @@ -28,7 +28,6 @@ services: image: chentex/random-logger container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth restart: always - dns: 172.33.1.2 networks: dncore_network: ipv4_address: 172.33.1.7 @@ -47,7 +46,6 @@ services: image: "chentex/random-logger" container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth restart: always - dns: 172.33.1.2 networks: dncore_network: ipv4_address: 172.33.1.7`; @@ -98,7 +96,7 @@ services: { encoding: "utf8" } ); expect(composeAfter.trim()).to.equal(composeAlreadyMigrated.trim()); - }); + }); after("Remove test setup", async () => { // Disconnect from network diff --git a/packages/dappmanager/test/unit/modules/ethClient/fullNodeEdit.test.ts b/packages/dappmanager/test/unit/modules/ethClient/fullNodeEdit.test.ts index 90e87d5ef..6ee542796 100644 --- a/packages/dappmanager/test/unit/modules/ethClient/fullNodeEdit.test.ts +++ b/packages/dappmanager/test/unit/modules/ethClient/fullNodeEdit.test.ts @@ -15,7 +15,6 @@ version: '3.5' services: geth.dnp.dappnode.eth: container_name: DAppNodePackage-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' image: 'geth.dnp.dappnode.eth:0.4.12' @@ -51,7 +50,6 @@ version: '3.5' services: geth.dnp.dappnode.eth: container_name: DAppNodePackage-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' image: 'geth.dnp.dappnode.eth:0.4.12' diff --git a/packages/dappmanager/test/unit/modules/nsupdate/utils.test.ts b/packages/dappmanager/test/unit/modules/nsupdate/utils.test.ts deleted file mode 100644 index 6a613f8d1..000000000 --- a/packages/dappmanager/test/unit/modules/nsupdate/utils.test.ts +++ /dev/null @@ -1,285 +0,0 @@ -import "mocha"; -import { expect } from "chai"; -import { - getMyDotEthdomain, - getDotDappnodeDomain, - getNsupdateTxts -} from "../../../../src/modules/nsupdate/utils.js"; -import { mockContainer } from "../../../testUtils.js"; -import { PackageContainer } from "@dappnode/common"; - -describe("modules > nsupdate", () => { - describe("getMyDotEthdomain", () => { - const cases: { [name: string]: string } = { - "ipfs.dnp.dappnode.eth": "my.ipfs.dnp.dappnode.eth", - "bitcoin.dnp.dappnode.eth": "my.bitcoin.dnp.dappnode.eth", - "artis.public.dappnode.eth": "my.artis.public.dappnode.eth", - "ln-network.dnp.dappnode.eth": "my.ln-network.dnp.dappnode.eth", - "with_under.dnp.dappnode.eth": "my.withunder.dnp.dappnode.eth", - "service1.dappnodesdk.dnp.dappnode.eth": - "my.service1.dappnodesdk.dnp.dappnode.eth" - }; - - for (const [name, domain] of Object.entries(cases)) { - it(`Should get the domain of ${name}`, () => { - expect(getMyDotEthdomain(name)).to.equal(domain); - }); - } - }); - - describe("getDotDappnodeDomain", () => { - const cases: { [name: string]: string } = { - "ipfs.dnp.dappnode.eth": "ipfs.dappnode", - "bitcoin.dnp.dappnode.eth": "bitcoin.dappnode", - "artis.public.dappnode.eth": "artis.public.dappnode", - "ln-network.dnp.dappnode.eth": "ln-network.dappnode", - "with_under.dnp.dappnode.eth": "withunder.dappnode", - "service1.dappnodesdk.dnp.dappnode.eth": "service1.dappnodesdk.dappnode" - }; - - for (const [name, domain] of Object.entries(cases)) { - it(`Should get the domain of ${name}`, () => { - expect( - getDotDappnodeDomain({ dnpName: name, serviceName: name }, true) - ).to.equal(domain); - }); - } - }); - - /** - * Util to reduce verbosity when asserting nsupdate texts - * @param nsupdateTxts - * @param expectedNsupdateTxts - */ - function assertNsUpdateTxts( - nsupdateTxts: string[], - expectedNsupdateTxts: { eth: string; dappnode: string } - ): void { - expect(nsupdateTxts[0]).to.equal( - ` -server 172.33.1.2 -debug yes -zone eth. -${expectedNsupdateTxts.eth.trim()} -show -send - `.trim(), - "Wrong eth zone" - ); - expect(nsupdateTxts[1]).to.equal( - ` -server 172.33.1.2 -debug yes -zone dappnode. -${expectedNsupdateTxts.dappnode.trim()} -show -send - `.trim(), - "Wrong dappnode zone" - ); - } - - describe("getNsupdateTxts", () => { - const ipfsDnpName = "ipfs.dnp.dappnode.eth"; - const bitcoinDnpName = "bitcoin.dnp.dappnode.eth"; - const gethDnpName = "geth.dnp.dappnode.eth"; - const pinnerDnpName = "pinner.dnp.dappnode.eth"; - const pinnerService1 = "cluster"; - const pinnerService2 = "app"; - const containers: PackageContainer[] = [ - { - ...mockContainer, - dnpName: ipfsDnpName, - serviceName: ipfsDnpName, - ip: "172.33.1.5", - isMain: true - }, - { - ...mockContainer, - dnpName: bitcoinDnpName, - serviceName: bitcoinDnpName, - ip: "172.33.0.2", - isMain: true - }, - { - ...mockContainer, - dnpName: gethDnpName, - serviceName: gethDnpName, - ip: "172.33.0.3", - chain: "ethereum", - isMain: true - }, - { - ...mockContainer, - dnpName: pinnerDnpName, - serviceName: pinnerService1, - ip: "172.33.0.4" - }, - { - ...mockContainer, - dnpName: pinnerDnpName, - serviceName: pinnerService2, - ip: "172.33.0.5" - } - ]; - const domainAliases = { - fullnode: gethDnpName - }; - - it("Should get nsupdate.txt contents for a normal case", () => { - const nsupdateTxts = getNsupdateTxts({ containers, domainAliases }); - assertNsUpdateTxts(nsupdateTxts, { - eth: ` -update delete my.ipfs.dnp.dappnode.eth A -update add my.ipfs.dnp.dappnode.eth 60 A 172.33.1.5 -update delete my.bitcoin.dnp.dappnode.eth A -update add my.bitcoin.dnp.dappnode.eth 60 A 172.33.0.2 -update delete my.geth.dnp.dappnode.eth A -update add my.geth.dnp.dappnode.eth 60 A 172.33.0.3 -update delete my.cluster.pinner.dnp.dappnode.eth A -update add my.cluster.pinner.dnp.dappnode.eth 60 A 172.33.0.4 -update delete my.app.pinner.dnp.dappnode.eth A -update add my.app.pinner.dnp.dappnode.eth 60 A 172.33.0.5 -`, - dappnode: ` -update delete ipfs.dnp.dappnode.eth.ipfs.dappnode A -update add ipfs.dnp.dappnode.eth.ipfs.dappnode 60 A 172.33.1.5 -update delete *.ipfs.dappnode A -update add *.ipfs.dappnode 60 A 172.33.1.5 -update delete ipfs.dappnode A -update add ipfs.dappnode 60 A 172.33.1.5 -update delete bitcoin.dnp.dappnode.eth.bitcoin.dappnode A -update add bitcoin.dnp.dappnode.eth.bitcoin.dappnode 60 A 172.33.0.2 -update delete bitcoin.dappnode A -update add bitcoin.dappnode 60 A 172.33.0.2 -update delete geth.dnp.dappnode.eth.geth.dappnode A -update add geth.dnp.dappnode.eth.geth.dappnode 60 A 172.33.0.3 -update delete geth.dappnode A -update add geth.dappnode 60 A 172.33.0.3 -update delete cluster.pinner.dappnode A -update add cluster.pinner.dappnode 60 A 172.33.0.4 -update delete app.pinner.dappnode A -update add app.pinner.dappnode 60 A 172.33.0.5 -update delete fullnode.dappnode A -update add fullnode.dappnode 60 A 172.33.0.3 -` - }); - }); - - it("Should get nsupdate.txt contents for remove only", () => { - const nsupdateTxts = getNsupdateTxts({ - containers, - domainAliases, - removeOnly: true - }); - - assertNsUpdateTxts(nsupdateTxts, { - eth: ` -update delete my.ipfs.dnp.dappnode.eth A -update delete my.bitcoin.dnp.dappnode.eth A -update delete my.geth.dnp.dappnode.eth A -update delete my.cluster.pinner.dnp.dappnode.eth A -update delete my.app.pinner.dnp.dappnode.eth A -`, - dappnode: ` -update delete ipfs.dnp.dappnode.eth.ipfs.dappnode A -update delete *.ipfs.dappnode A -update delete ipfs.dappnode A -update delete bitcoin.dnp.dappnode.eth.bitcoin.dappnode A -update delete bitcoin.dappnode A -update delete geth.dnp.dappnode.eth.geth.dappnode A -update delete geth.dappnode A -update delete cluster.pinner.dappnode A -update delete app.pinner.dappnode A -update delete fullnode.dappnode A -` - }); - }); - - it("Should get nsupdate.txt contents for installing bitcoin", () => { - const nsupdateTxts = getNsupdateTxts({ - containers, - domainAliases, - dnpNames: [bitcoinDnpName] - }); - - assertNsUpdateTxts(nsupdateTxts, { - eth: ` -update delete my.bitcoin.dnp.dappnode.eth A -update add my.bitcoin.dnp.dappnode.eth 60 A 172.33.0.2 -`, - dappnode: ` -update delete bitcoin.dnp.dappnode.eth.bitcoin.dappnode A -update add bitcoin.dnp.dappnode.eth.bitcoin.dappnode 60 A 172.33.0.2 -update delete bitcoin.dappnode A -update add bitcoin.dappnode 60 A 172.33.0.2 -` - }); - }); - - it("Should get nsupdate.txt contents for a removing bitcoin", () => { - const nsupdateTxts = getNsupdateTxts({ - containers, - domainAliases, - dnpNames: [bitcoinDnpName], - removeOnly: true - }); - - assertNsUpdateTxts(nsupdateTxts, { - eth: ` -update delete my.bitcoin.dnp.dappnode.eth A`, - dappnode: ` -update delete bitcoin.dnp.dappnode.eth.bitcoin.dappnode A -update delete bitcoin.dappnode A` - }); - }); - - it("Should add root domain to grafana container", () => { - const grafanaContainer: PackageContainer = { - ...mockContainer, - canBeFullnode: false, - containerId: - "ba4765113dd6016da8b35dfe367493186f3bfd34d88eca03ccf894f7045710fa", - containerName: "DAppNodePackage-grafana.dms.dnp.dappnode.eth", - created: 1618303536, - dnpName: "dms.dnp.dappnode.eth", - exitCode: null, - image: "grafana.dms.dnp.dappnode.eth:1.0.1", - instanceName: "", - ip: "172.33.0.3", - isCore: false, - isDnp: true, - isMain: true, - networks: [ - { - ip: "172.33.0.3", - name: "dncore_network" - } - ], - - running: true, - serviceName: "grafana", - state: "running" - }; - - const nsupdateTxts = getNsupdateTxts({ - containers: [grafanaContainer], - domainAliases: {} - }); - - assertNsUpdateTxts(nsupdateTxts, { - eth: ` -update delete my.grafana.dms.dnp.dappnode.eth A -update add my.grafana.dms.dnp.dappnode.eth 60 A 172.33.0.3 -update delete my.dms.dnp.dappnode.eth A -update add my.dms.dnp.dappnode.eth 60 A 172.33.0.3 - `, - dappnode: ` -update delete grafana.dms.dappnode A -update add grafana.dms.dappnode 60 A 172.33.0.3 -update delete dms.dappnode A -update add dms.dappnode 60 A 172.33.0.3` - }); - }); - }); -}); \ No newline at end of file diff --git a/packages/dockerCompose/src/editor.ts b/packages/dockerCompose/src/editor.ts index 8982db325..8c9acc69a 100644 --- a/packages/dockerCompose/src/editor.ts +++ b/packages/dockerCompose/src/editor.ts @@ -327,6 +327,9 @@ export class ComposeEditor { !Array.isArray(service.environment) ) service.environment = stringifyEnvironment(service.environment); + + // Remove hardcoded DNS + service.dns = undefined; return { ...omitBy(service, (el) => isObject(el) && isEmpty(el)), // Add mandatory properties for the ts compiler diff --git a/packages/dockerCompose/src/setDappnodeComposeDefaults.ts b/packages/dockerCompose/src/setDappnodeComposeDefaults.ts index ee7aec742..0b9b3d4d0 100644 --- a/packages/dockerCompose/src/setDappnodeComposeDefaults.ts +++ b/packages/dockerCompose/src/setDappnodeComposeDefaults.ts @@ -58,7 +58,6 @@ export function setDappnodeComposeDefaults( container_name: getContainerName({ dnpName, serviceName, isCore }), image: getImageTag({ serviceName, dnpName, version }), environment: parseEnvironment(serviceUnsafe.environment || {}), - dns: params.DNS_SERVICE, // Common DAppNode ENS networks: setServiceNetworksWithAliases(serviceUnsafe.networks, { serviceName, dnpName, diff --git a/packages/dockerCompose/test/unit/composeAliases.test.ts b/packages/dockerCompose/test/unit/composeAliases.test.ts index 0ebdf22ea..b230030d7 100644 --- a/packages/dockerCompose/test/unit/composeAliases.test.ts +++ b/packages/dockerCompose/test/unit/composeAliases.test.ts @@ -17,7 +17,6 @@ version: '3.5' services: goerli-geth.dnp.dappnode.eth: container_name: DAppNodePackage-goerli-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' image: 'goerli-geth.dnp.dappnode.eth:0.4.12' @@ -87,7 +86,6 @@ version: '3.5' services: goerli-geth.dnp.dappnode.eth: container_name: DAppNodePackage-goerli-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' image: 'goerli-geth.dnp.dappnode.eth:0.4.12' @@ -141,7 +139,6 @@ version: '3.5' services: goerli-geth.dnp.dappnode.eth: container_name: DAppNodePackage-goerli-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' image: 'goerli-geth.dnp.dappnode.eth:0.4.12' @@ -195,7 +192,6 @@ version: '3.5' services: goerli-geth.dnp.dappnode.eth: container_name: DAppNodePackage-goerli-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' image: 'goerli-geth.dnp.dappnode.eth:0.4.12' @@ -263,7 +259,6 @@ version: '3.5' services: goerli-geth.dnp.dappnode.eth: container_name: DAppNodePackage-goerli-geth.dnp.dappnode.eth - dns: 172.33.1.2 environment: - 'EXTRA_OPTIONS=--http.api eth,net,web3,txpool' - _DAPPNODE_GLOBAL_ACTIVE=true diff --git a/packages/dockerCompose/test/unit/network.test.ts b/packages/dockerCompose/test/unit/network.test.ts index 827cb9b1b..c20d49838 100644 --- a/packages/dockerCompose/test/unit/network.test.ts +++ b/packages/dockerCompose/test/unit/network.test.ts @@ -8,19 +8,19 @@ describe("modules / compose / networks", () => { from: Parameters[0]; to: ReturnType; }[] = [ - { id: "Empty array", from: [], to: {} }, - { id: "Empty obj", from: {}, to: {} }, - { - id: "From array to obj", - from: ["dncore_network"], - to: { dncore_network: {} }, - }, - { - id: "Keep obj", - from: { dncore_network: {} }, - to: { dncore_network: {} }, - }, - ]; + { id: "Empty array", from: [], to: {} }, + { id: "Empty obj", from: {}, to: {} }, + { + id: "From array to obj", + from: ["dncore_network"], + to: { dncore_network: {} }, + }, + { + id: "Keep obj", + from: { dncore_network: {} }, + to: { dncore_network: {} }, + }, + ]; for (const { id, from, to } of testCases) { it(id, () => { @@ -55,6 +55,7 @@ describe("modules / compose / networks", () => { networks: { [networkName]: { aliases }, }, + dns: undefined, }, }, networks: { @@ -69,6 +70,7 @@ describe("modules / compose / networks", () => { "sample.dnp.dappnode.eth": { container_name, image, + dns: undefined, }, }, networks: {}, diff --git a/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.parsed.yml b/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.parsed.yml index b1909de6e..46ad9f92d 100644 --- a/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.parsed.yml +++ b/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.parsed.yml @@ -2,7 +2,6 @@ version: "3.5" services: dappmanager.dnp.dappnode.eth: container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth - dns: 172.33.1.2 environment: DISABLE_UPNP: "" ETH_MAINNET_RPC_URL_OVERRIDE: "" diff --git a/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.yml b/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.yml index f98477aa2..f67343f75 100644 --- a/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.yml +++ b/packages/dockerCompose/test/unit/releaseSpecs/dappmanager/docker-compose.yml @@ -23,7 +23,6 @@ services: - ETH_MAINNET_RPC_URL_REMOTE= - IPFS_HOST= - DISABLE_UPNP= - dns: 172.33.1.2 networks: dncore_network: ipv4_address: 172.33.1.7 diff --git a/packages/dockerCompose/test/unit/releaseSpecs/prysm/docker-compose.parsed.yml b/packages/dockerCompose/test/unit/releaseSpecs/prysm/docker-compose.parsed.yml index 63d8ffaa0..85d12329e 100644 --- a/packages/dockerCompose/test/unit/releaseSpecs/prysm/docker-compose.parsed.yml +++ b/packages/dockerCompose/test/unit/releaseSpecs/prysm/docker-compose.parsed.yml @@ -13,7 +13,6 @@ services: HTTP_WEB3PROVIDER: "http://geth.dappnode:8545" CORSDOMAIN: "http://prysm.dappnode" EXTRA_OPTS: "" - dns: 172.33.1.2 networks: dncore_network: aliases: @@ -34,7 +33,6 @@ services: BEACON_RPC_GATEWAY_PROVIDER: "beacon-chain.prysm.dappnode:3500" GRAFFITI: validating_from_DAppNode EXTRA_OPTS: "" - dns: 172.33.1.2 networks: dncore_network: aliases: diff --git a/packages/dockerCompose/test/unit/releaseSpecs/sample-core/docker-compose.parsed.yml b/packages/dockerCompose/test/unit/releaseSpecs/sample-core/docker-compose.parsed.yml index 7b5066b01..31896bdb0 100644 --- a/packages/dockerCompose/test/unit/releaseSpecs/sample-core/docker-compose.parsed.yml +++ b/packages/dockerCompose/test/unit/releaseSpecs/sample-core/docker-compose.parsed.yml @@ -2,7 +2,6 @@ version: "3.5" services: s1: container_name: DAppNodeCore-s1.sample-core.dnp.dappnode.eth - dns: 172.33.1.2 image: "s1.sample-core.dnp.dappnode.eth:0.2.33" logging: driver: json-file @@ -19,7 +18,6 @@ services: - "data:/data" s2: container_name: DAppNodeCore-s2.sample-core.dnp.dappnode.eth - dns: 172.33.1.2 image: "s2.sample-core.dnp.dappnode.eth:0.2.33" logging: driver: json-file diff --git a/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.parsed.yml b/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.parsed.yml index 24bcf78b7..354c1cc95 100644 --- a/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.parsed.yml +++ b/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.parsed.yml @@ -2,7 +2,6 @@ version: "3.5" services: vpn.dnp.dappnode.eth: container_name: DAppNodeCore-vpn.dnp.dappnode.eth - dns: 172.33.1.2 image: "vpn.dnp.dappnode.eth:0.2.5" logging: driver: journald diff --git a/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.yml b/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.yml index 333b39d2d..2c44d9a49 100644 --- a/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.yml +++ b/packages/dockerCompose/test/unit/releaseSpecs/vpn/docker-compose.yml @@ -23,7 +23,6 @@ services: ports: - "1194:1194/udp" - "8092:8092" - dns: 172.33.1.2 networks: dncore_network: ipv4_address: 172.33.1.4 diff --git a/packages/dockerCompose/test/unit/setDappnodeComposeDefaults.test.ts b/packages/dockerCompose/test/unit/setDappnodeComposeDefaults.test.ts index dcbba7697..b246e940c 100644 --- a/packages/dockerCompose/test/unit/setDappnodeComposeDefaults.test.ts +++ b/packages/dockerCompose/test/unit/setDappnodeComposeDefaults.test.ts @@ -106,7 +106,6 @@ describe("setDappnodeComposeDefaults", () => { "beacon-chain": { container_name: "DAppNodePackage-beacon-chain.teku-gnosis.dnp.dappnode.eth", - dns: "172.33.1.2", environment: { LOG_TYPE: "INFO", BEACON_API_PORT: "3500", @@ -129,7 +128,6 @@ describe("setDappnodeComposeDefaults", () => { validator: { container_name: "DAppNodePackage-validator.teku-gnosis.dnp.dappnode.eth", - dns: "172.33.1.2", environment: { LOG_TYPE: "INFO", BEACON_NODE_ADDR: "http://beacon-chain.teku-gnosis.dappnode:3500", @@ -189,7 +187,6 @@ describe("setDappnodeComposeDefaults", () => { "IPFS_HOST=", "DISABLE_UPNP=", ], - dns: "172.33.1.2", networks: { dncore_network: { ipv4_address: "172.33.1.7", @@ -232,7 +229,6 @@ describe("setDappnodeComposeDefaults", () => { services: { "dappmanager.dnp.dappnode.eth": { container_name: "DAppNodeCore-dappmanager.dnp.dappnode.eth", - dns: "172.33.1.2", environment: { LOG_LEVEL: "info", ETH_MAINNET_RPC_URL_OVERRIDE: "", diff --git a/packages/dockerCompose/test/unit/userSettings.test.ts b/packages/dockerCompose/test/unit/userSettings.test.ts index b94d0b720..c8e484427 100644 --- a/packages/dockerCompose/test/unit/userSettings.test.ts +++ b/packages/dockerCompose/test/unit/userSettings.test.ts @@ -38,7 +38,6 @@ const polkadotNewCompose = { }, restart: "unless-stopped", container_name: "DAppNodePackage-polkadot-kusama.public.dappnode.eth", - dns: "172.33.1.2", networks: ["dncore_network"], }, }, @@ -209,7 +208,6 @@ describe("parseUserSet", () => { DEFAULT_CLIENT: "PARITY", }, ports: ["35353:30303", "35353:30303/udp", "35354:30304/udp"], - dns: "172.33.1.2", networks: { network: { ipv4_address: "172.33.1.6", diff --git a/packages/params/src/params.ts b/packages/params/src/params.ts index 5c808cb0c..ab9fff56d 100644 --- a/packages/params/src/params.ts +++ b/packages/params/src/params.ts @@ -111,7 +111,6 @@ export const params = { WIREGUARD_DEVICES_ENVNAME: "PEERS", // Docker compose parameters - DNS_SERVICE: "172.33.1.2", DNP_PRIVATE_NETWORK_SUBNET: "172.33.0.0/16", DNP_PRIVATE_NETWORK_NAME: "dncore_network", DNP_PRIVATE_NETWORK_NAME_FROM_CORE: "network", @@ -134,7 +133,6 @@ export const params = { AUTO_UPDATE_DAEMON_INTERVAL: 5 * MINUTE, CHECK_DISK_USAGE_DAEMON_INTERVAL: 1 * MINUTE, NAT_RENEWAL_DAEMON_INTERVAL: 1 * HOUR, - NSUPDATE_DAEMON_INTERVAL: 1 * HOUR, ETHICAL_METRICS_DAEMON_INTERVAL: 50 * MINUTE, // IPFS parameters