Skip to content

Add unit tests for SOCKS5 UDP header generation and parsing#60

Merged
zh-jq merged 1 commit into
mainfrom
codex/find-repository-usage-instructions
Jul 12, 2026
Merged

Add unit tests for SOCKS5 UDP header generation and parsing#60
zh-jq merged 1 commit into
mainfrom
codex/find-repository-usage-instructions

Conversation

@zh-jq

@zh-jq zh-jq commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Verify correctness of SOCKS5 UDP header generation and parsing for IPv4, IPv6, IPv4-mapped IPv6 and domain names.
  • Ensure reusable header buffer behavior is correct and that malformed packets are rejected with proper errors.

Description

  • Add a #[cfg(test)] mod tests with unit tests exercising UdpOutput::generate_header, UdpOutput::generate_header2, and UdpInput::parse_header for round-trip encoding/decoding of IPv4, IPv6, and domain addresses.
  • Add a test that confirms an IPv4-mapped IPv6 address is encoded using the IPv4 header format and that UDP_HEADER_LEN_IPV4 is used.
  • Add a test validating the SocksUdpHeader::encode behavior where the internal buffer resizes for a domain address and the returned view shrinks for subsequent IPv4 encoding.
  • Add tests that UdpInput::parse_header rejects several malformed packets and returns the expected SocksUdpPacketError variants.

Testing

  • Ran the crate unit tests with cargo test and verified the new tests execute successfully against the vey-socks UDP header logic.
  • All added tests passed (no failures reported).

Codex Task

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zh-jq
zh-jq merged commit 3504f16 into main Jul 12, 2026
118 of 128 checks passed
@zh-jq
zh-jq deleted the codex/find-repository-usage-instructions branch July 12, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant