Skip to content

Commit

Permalink
Drop cacheable-lookup (louislam#4178)
Browse files Browse the repository at this point in the history
* WIP

* WIP
  • Loading branch information
louislam authored Dec 10, 2023
1 parent 97ed0a9 commit 530c8e5
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 154 deletions.
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"axios-ntlm": "1.3.0",
"badge-maker": "~3.3.1",
"bcryptjs": "~2.4.3",
"cacheable-lookup": "~6.0.4",
"chardet": "~1.4.0",
"check-password-strength": "^2.0.5",
"cheerio": "~1.0.0-rc.12",
Expand Down
88 changes: 0 additions & 88 deletions server/cacheable-dns-http-agent.js

This file was deleted.

13 changes: 7 additions & 6 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const { demoMode } = require("../config");
const version = require("../../package.json").version;
const apicache = require("../modules/apicache");
const { UptimeKumaServer } = require("../uptime-kuma-server");
const { CacheableDnsHttpAgent } = require("../cacheable-dns-http-agent");
const { DockerHost } = require("../docker");
const Gamedig = require("gamedig");
const jsonata = require("jsonata");
Expand All @@ -24,6 +23,8 @@ const crypto = require("crypto");
const { UptimeCalculator } = require("../uptime-calculator");
const { CookieJar } = require("tough-cookie");
const { HttpsCookieAgent } = require("http-cookie-agent/http");
const https = require("https");
const http = require("http");

const rootCertificates = rootCertificatesFingerprints();

Expand Down Expand Up @@ -667,12 +668,12 @@ class Monitor extends BeanModel {
headers: {
"Accept": "*/*",
},
httpsAgent: CacheableDnsHttpAgent.getHttpsAgent({
httpsAgent: new https.Agent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
rejectUnauthorized: !this.getIgnoreTls(),
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
}),
httpAgent: CacheableDnsHttpAgent.getHttpAgent({
httpAgent: new http.Agent({
maxCachedSessions: 0,
}),
maxRedirects: this.maxredirects,
Expand Down Expand Up @@ -719,12 +720,12 @@ class Monitor extends BeanModel {
headers: {
"Accept": "*/*",
},
httpsAgent: CacheableDnsHttpAgent.getHttpsAgent({
httpsAgent: new https.Agent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
rejectUnauthorized: !this.getIgnoreTls(),
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
}),
httpAgent: CacheableDnsHttpAgent.getHttpAgent({
httpAgent: new http.Agent({
maxCachedSessions: 0,
}),
};
Expand All @@ -739,7 +740,7 @@ class Monitor extends BeanModel {
options.socketPath = dockerHost._dockerDaemon;
} else if (dockerHost._dockerType === "tcp") {
options.baseURL = DockerHost.patchDockerURL(dockerHost._dockerDaemon);
options.httpsAgent = CacheableDnsHttpAgent.getHttpsAgent(
options.httpsAgent = new https.Agent(
DockerHost.getHttpsAgentOptions(dockerHost._dockerType, options.baseURL)
);
}
Expand Down
3 changes: 0 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ const { maintenanceSocketHandler } = require("./socket-handlers/maintenance-sock
const { apiKeySocketHandler } = require("./socket-handlers/api-key-socket-handler");
const { generalSocketHandler } = require("./socket-handlers/general-socket-handler");
const { Settings } = require("./settings");
const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
const apicache = require("./modules/apicache");
const { resetChrome } = require("./monitor-types/real-browser-monitor-type");
const { EmbeddedMariaDB } = require("./embedded-mariadb");
Expand Down Expand Up @@ -1322,8 +1321,6 @@ let needSetup = false;
await setSettings("general", data);
server.entryPage = data.entryPage;

await CacheableDnsHttpAgent.update();

// Also need to apply timezone globally
if (data.serverTimezone) {
await server.setTimezone(data.serverTimezone);
Expand Down
3 changes: 0 additions & 3 deletions server/uptime-kuma-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const { R } = require("redbean-node");
const { log } = require("../src/util");
const Database = require("./database");
const util = require("util");
const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
const { Settings } = require("./settings");
const dayjs = require("dayjs");
const childProcessAsync = require("promisify-child-process");
Expand Down Expand Up @@ -131,8 +130,6 @@ class UptimeKumaServer {
// Static
this.app.use("/screenshots", express.static(Database.screenshotDir));

await CacheableDnsHttpAgent.update();

process.env.TZ = await this.getTimezone();
dayjs.tz.setDefault(process.env.TZ);
log.debug("DEBUG", "Timezone: " + process.env.TZ);
Expand Down
40 changes: 0 additions & 40 deletions src/components/settings/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,46 +187,6 @@
</div>
</div>

<!-- DNS Cache -->
<div class="mb-4">
<label class="form-label">
{{ $t("Enable DNS Cache") }}
<div class="form-text">
⚠️ {{ $t("dnsCacheDescription") }}
</div>
</label>

<div class="form-check">
<input
id="dnsCacheEnable"
v-model="settings.dnsCache"
class="form-check-input"
type="radio"
name="dnsCache"
:value="true"
required
/>
<label class="form-check-label" for="dnsCacheEnable">
{{ $t("Enable") }}
</label>
</div>

<div class="form-check">
<input
id="dnsCacheDisable"
v-model="settings.dnsCache"
class="form-check-input"
type="radio"
name="dnsCache"
:value="false"
required
/>
<label class="form-check-label" for="dnsCacheDisable">
{{ $t("Disable") }}
</label>
</div>
</div>

<!-- Chrome Executable -->
<div class="mb-4">
<label class="form-label" for="primaryBaseURL">
Expand Down
4 changes: 0 additions & 4 deletions src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ export default {
this.settings.nscd = true;
}
if (this.settings.dnsCache === undefined) {
this.settings.dnsCache = false;
}
if (this.settings.keepDataPeriodDays === undefined) {
this.settings.keepDataPeriodDays = 180;
}
Expand Down

0 comments on commit 530c8e5

Please sign in to comment.