Deduplicate more

This commit is contained in:
quotentiroler
2026-02-09 18:56:58 -08:00
parent c4d9b6eadb
commit 53910f3643
14 changed files with 38 additions and 138 deletions

View File

@@ -4,7 +4,7 @@ import type { Duplex } from "node:stream";
import { randomBytes } from "node:crypto";
import { createServer } from "node:http";
import WebSocket, { WebSocketServer } from "ws";
import { isLoopbackHost } from "../gateway/net.js";
import { isLoopbackAddress, isLoopbackHost } from "../gateway/net.js";
import { rawDataToString } from "../infra/ws.js";
type CdpCommand = {
@@ -102,25 +102,6 @@ export type ChromeExtensionRelayServer = {
stop: () => Promise<void>;
};
function isLoopbackAddress(ip: string | undefined): boolean {
if (!ip) {
return false;
}
if (ip === "127.0.0.1") {
return true;
}
if (ip.startsWith("127.")) {
return true;
}
if (ip === "::1") {
return true;
}
if (ip.startsWith("::ffff:127.")) {
return true;
}
return false;
}
function parseBaseUrl(raw: string): {
host: string;
port: number;