mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:48:28 +00:00
refactor(security): unify local-host and tailnet CIDR checks
This commit is contained in:
@@ -334,6 +334,19 @@ export function isLoopbackHost(host: string): boolean {
|
||||
return isLoopbackAddress(unbracket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local-facing host check for inbound requests:
|
||||
* - loopback hosts (localhost/127.x/::1 and mapped forms)
|
||||
* - Tailscale Serve/Funnel hostnames (*.ts.net)
|
||||
*/
|
||||
export function isLocalishHost(hostHeader?: string): boolean {
|
||||
const host = resolveHostName(hostHeader);
|
||||
if (!host) {
|
||||
return false;
|
||||
}
|
||||
return isLoopbackHost(host) || host.endsWith(".ts.net");
|
||||
}
|
||||
|
||||
/**
|
||||
* Security check for WebSocket URLs (CWE-319: Cleartext Transmission of Sensitive Information).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user