feat: support comp-lzo for OpenVPN#2841
Merged
Merged
Conversation
- Add `comp-lzo` config option for OpenVPN proxy (values: "yes", "no", "adaptive") - Send LZO header (0xfa) with outgoing packets when comp-lzo enabled - Use github.com/rasky/go-lzo (pure Go, no CGO) for LZO decompression - Parse server-pushed routes from PUSH_REPLY - Add IV_LZO=1 to peer info when enabled - Add comp-lzo to OpenVPN options string
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.
Summary
comp-lzoconfig option for OpenVPN proxy to support LZO compressionProblem
When connecting to OpenVPN servers with
comp-lzoenabled, the handshake succeeds but data transfer fails. The server expects all data packets to include a 1-byte LZO compression header, but mihomo was sending raw IP packets without it.Root Cause
Changes
transport/openvpn/config.go: AddCompLZOfield toClientConfigstructtransport/openvpn/lzo.go: New file - pure Go LZO1X decompression usinggithub.com/rasky/go-lzotransport/openvpn/data.go: Add LZO header (0xfa) to outgoing packets when comp-lzo is enabled; decompress incoming LZO-compressed packets (0x66)transport/openvpn/keymethod.go: AddIV_LZO=1to peer info andcomp-lzoto options string when enabledtransport/openvpn/client.go: Use new comp-lzo aware functionstransport/openvpn/push.go: Parserouteandroute-ipv6from server push replyadapter/outbound/openvpn.go: Addcomp-lzoconfig option, convert string to boolConfig Example
Testing
Verified against a real OpenVPN server with comp-lzo enabled:
Dependencies
Pure Go, no CGO required. Uses
github.com/rasky/go-lzofor LZO decompression.