Skip to content

feat: implement incoming connections#16

Merged
markwylde merged 7 commits intomainfrom
feat/implement-incoming
Jun 20, 2025
Merged

feat: implement incoming connections#16
markwylde merged 7 commits intomainfrom
feat/implement-incoming

Conversation

@markwylde
Copy link
Member

@markwylde markwylde commented Jun 20, 2025

This PR implements a comprehensive overhaul of WrapGuard to support incoming connections through a SOCKS5
proxy and WireGuard tunnel system. The changes include:

  • SOCKS5 Proxy Implementation: Added a SOCKS5 proxy server to handle incoming connections and route
    traffic through the WireGuard tunnel
  • Enhanced Configuration System: Restructured config parsing with better validation and wireguard-go
    compatibility
  • Modernized Tunnel Management: Replaced custom network implementation with wireguard-go integration
    for better stability
  • Structured Logging: Implemented JSON-based structured logging with configurable levels
  • Docker Demo Environment: Added comprehensive demo showing Node.js applications communicating via
    WireGuard
  • Improved Build System: Enhanced Makefile with cross-platform builds, testing, and development tools

Key Features

SOCKS5 Proxy Support

  • Full SOCKS5 protocol implementation for handling incoming TCP connections
  • Automatic traffic routing through WireGuard tunnel
  • Support for both IPv4 and IPv6 connections

Enhanced WireGuard Integration

  • Direct integration with wireguard-go library
  • Proper TUN interface management
  • Improved packet routing and handling
  • Better error handling and connection stability

Docker Demo

  • Complete Docker-based demonstration environment
  • Shows real-world usage with Node.js HTTP servers
  • Automated setup and key generation
  • Cross-container communication through WireGuard tunnel

Technical Changes

Configuration System

  • Converted config parser to use string-based fields for better compatibility
  • Added base64 to hex conversion for wireguard-go IPC protocol
  • Implemented hostname resolution for endpoints
  • Enhanced validation with proper error messages

Logging System

  • Replaced simple logging with structured JSON output
  • Added configurable log levels (debug, info, warn, error)
  • Included request/response logging for debugging
  • Better error context and tracing

Build System

  • Modernized Makefile with comprehensive targets
  • Added cross-platform build support (Linux, macOS)
  • Included testing, formatting, and linting tools
  • Debug build configuration with symbols

Test Coverage

  • Config parsing: Comprehensive tests for all configuration scenarios
  • SOCKS5 proxy: Full protocol implementation testing
  • Traffic forwarding: Bidirectional data flow validation
  • Tunnel management: TUN interface and routing tests
  • Logging system: Structured output and level filtering tests

Breaking Changes

  • Configuration file format remains compatible but internal parsing has changed
  • Command-line interface is preserved for backward compatibility
  • C library interface updated for better integration

Demo Usage

cd demo
./setup.sh
docker compose up --build

This will start a WireGuard server and two Node.js applications that communicate through the tunnel without
 requiring root privileges or kernel modules.

Test Plan

- Build system works on Linux and macOS
- All unit tests pass (make test)
- Demo environment runs successfully
- SOCKS5 proxy handles connections correctly
- WireGuard tunnel establishes and routes traffic
- Configuration parsing works with existing configs
- Logging output is properly structured
- Cross-platform compatibility maintained

markwylde and others added 7 commits June 20, 2025 19:57
- Rewrite config parser to use string-based fields instead of net types
- Add base64 to hex conversion for wireguard-go compatibility
- Implement endpoint hostname resolution
- Add comprehensive config validation
- Update example configuration with realistic settings
- Remove IPv6-specific test file in favor of unified testing
- Create comprehensive demo showing Node.js apps communicating via WireGuard
- Add Docker containers for WireGuard server and client applications
- Include automated key generation and setup scripts
- Add test client for validation
- Update README with demo instructions
- Replace simple logging with structured JSON logger
- Add configurable log levels and output formatting
- Include request/response logging for debugging
- Update all components to use new logger interface
- Add SOCKS5 proxy server for handling incoming connections
- Implement traffic forwarder for routing between interfaces
- Add bidirectional data forwarding with proper connection handling
- Include comprehensive tests for proxy and forwarding logic
- Replace custom network implementation with wireguard-go integration
- Add TUN interface creation and management
- Implement proper packet routing and handling
- Update IPC communication for tunnel control
- Remove deprecated network and memory TUN implementations
- Modernize Makefile with comprehensive build targets
- Add support for cross-platform builds and testing
- Include debug builds and code formatting tools
- Update Go modules and dependencies
- Remove deprecated test scripts
- Add main function tests
@markwylde markwylde merged commit 9e9fe90 into main Jun 20, 2025
1 of 5 checks passed
@markwylde markwylde deleted the feat/implement-incoming branch June 20, 2025 19:01
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.

1 participant