feat: support custom peer-info for openvpn outbound#2926
Merged
Conversation
Allow declaring custom peer-info entries (e.g. IV_HWADDR, UV_*) in the openvpn outbound config. They are appended after the built-in IV_VER/IV_PROTO/IV_CIPHERS fields and sorted by key for deterministic output. Omitting peer-info keeps the emitted bytes identical to before, so the change is fully backward compatible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 29, 2026
3 tasks
vernesong
pushed a commit
to vernesong/mihomo
that referenced
this pull request
Jun 30, 2026
vernesong
pushed a commit
to vernesong/mihomo
that referenced
this pull request
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2919
Adds an optional
peer-infomap to the OpenVPN outbound, letting users declare custom peer-info entries (e.g.IV_HWADDR,UV_*) sent during the key-method-2 handshake. Entries are appended after the built-inIV_VER/IV_PROTO/IV_CIPHERSand sorted by key for deterministic output. Fully backward compatible — whenpeer-infois omitted the emitted bytes are identical to before.Why
Some OpenVPN deployments use
--client-connectscripts or PAM plugins to read client-pushed peer-info (such asIV_HWADDRor customUV_*) for access control — e.g. checking a device's hardware address against an allow-list. mihomo currently sends a hard-coded minimal peer-info, so such servers reject the connection and the OpenVPN outbound is unusable against them. This lets the client advertise the required peer-info.Related
Against servers that run slow access-control checks during the handshake, you may also need the standalone handshake-timeout fix in #2925 for the control channel to complete in time. That is submitted separately because it is an independent, pre-existing bug.
Testing
go test ./transport/openvpn/passes. Verified against a real OpenVPN server that gates clients byIV_HWADDR.这个 PR 做了什么
为 OpenVPN 出站新增一个可选的
peer-infomap,允许用户声明在 key-method-2 握手时上送的自定义 peer-info 条目(如IV_HWADDR、UV_*)。用户条目追加在内置IV_VER/IV_PROTO/IV_CIPHERS之后,并按 key 排序以保证确定性输出。完全向后兼容 —— 不填peer-info时,上送的字节与改动前逐字节一致。为什么需要
部分 OpenVPN 部署会用
--client-connect脚本或 PAM 插件读取客户端上送的 peer-info(如IV_HWADDR或自定义UV_*)做准入控制(例如按设备硬件地址校验白名单)。mihomo 目前上送的是写死的最小 peer-info,这类服务端会拒绝连接,导致 OpenVPN 出站在这类环境下无法使用。本改动让客户端能上送所需的 peer-info。关联
对在握手期间做慢速准入校验的服务端,可能还需要配合 #2925(独立的握手超时修复)才能让控制信道及时完成。那个修复是独立的、早已存在的 bug,因此单独成 PR。
测试
go test ./transport/openvpn/通过。已针对真实按IV_HWADDR做准入的 OpenVPN 服务端验证连通。🤖 Generated with Claude Code