Skip to content

Conversation

@ibigbug
Copy link
Member

@ibigbug ibigbug commented Jul 7, 2025

🤔 This is a ...

  • New feature
  • Bug fix
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

#579
#847
#719

💡 Background and solution

use tun-rs from #719 (comment)

---
port: 8888

log-level: trace

ipv6: true

dns:
  ipv6: true

tun:
  enable: true
  device-id: "dev://utun1989"
  route-all: true
  gateway: "198.19.0.1/24"
  gateway-v6: "fd00:fac::1/64"
  so-mark: 3389
  dns-hijack: false
  # dns-hijack:
  #   - 1.1.1.1:53
  routes:
    - 1.1.1.1/32
    - 2001:4860:4860::8888/128
    - 2404:6800:4006:810::200e/128

rules:
  - MATCH, DIRECT

📝 Changelog

  • assign tun ipv6 address
  • new_tcp/udp_socket stack selection logic
  • auto config routes for v6

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Changelog is provided or not needed

@ibigbug ibigbug marked this pull request as draft July 7, 2025 16:27
@ibigbug ibigbug requested a review from Copilot July 10, 2025 18:41

This comment was marked as outdated.

@ibigbug ibigbug marked this pull request as ready for review July 11, 2025 16:22
@ibigbug ibigbug requested a review from Copilot July 11, 2025 16:22
@ibigbug ibigbug changed the title feat(tun): ipv6 support feat(tun): support ipv6 on tun inbound Jul 11, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances TUN support by adding IPv6 configuration, addressing, and routing across platforms, and switches to the tun-rs crate for TUN device management.

  • Introduce gateway_v6 in TunConfig and auto-configure IPv6 routes
  • Replace the legacy tun crate with tun-rs and refactor TUN initialization
  • Refactor network interface handling to use a richer OutboundInterface type

Reviewed Changes

Copilot reviewed 41 out of 43 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/check_socks5.py Add IPv6 DNS probe and validation in the SOCKS5 check script
clash-lib/src/config/internal/config.rs Extend TunConfig with gateway_v6 support
clash-lib/src/app/net/mod.rs Introduce OutboundInterface with IPv6 fields and helpers
clash-lib/src/proxy/utils/socket_helpers.rs Update TCP/UDP socket helpers to select IPv6 sockets by interface
clash-lib/src/proxy/tun/routes/macos.rs Add IPv6 route handling in macOS TUN route commands
clash-lib/src/app/logging.rs Improve default log-level parsing fallback behavior
Comments suppressed due to low confidence (2)

scripts/check_socks5.py:42

  • The return True is unconditionally executed and is not indented under the preceding if, causing the subsequent else to be unmatched. Indent the return True inside the if block or restructure the conditional to ensure the else pairs correctly.
        return True

clash-lib/src/proxy/utils/socket_helpers.rs:62

  • Named placeholders {iface:?} and {family:?} in a debug! format string without passing named arguments will not compile. Use positional placeholders and pass iface and family as arguments, e.g., "binding tcp socket to interface: {:?}, family: {:?}", iface, family.
        debug!("binding tcp socket to interface: {iface:?}, family: {family:?}");

}
}

if gateway_v4.is_none() {
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error condition only checks for a missing IPv4 gateway and will fail even if an IPv6 gateway is present. Update the final check to if gateway_v4.is_none() && gateway_v6.is_none() so that success is allowed when either gateway exists.

Suggested change
if gateway_v4.is_none() {
if gateway_v4.is_none() && gateway_v6.is_none() {

Copilot uses AI. Check for mistakes.
@ibigbug ibigbug merged commit 13e4adc into master Jul 12, 2025
34 of 35 checks passed
@ibigbug ibigbug deleted the tun-ipv6 branch July 12, 2025 16:12
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