* Validate a port number and throw an error if invalid * @param port The port number to validate * @param jumpHostStr The original jump host string for error messages * @throws Error if port is invalid (NaN, <= 0, or > 65535)
(port: number, jumpHostStr: string)
| 241 | * @throws Error if port is invalid (NaN, <= 0, or > 65535) |
| 242 | */ |
| 243 | function validatePort(port: number, jumpHostStr: string): void { |
| 244 | if (isNaN(port) || port <= 0 || port > 65535) { |
| 245 | throw new Error(`Invalid port number in "${jumpHostStr}": port must be between 1 and 65535`); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Parse a jump host string in the format [user@]host[:port] |