Skip to content

fix: support SOCKS5 IPv6 literal destinations - #261

Merged
inureyes merged 2 commits into
mainfrom
fix/issue-256-socks-ipv6-literals
Aug 3, 2026
Merged

fix: support SOCKS5 IPv6 literal destinations#261
inureyes merged 2 commits into
mainfrom
fix/issue-256-socks-ipv6-literals

Conversation

@inureyes

@inureyes inureyes commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Add real SOCKS5 ATYP 0x04 parsing so dynamic forwarding consumes IPv6 literals and forwards them as bracketed [ipv6]:port targets.
  • Keep the SOCKS5 success reply intentionally RFC 1928-compatible with the OpenSSH-style 0.0.0.0:0 BND.ADDR placeholder, and document that choice in code.
  • Add focused IPv6 literal regressions plus update the -D CLI help and man page to describe IPv4, domain-name, and IPv6 SOCKS5 destinations accurately.

Test plan

  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --test socks_ipv6_literal_test
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --test address_family_test forced_family_with_no_candidate_fails_hard
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --test socks_ipv6_literal_test -- -D warnings

Notes

  • cargo check --lib --tests is still blocked by pre-existing cfg(test) compile errors in src/ssh/tokio_client/to_socket_addrs_with_hostname.rs; this branch does not touch that file.

Closes #256

@inureyes inureyes added type:bug Something isn't working priority:medium Medium priority issue status:review Under review status:done Completed and removed status:review Under review labels Aug 3, 2026
@inureyes
inureyes force-pushed the fix/issue-256-socks-ipv6-literals branch from 9d54838 to 75f549e Compare August 3, 2026 11:12
Implement the SOCKS5 ATYP 0x04 path so dynamic forwarding consumes the full IPv6 request, formats the destination as [ipv6]:port, and reuses the existing family-aware direct-tcpip channel opener instead of rejecting IPv6 literals outright.

Document the deliberate RFC 1928 reply choice to keep the OpenSSH-compatible 0.0.0.0:0 BND.ADDR placeholder, and update the CLI help and man page so they describe SOCKS5 IPv4, domain-name, and IPv6 literal support accurately.

Validation: CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --test socks_ipv6_literal_test; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --test address_family_test forced_family_with_no_candidate_fails_hard; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --test socks_ipv6_literal_test -- -D warnings.

Refs #256
Import TunnelStats directly into the SOCKS unit-test module so the cold test build resolves the helper type correctly.

Also correct the synthetic SOCKS5 CONNECT request headers in the in-file tests so the handler sees the intended ATYP byte instead of an extra zero that forced the address-type-not-supported path.

Validation: CARGO_TARGET_DIR=/tmp/bssh-256-libtests2-iA5MEz cargo test --lib forwarding::dynamic::socks::tests; CARGO_TARGET_DIR=/tmp/bssh-256-int2-CMiDkA cargo test --test socks_ipv6_literal_test; CARGO_TARGET_DIR=/tmp/bssh-256-check2-DPHEcE cargo check --lib --tests; CARGO_TARGET_DIR=/tmp/bssh-256-clippy-Y6LW6I cargo clippy --lib --tests -- -D warnings.
@inureyes
inureyes force-pushed the fix/issue-256-socks-ipv6-literals branch from 7a85ad1 to 74311c4 Compare August 3, 2026 11:43
@inureyes
inureyes merged commit 487819f into main Aug 3, 2026
3 checks passed
@inureyes
inureyes deleted the fix/issue-256-socks-ipv6-literals branch August 3, 2026 11:52
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: SOCKS5 dynamic forwarding rejects IPv6 destination literals (ATYP 0x04)

1 participant