Enhanced SOCKS5 implementation and username validation improvements#35
Conversation
This adds support for the -T flag which disables pseudo-terminal allocation during SSH sessions. This flag is required for VSCode's Remote SSH extension to function properly. Changes: - Add -T flag definition to disable PTY allocation - Update interactiveSession to respect the disablePTY flag - Thread disablePTY parameter through runSSH function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements SOCKS5 dynamic port forwarding to support VSCode Remote SSH extension. The -D flag allows specifying a local port or bind_address:port that will act as a SOCKS5 proxy, forwarding connections through the SSH tunnel. Changes: - Add -D flag to accept [bind_address:]port specification - Implement setupDynamicForward to create local SOCKS5 listener - Implement handleSOCKS5 for full SOCKS5 protocol handling - Support IPv4, IPv6, and domain name address types - Add bidirectional data forwarding between client and remote The implementation handles: - SOCKS5 handshake (version 5, no authentication) - Connection requests (CONNECT command) - Address parsing (IPv4, IPv6, domain names) - SSH tunnel forwarding to target addresses - Proper error responses per SOCKS5 spec 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
SSH usernames commonly include dots (e.g., first.last) which are valid according to most Unix systems. The previous validation incorrectly rejected usernames containing dots. Changes: - Update ValidateSSHUser regex to allow dots in usernames - Add test cases for usernames with single and multiple dots - Update error message to reflect dot is now allowed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhances the SOCKS5 dynamic port forwarding feature with: Security improvements: - Add bind address validation to prevent unintended network exposure - Validate bind address is a valid IP or localhost - Warn users when binding to non-localhost addresses - Allow localhost, 127.0.0.1, ::1, 0.0.0.0, and :: with warnings Error handling improvements: - Better error handling in listener goroutine - Distinguish between normal shutdown and actual errors - Check for context cancellation and closed connections - More informative error messages Lifecycle management: - Add context for graceful shutdown of SOCKS5 listener - Proper cleanup when SSH session ends - Prevent orphaned goroutines and listeners Comprehensive testing: - Add tests for dynamic forward spec parsing - Add tests for SOCKS5 address parsing (IPv4, IPv6, domain) - Add tests for SOCKS5 protocol versions - Add tests for SOCKS5 commands - Add tests for bind address security validation - Test port validation and various bind address formats All changes maintain backward compatibility while improving security and reliability of the SOCKS5 proxy feature. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
Update both README.md and CLAUDE.md to reflect recent changes: README.md updates: - Add SOCKS5 dynamic port forwarding to core features - Document -D flag for SOCKS5 proxy (VSCode Remote SSH compatible) - Document -T flag to disable PTY allocation - Add comprehensive SOCKS5 examples with security notes - Add PTY control examples - Note support for dots in usernames (e.g., first.last) CLAUDE.md updates: - Update core features list with SOCKS5 and PTY control - Add SOCKS5 and -T flag usage examples - Update code structure statistics (~700 lines main.go, ~850 lines tests) - Add SOCKS5 proxy debugging workflow - Document recent changes from PR #33 and PR #34 - Update total line count to ~5,250 lines Documentation now accurately reflects the enhanced functionality while maintaining the project's philosophy of simplicity.
|
Claude finished @derekg's task —— View job Pull Request ReviewReviewing PR #35: Enhanced SOCKS5 implementation and username validation improvements 🔍 Overall Assessment: EXCELLENTThis PR successfully adds significant functionality while maintaining the project's core philosophy of simplicity. The implementation is well-structured, thoroughly tested, and properly documented. ✅ StrengthsCode Quality & Architecture
Security Enhancements
Test Coverage
|
Summary
This PR enhances ts-ssh with SOCKS5 dynamic port forwarding, improved username validation, and PTY control features. All changes maintain the project's simplicity philosophy while adding essential functionality for modern SSH workflows.
Changes Included
SOCKS5 Dynamic Port Forwarding (Enhanced PR #33)
-D [bind_address:]portflag for SOCKS5 proxy supportUsername Validation Enhancement (PR #34)
first.last)^[a-zA-Z0-9_\-\.]+$PTY Control
-Tflag to disable pseudo-terminal allocationDocumentation
Security Improvements
Bind Address Validation:
Error Handling:
Testing
Added comprehensive test coverage:
TestParseDynamicForwardSpec- Forward spec parsingTestSOCKS5AddressParsing- IPv4/IPv6/domain parsingTestSOCKS5ProtocolVersions- Protocol version validationTestSOCKS5Commands- Command support testingTestBindAddressSecurity- Security validation testingCode Quality
go fmtExamples
SOCKS5 Proxy