mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-22 08:03:40 +00:00
14 lines
583 B
TypeScript
14 lines
583 B
TypeScript
import type { Host, HostProtocol } from './models';
|
|
|
|
type TerminalTransportHost = Pick<Host, 'protocol' | 'moshEnabled' | 'etEnabled'>
|
|
& Partial<Pick<Host, 'hostname'>>;
|
|
|
|
/** Resolve the transport actually selected by the first-party session launcher. */
|
|
export function resolveEffectiveTerminalProtocol(host: TerminalTransportHost): HostProtocol {
|
|
if (host.protocol && host.protocol !== 'ssh') return host.protocol;
|
|
if (host.moshEnabled) return 'mosh';
|
|
if (host.etEnabled) return 'et';
|
|
if (host.hostname === 'localhost') return 'local';
|
|
return host.protocol ?? 'ssh';
|
|
}
|