Skip to content

Commit

Permalink
update params imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Sep 19, 2023
1 parent 32aeb84 commit f01780c
Show file tree
Hide file tree
Showing 87 changed files with 125 additions and 450 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from "express";
import params from "../../../params.js";
import { params } from "@dappnode/params";
import { getIpfsProxyHandler, ProxyType } from "./ipfsProxy.js";
import { ResolveDomainWithCache } from "./resolveDomain.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from "http";
import httpProxy from "http-proxy";
import express from "express";
import params from "../../../params.js";
import { params } from "@dappnode/params";
import { EthProviderError } from "../../../modules/ethClient/index.js";
import { ipfs } from "../../../modules/ipfs/index.js";
import { urlJoin } from "../../../utils/url.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { base } from "./base.js";
import { NotFoundError } from "../types.js";
import params from "../../../../params.js";
import { params } from "@dappnode/params";

const adminUiUrl = `http://my.dappnode/`;
const adminUiInstallUrl = `${adminUiUrl}/installer`;
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/api/routes/upload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import path from "path";
import crypto from "crypto";
import params from "../../params.js";
import { params } from "@dappnode/params";
import * as db from "../../db/index.js";
import { logs } from "../../logs.js";
import { wrapHandler } from "../utils.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/api/startTestApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as api from "../calls/index.js";
import http from "http";
import express from "express";
import bodyParser from "body-parser";
import params from "../params.js";
import { params } from "@dappnode/params";
import { logs } from "../logs.js";

