Skip to content

Conversation

@ljluestc
Copy link

The original issue requested the ability to connect to SSH servers through TCP proxies, which is essential for:

  • Corporate environments with proxy requirements
  • Development behind proxy firewalls
  • Secure access through proxy infrastructure
  • VPN-less remote server access

Solution Overview

Added complete SOCKS5 and HTTP CONNECT proxy support with the following features:

Core Features

  • SOCKS5 Proxy Support - Full protocol implementation
  • HTTP CONNECT Proxy Support - Standard HTTP tunneling
  • Authentication - Optional username/password for both proxy types
  • Backward Compatibility - No breaking changes to existing API
  • Error Handling - Comprehensive error reporting
  • Timeout Support - Configurable connection timeouts

API Design

  • Convenience Functions: NewSOCKS5ProxyConn(), NewHTTPProxyConn()
  • Manual Configuration: Enhanced Config struct with Proxy field
  • Type Safety: ProxyType enum for SOCKS5/HTTP proxy types
  • Clean Interface: Simple, intuitive API design

- Implement SOCKS5 and HTTP CONNECT proxy support
- Add proxy configuration structures and types
- Create proxy dialer functionality with authentication
- Add convenience functions for proxy connections
- Create comprehensive test suite with mock servers
- Update documentation and examples
- Add full integration tests and testing utilities

Proxy Types Supported:
- SOCKS5 proxy with optional authentication
- HTTP CONNECT proxy with optional authentication

Testing Features:
- Mock proxy servers for unit testing
- Integration tests with real proxy protocols
- Authentication testing scenarios
- Concurrent connection testing
- Error handling and timeout validation
- Fluent testing API for easy test setup

Files Added:
- proxy_test.go: Comprehensive unit tests
- proxy_test_utils.go: Mock server implementations
- proxy_integration_test.go: End-to-end integration tests
- proxy_test_helpers.go: Testing utilities and fluent API
- PROXY_TESTING_README.md: Complete testing documentation

Files Modified:
- client.go: Added proxy support and dialer logic
- README.md: Updated with proxy usage examples
- examples/goph/main.go: Added proxy command-line options
- go.mod: Added golang.org/x/net dependency
- goph_test.go: Added basic proxy configuration tests

This resolves GitHub issue melbahja#56: 'how to access remote server via a tcp proxy'
Add demo_proxy.go script that showcases:
- Proxy configuration examples
- Convenience function usage
- Real-world usage scenarios
- Error handling approaches
- Testing strategy overview
- Add core SOCKS5 and HTTP CONNECT proxy support
- Remove extensive testing suite, keep only essential code
- Reduce from 2,944 lines to ~300 lines (90% reduction)
- Keep only: client.go, go.mod, goph_test.go, README.md, examples/main.go

Resolves GitHub issue melbahja#56: access remote servers via TCP proxy
@melbahja
Copy link
Owner

Hey,
looks fine i will test this and then we can merge after some cleanups.
Thank you for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants