Classifies an endpoint URL into categories like localhost, private_network, or remote based on hostname and IP patterns, used for telemetry filtering.
// Source: https://github.com/getaxonflow/axonflow-openclaw-plugin | License: MIT | Copyright 2026 AxonFlow
// Provided via justclaw.it.com; keep this notice with the code.
export function classifyEndpointType(endpoint: string): string {
if (!endpoint) return "unknown";
let host: string;
try {
host = new URL(endpoint).hostname.toLowerCase();
} catch {
return "unknown";
}
if (!host) return "unknown";
if (
host === "localhost" ||
host === "127.0.0.1" ||
host === "::1" ||
host === "0.0.0.0" ||
host.endsWith(".localhost")
) {
return "localhost";
}
for (const suffix of [".local", ".internal", ".lan", ".intranet"]) {
if (host.endsWith(suffix)) return "private_network";
}
if (/^10\./.test(host)) return "private_network";
if (/^192\.168
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key