Skip to content

Conversation

@markwylde
Copy link
Member

Summary

  • Adds policy-based routing to direct traffic through specific WireGuard peers
  • Introduces --exit-node flag for simple VPN-style routing
  • Implements --route flag for fine-grained routing control

Features

  • Exit Node Support: Use --exit-node=10.0.0.3 to route all traffic through a specific peer
  • Policy-Based Routing: Use --route=192.168.0.0/16:10.0.0.3 to route specific subnets
  • Configuration File Support: Define routes in WireGuard config with Route= directives
  • Routing Engine: Smart peer selection based on destination IP, protocol, and port

Usage Examples

# Route all traffic through peer at 10.0.0.3
wrapguard --config=wg0.conf --exit-node=10.0.0.3 -- curl https://example.com

# Route specific networks through different peers
wrapguard --config=wg0.conf \
  --route=192.168.0.0/16:10.0.0.3 \
  --route=172.16.0.0/12:10.0.0.4 \
  -- ssh internal.corp.com

Test Plan

  • Unit tests for routing engine and CLI parsing
  • Integration tests for peer selection logic
  • Manual testing with multiple peers and routes
  • Performance testing with complex routing tables

- Add RoutingEngine to manage routing decisions for WireGuard peers
- Support routing policies with destination CIDR, protocol, and port ranges
- Implement FindPeerForDestination to select appropriate peer for traffic
- Add parsing functions for routing policies and port ranges
- Add --exit-node flag to route all traffic through a specific peer
- Add --route flag to define custom routing policies (CIDR:peerIP)
- Implement ApplyCLIRoutes to apply routing policies from CLI
- Support for policy-based routing in config file with Route= directive
- Add RoutingEngine to tunnel for peer selection
- Update SOCKS5 dialer to use routing engine for destination selection
- Route traffic through appropriate peer based on policies
- Add routing engine to tunnel initialization
- Add routing section to README with exit node and policy-based routing
- Create example-routing.conf showing advanced routing configurations
- Add example-usage.sh with practical routing examples
- Update example config with routing policy examples
@markwylde markwylde merged commit aaa9911 into main Jun 26, 2025
3 checks passed
@markwylde markwylde deleted the feat/policy-based-routing branch June 26, 2025 22:46
@markwylde
Copy link
Member Author

This should fix the second issue in #15

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