Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

connect to host … : Unknown error for WSAEHOSTUNREACH / WSAENETUNREACH (no errno mapping)

未关闭 适合新手
#2,482 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
networking

调研方向

从 contrib/win32/win32compat/socketio.c 中的 errno_from_WSAError() 开始。issue 指出缺少 WSAEHOSTUNREACH 和 WSAENETUNREACH 的映射;请检查 misc.c 中对应的错误字符串。如果有相关的 Windows 连接测试,请运行并确认无法访问的主机会产生有意义的错误,而不是“Unknown error”。

由索引模型根据 Issue 内容生成。

描述

Summary

When the TCP connect fails because the host or network is unreachable (for example, Wi-Fi drops), ssh prints

ssh: connect to host 192.168.0.63 port 22: Unknown error

instead of a meaningful message. Tools that parse ssh's output to decide whether a failure is transient can't classify it. VS Code Remote-SSH, for example, treats it as a permanent error and stops reconnecting.

Steps to reproduce
  1. ssh -F NUL -o BatchMode=yes [email protected] (no route) → ssh: connect to host 240.0.0.1 port 22: Unknown error, instantly.
  2. Or, with Wi-Fi disconnected (netsh wlan disconnect), ssh <LAN host> → same Unknown error. .NET reports the same connect as SocketError.HostUnreachable (10065).
Expected

No route to host / Network is unreachable (or at least a message naming the Winsock error).

Actual

Unknown error.

Cause

contrib/win32/win32compat/socketio.c, errno_from_WSAError() maps only a handful of WSA codes. Everything else falls to

default:
    return wsaerrno - 10000;

So WSAEHOSTUNREACH (10065) becomes errno 65 and WSAENETUNREACH (10051) becomes 51. w32_strerror() in misc.c only has strings for EADDRINUSE..EWOULDBLOCK (100–140), so strerror_s returns "Unknown error" for those values.

Suggested fix: add explicit cases:

  • WSAENETDOWN → ENETDOWN
  • WSAENETUNREACH → ENETUNREACH
  • WSAEHOSTUNREACH → EHOSTUNREACH
  • WSAEADDRNOTAVAIL → EADDRNOTAVAIL

Optionally, use the POSIX/glibc wording in _sys_errlist_ext ("No route to host", "Network is unreachable"); the current "Host is unreachable" and "Network unreachable" differ from what other platforms print and from what scripts match.

Version
  • OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 (Windows 10 Pro 22H2 19045, built-in)
  • Same code in v10.4.0.0 (socketio.c unchanged).
主要语言
没有语言数据
星标
8.3k
派生
822
平均合并
3 天 2 小时
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PowerShell/Win32-OpenSSH 的其他 Issue

查看 PowerShell/Win32-OpenSSH 的全部 Issue

相似的 Issue

更多 Networking Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。