MCPcopy Create free account
hub / github.com/bytebase/dbhub / looksLikeSSHAlias

Function looksLikeSSHAlias

src/utils/ssh-config-parser.ts:217–235  ·  view source on GitHub ↗
(host: string)

Source from the content-addressed store, hash-verified

215 * This is a heuristic to determine if we should look up the host in SSH config
216 */
217export function looksLikeSSHAlias(host: string): boolean {
218 // If it contains dots, it's likely a domain or IP
219 if (host.includes('.')) {
220 return false;
221 }
222
223 // If it's all numbers (with possible colons for IPv6), it's likely an IP
224 if (/^[\d:]+$/.test(host)) {
225 return false;
226 }
227
228 // Check for IPv6 addresses with hex characters
229 if (/^[0-9a-fA-F:]+$/.test(host) && host.includes(':')) {
230 return false;
231 }
232
233 // Otherwise, treat it as a potential SSH alias
234 return true;
235}
236
237/**
238 * Validate a port number and throw an error if invalid

Callers 4

resolveJumpHostsFunction · 0.85
connectSourceMethod · 0.85
resolveSSHConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected