Skip to content

fix: honor address family for SOCKS4 forwarding - #263

Merged
inureyes merged 2 commits into
mainfrom
fix/issue-255-socks4-address-family
Aug 3, 2026
Merged

fix: honor address family for SOCKS4 forwarding#263
inureyes merged 2 commits into
mainfrom
fix/issue-255-socks4-address-family

Conversation

@inureyes

@inureyes inureyes commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Honor the resolved address-family policy in the real SOCKS4 dynamic-forwarding path instead of silently using AddressFamily::Any.

What changed

  • Thread AddressFamily from the dynamic connection handler into the SOCKS4 handler.
  • Reject SOCKS4 IPv4 destinations under forced IPv6 with a protocol-correct 0x5B response before opening an SSH channel.
  • Preserve existing behavior for AddressFamily::Any and forced IPv4.
  • Document the SOCKS4 family guarantee in CLI help and the manpage.
  • Add regression coverage for Any, IPv4, and IPv6 policies.

Test plan

  • cargo fmt --all --check
  • cargo test --lib forwarding::dynamic::socks::tests
  • cargo test --test address_family_test
  • cargo check --lib --tests
  • cargo clippy --lib --tests -- -D warnings

Closes #255

Thread the resolved AddressFamily into the SOCKS4 dynamic forwarding path so forced IPv6 now fails closed with a protocol-correct 0x5B rejection instead of silently tunneling IPv4.

Update the -D help text and manpage to state the real SOCKS4 guarantee under -4/-6, and add focused regression tests around the forced-family destination selection helper.

Validation:
- cargo check --lib
- cargo test --test address_family_test
- cargo check --lib --tests (fails in pre-existing src/ssh/tokio_client/to_socket_addrs_with_hostname.rs test-module errors)
- cargo clippy --lib --tests -- -D warnings (fails on the same pre-existing test-module errors)

Refs #255
@inureyes inureyes added type:bug Something isn't working priority:medium Medium priority issue status:review Under review labels Aug 3, 2026
Refactor the SOCKS4 handler through a minimal stream-generic seam so acceptance-level tests can drive the real request parser and response path without changing production behavior.

The new tests send full SOCKS4 frames, prove forced IPv6 returns a 0x5B rejection before the channel-open seam, and prove AddressFamily::Any and V4 reach the seam after parsing the request.

Validation:
- cargo test --lib forwarding::dynamic::socks::tests
- cargo test --test address_family_test
- cargo fmt --all
- cargo check --lib --tests
- cargo clippy --lib --tests -- -D warnings

Refs #255
@inureyes inureyes added status:done Completed and removed status:review Under review labels Aug 3, 2026
@inureyes
inureyes merged commit f7739ac into main Aug 3, 2026
3 checks passed
@inureyes
inureyes deleted the fix/issue-255-socks4-address-family branch August 3, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue status:done Completed type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: -D SOCKS4 dynamic forwarding ignores -4/-6 and the ssh_config AddressFamily keyword

1 participant