export function startTestApi(): http.Server {
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/backupGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import crypto from "crypto";
import path from "path";
import { logs } from "../logs.js";
import * as db from "../db/index.js";
import params from "../params.js";
import { params } from "@dappnode/params";
// Modules
import { listPackage } from "../modules/docker/list/index.js";
// Utils
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/backupRestore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import fs from "fs";
import * as db from "../db/index.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import { logs } from "../logs.js";
import { listPackage } from "../modules/docker/list/index.js";
import { packageRestart } from "./packageRestart.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/changeIpfsTimeout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import params from "../params.js";
import { params } from "@dappnode/params";

/**
* Used to test different IPFS timeout parameters live from the ADMIN UI.
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/cleanCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import params from "../params.js";
import { params } from "@dappnode/params";
import { clearCacheDb } from "../db/index.js";
// Utils
import shell from "../utils/shell.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/copyFileTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
// Utils
import shell from "../utils/shell.js";
import dataUriToFile from "../utils/dataUriToFile.js";
import params from "../params.js";
import { params } from "@dappnode/params";

const tempTransferDir = params.TEMP_TRANSFER_DIR;

Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/fetchCoreUpdateData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { valid, satisfies } from "semver";
import params from "../params.js";
import { params } from "@dappnode/params";
import { CoreUpdateData, PackageRelease } from "@dappnode/common";
import { ReleaseFetcher } from "../modules/release/index.js";
import { listPackages } from "../modules/docker/list/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/fetchDnpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mapValues, omit } from "lodash-es";
import { valid, gt } from "semver";
import { Manifest, SetupWizardField } from "@dappnode/types";
import { listPackages } from "../modules/docker/list/index.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import shouldUpdate from "../modules/dappGet/utils/shouldUpdate.js";
import deepmerge from "deepmerge";
import { fileToGatewayUrl } from "../utils/distributedFile.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/httpsPortal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import params from "../params.js";
import { params } from "@dappnode/params";
import { HttpsPortalMapping, ExposableServiceMapping } from "@dappnode/common";
import {
HttpsPortal,
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/localProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
startAvahiDaemon,
getAvahiDaemonStatus
} from "../modules/hostScripts/scripts/avahiDaemon.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import { AvahiDaemonStatus, LocalProxyingStatus } from "@dappnode/common";
import { packageSetEnvironment } from "./packageSetEnvironment.js";
import { listPackageNoThrow } from "../modules/docker/list/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/packageGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { logs } from "../logs.js";
import { ComposeFileEditor } from "../modules/compose/editor.js";
import { getVolumesOwnershipData } from "../modules/docker/volumesData.js";
import { sortPackages } from "./packagesGet.js";
import params from "../params.js";
import { params } from "@dappnode/params";

/**
* Get package detail information
Expand Down
7 changes: 5 additions & 2 deletions packages/dappmanager/src/calls/packageRemove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "fs";
import { eventBus } from "../eventBus.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import { dockerComposeDown } from "../modules/docker/compose/index.js";
import {
dockerContainerRemove,
Expand All @@ -15,7 +15,10 @@ import { isRunningHttps } from "../modules/https-portal/utils/isRunningHttps.js"
import { httpsPortal } from "./httpsPortal.js";
import * as db from "../db/index.js";
import { mevBoostMainnet, mevBoostPrater, stakerPkgs } from "@dappnode/types";
import { ethicalMetricsDnpName, unregister } from "../modules/ethicalMetrics/index.js";
import {
ethicalMetricsDnpName,
unregister
} from "../modules/ethicalMetrics/index.js";

/**
* Remove package data: docker down + disk files
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/packageRestart.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs";
import params from "../params.js";
import { params } from "@dappnode/params";
import { eventBus } from "../eventBus.js";
import * as getPath from "../utils/getPath.js";
import { dockerContainerRestart } from "../modules/docker/index.js";
Expand Down
12 changes: 9 additions & 3 deletions packages/dappmanager/src/calls/packageRestartVolumes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import { removeNamedVolume } from "../modules/docker/removeNamedVolume.js";
import { eventBus } from "../eventBus.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import { logs } from "../logs.js";
import * as getPath from "../utils/getPath.js";
import {
Expand All @@ -17,7 +17,10 @@ import { packageInstalledHasPid } from "../utils/pid.js";
import { ComposeFileEditor } from "../modules/compose/editor.js";
import { containerNamePrefix, containerCoreNamePrefix } from "@dappnode/types";
import { unregister } from "../modules/ethicalMetrics/unregister.js";
import { ethicalMetricsDnpName, ethicalMetricsTorServiceVolume } from "../modules/ethicalMetrics/index.js";
import {
ethicalMetricsDnpName,
ethicalMetricsTorServiceVolume
} from "../modules/ethicalMetrics/index.js";

/**
* Removes a package volumes. The re-ups the package
Expand Down Expand Up @@ -58,7 +61,10 @@ export async function packageRestartVolumes({
}

// The Ethical Metrics instance must be unregistered if the tor hidden service volume is removed
if ((dnp.dnpName === ethicalMetricsDnpName && !volumeName) || volumeName === ethicalMetricsTorServiceVolume) {
if (
(dnp.dnpName === ethicalMetricsDnpName && !volumeName) ||
volumeName === ethicalMetricsTorServiceVolume
) {
try {
await unregister();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/packageSetPortMappings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eventBus } from "../eventBus.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import { listPackage } from "../modules/docker/list/index.js";
import { ComposeFileEditor } from "../modules/compose/editor.js";
import { PortMapping } from "@dappnode/common";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/packageStartStop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
dockerContainerStart
} from "../modules/docker/index.js";
import { eventBus } from "../eventBus.js";
import params from "../params.js";
import { params } from "@dappnode/params";
import { getServicesSharingPid } from "../utils/pid.js";
import { ComposeFileEditor } from "../modules/compose/editor.js";
import { PackageContainer } from "@dappnode/common";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/seedPhraseSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { storePrivateKeyFromSeed } from "../utils/seedPhrase.js";
import { decrypt } from "../utils/publickeyEncryption.js";
import * as db from "../db/index.js";
import { eventBus } from "../eventBus.js";
import params from "../params.js";
import { params } from "@dappnode/params";

const adminPublicKey = params.ADMIN_NACL_PUBLIC_KEY;

Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/wifi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComposeFileEditor } from "../modules/compose/editor.js";
import { logContainer } from "../modules/docker/api/index.js";
import { listContainer } from "../modules/docker/list/index.js";
import { CurrentWifiCredentials, WifiReport } from "@dappnode/common";
import params from "../params.js";
import { params } from "@dappnode/params";

/**
* Return wifi report
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/daemons/autoUpdates/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import params from "../../params.js";
import { params } from "@dappnode/params";
import { eventBus } from "../../eventBus.js";
import { ReleaseFetcher } from "../../modules/release/index.js";
import { EthProviderError } from "../../modules/ethClient/index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { valid, lte } from "semver";
import params from "../../params.js";
import { params } from "@dappnode/params";
import * as db from "../../db/index.js";
import { eventBus } from "../../eventBus.js";
import { ReleaseFetcher } from "../../modules/release/index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { valid, lte } from "semver";
import params from "../../params.js";
import { params } from "@dappnode/params";
import { listPackages } from "../../modules/docker/list/index.js";
import { eventBus } from "../../eventBus.js";
import { ReleaseFetcher } from "../../modules/release/index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eventBus } from "../../eventBus.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import {
isUpdateDelayCompleted,
flagCompletedUpdate,
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/daemons/diskUsage/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as db from "../../db/index.js";
import shellExec from "../../utils/shell.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import { eventBus } from "../../eventBus.js";
import { logs } from "../../logs.js";
import { runAtMostEvery } from "../../utils/asyncFlows.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/daemons/dyndns/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eventBus } from "../../eventBus.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import * as db from "../../db/index.js";
import updateIp from "../../modules/dyndns/updateIp.js";
import lookup from "../../utils/lookup.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/daemons/ethMultiClient/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as db from "../../db/index.js";
import { eventBus } from "../../eventBus.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import { packageInstall } from "../../calls/index.js";
import { listPackageNoThrow } from "../../modules/docker/list/index.js";
import { runOnlyOneSequentially } from "../../utils/asyncFlows.js";
Expand Down
22 changes: 14 additions & 8 deletions packages/dappmanager/src/daemons/ethicalMetrics/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import { eventBus } from "../../eventBus.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import { runOnlyOneSequentially } from "../../utils/asyncFlows.js";
import { runAtMostEvery } from "../../utils/asyncFlows.js";
import { logs } from "../../logs.js";
import { checkEthicalMetricsStatus } from "./checkEthicalMetricsStatus.js";

/**
* Randomize an interval
*
*
* Example:
* getRandomizedInterval(50, 10) // 50 +/- 10 = [40, 60]
*
*
* @param baseInterval
* @param variation
* @returns
* @param variation
* @returns
*/
function getRandomizedInterval(baseInterval: number, variation: number): number {
function getRandomizedInterval(
baseInterval: number,
variation: number
): number {
const randomAdjustment = Math.round((Math.random() * 2 - 1) * variation); // Random integer between -variation and +variation
return baseInterval + randomAdjustment;
}

/**
* Run the Ethical metrics daemon.
* Run the Ethical metrics daemon.
* It will check that DMS, Exporter and Ethical metrics are installed and running if Ethical metrics is enabled
*/
export function startEthicalMetricsDaemon(signal: AbortSignal): void {
Expand All @@ -38,7 +41,10 @@ export function startEthicalMetricsDaemon(signal: AbortSignal): void {

runAtMostEvery(
async () => runEthicalMetricsTaskMemo(),
getRandomizedInterval(params.ETH_METRICS_DAEMON_INTERVAL, params.ETH_METRICS_DAEMON_INTERVAL_VARIATION),
getRandomizedInterval(
params.ETH_METRICS_DAEMON_INTERVAL,
params.ETH_METRICS_DAEMON_INTERVAL_VARIATION
),
signal
);
}
2 changes: 1 addition & 1 deletion packages/dappmanager/src/daemons/natRenewal/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as upnpc from "../../modules/upnpc/index.js";
import { eventBus } from "../../eventBus.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import * as db from "../../db/index.js";
import getPortsToOpen from "./getPortsToOpen.js";
import getLocalIp from "../../utils/getLocalIp.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/daemons/nsupdate/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import retry from "async-retry";
import { eventBus } from "../../eventBus.js";
import * as db from "../../db/index.js";
import params from "../../params.js";
import { params } from "@dappnode/params";
import { listContainers } from "../../modules/docker/list/index.js";
import { getNsupdateTxts, execNsupdate } from "../../modules/nsupdate/index.js";
import { runAtMostEveryIntervals } from "../../utils/asyncFlows.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/db/dbFactory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as validate from "../utils/validate.js";
import { logs } from "../logs.js";
import { JsonFileDb } from "@dappnode/utils";
import params from "../params.js";
import { params } from "@dappnode/params";

/**
* Stores critical data for this DAppNode, such as the DynDNS identity
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/db/interceptGlobalEnvOnSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
updatePkgsWithGlobalEnvs,
writeGlobalEnvsToEnvFile
} from "../modules/globalEnvs.js";
import params from "../params.js";
import { params } from "@dappnode/params";

/**
* Intercept all on set methods when any global env is set. When updating a global env there must be done:
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/db/ipfsClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dbMain } from "./dbFactory.js";
import { IpfsClientTarget } from "@dappnode/common";
import params from "../params.js";
import { params } from "@dappnode/params";

// User chosen properties
const IPFS_CLIENT_TARGET = "ipfs-client-target";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/db/releaseKeys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import params from "../params.js";
import { params } from "@dappnode/params";
import { TrustedReleaseKey } from "@dappnode/common";
import { dbMain } from "./dbFactory.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/domains.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import params from "./params.js";
import { params } from "@dappnode/params";
import { getContainerDomain } from "@dappnode/types";

export function stripCharacters(s: string): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as calls from "./calls/index.js";
import { routesLogger, subscriptionsLogger } from "./api/logger.js";
import * as routes from "./api/routes/index.js";
import { logs } from "./logs.js";
import params from "./params.js";
import { params } from "@dappnode/params";
import { getVpnApiClient } from "./api/vpnApiClient.js";
import {
getVersionData,
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/initializeDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import getStaticIp from "./utils/getStaticIp.js";
import getExternalUpnpIp from "./modules/upnpc/getExternalIp.js";
import { writeGlobalEnvsToEnvFile } from "./modules/globalEnvs.js";
import getPublicIpFromUrls from "./utils/getPublicIpFromUrls.js";
import params from "./params.js";
import { params } from "@dappnode/params";
import ping from "./utils/ping.js";
import { pause } from "./utils/asyncFlows.js";
import retry from "async-retry";
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/logUserAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eventBus } from "./eventBus.js";
import params from "./params.js";
import { params } from "@dappnode/params";
import { UserActionLog } from "@dappnode/common";
import { logSafeObjects } from "./utils/logs.js";
import { JsonFileDb } from "@dappnode/utils";
Expand Down
Loading

0 comments on commit f01780c

Please sign in to comment.