MCPcopy Create free account
hub / github.com/Mister-leo/fssh / resolveHostQuery

Function resolveHostQuery

cmd/fssh/shell_commands.go:536–558  ·  view source on GitHub ↗

resolveHostQuery resolves a query (id/alias/hostname/ip) to a host alias

(ctx *ShellContext, query string)

Source from the content-addressed store, hash-verified

534
535// resolveHostQuery resolves a query (id/alias/hostname/ip) to a host alias
536func resolveHostQuery(ctx *ShellContext, query string) string {
537 // Try ID first
538 if name, ok := ctx.idToName[query]; ok {
539 return name
540 }
541
542 // Try exact alias match
543 if _, ok := ctx.byName[query]; ok {
544 return query
545 }
546
547 // Try hostname match
548 if hi, ok := ctx.byHostname[query]; ok {
549 return hi.Name
550 }
551
552 // Try IP match
553 if name, ok := ctx.ipToName[query]; ok {
554 return name
555 }
556
557 return ""
558}
559
560// --- Helper functions ---
561

Callers 1

cmdInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected