




























@@ -5,6 +5,7 @@ import { promptYesNo } from "../cli/prompt.js";
55import { danger, info, logVerbose, shouldLogVerbose, warn } from "../globals.js";
66import { runExec } from "../process/exec.js";
77import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
8+import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "../shared/number-coercion.js";
89import { asNullableObjectRecord as readRecord } from "../shared/record-coerce.js";
910import {
1011normalizeLowercaseStringOrEmpty,
@@ -540,19 +541,27 @@ function parseWhoisIdentity(payload: Record<string, unknown>): TailscaleWhoisIde
540541}
541542542543function readCachedWhois(ip: string, now: number): TailscaleWhoisIdentity | null | undefined {
544+const validNow = asDateTimestampMs(now);
545+if (validNow === undefined) {
546+return undefined;
547+}
543548const cached = whoisCache.get(ip);
544549if (!cached) {
545550return undefined;
546551}
547-if (cached.expiresAt <= now) {
552+const expiresAt = asDateTimestampMs(cached.expiresAt);
553+if (expiresAt === undefined || expiresAt <= validNow) {
548554whoisCache.delete(ip);
549555return undefined;
550556}
551557return cached.value;
552558}
553559554-function writeCachedWhois(ip: string, value: TailscaleWhoisIdentity | null, ttlMs: number) {
555-whoisCache.set(ip, { value, expiresAt: Date.now() + ttlMs });
560+function writeCachedWhois(ip: string, value: TailscaleWhoisIdentity | null, ttlMs: number): void {
561+const expiresAt = resolveExpiresAtMsFromDurationMs(ttlMs);
562+if (expiresAt !== undefined) {
563+whoisCache.set(ip, { value, expiresAt });
564+}
556565}
557566558567export async function readTailscaleWhoisIdentity(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。