Skip to content

初步实现 TProxy IPv6 透明代理 - #1318

Merged
vernesong merged 6 commits into
vernesong:masterfrom
EkkoG:IPv6_support
Aug 22, 2021
Merged

vernesong merged 6 commits into
vernesong:masterfrom
EkkoG:IPv6_support

Conversation

@EkkoG

@EkkoG EkkoG commented Mar 29, 2021 •

Copy link
Copy Markdown
Contributor

说明

  1. IPv6 TCP+UDP 都走 TProxy
  2. IPv6 所有流量都经过 Clash

测试 ipk

luci-app-openclash_0.43.01-beta_all.ipk.zip

TCP 测试

$ curl -6 https://www.google.com/ -v > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 2404:6800:4005:80b::2004:443...
* Connected to www.google.com (2404:6800:4005:80b::2004) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* TLS 1.2 connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate: www.google.com
* Server certificate: GTS CA 1O1
* Server certificate: GlobalSign
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fe29880f600)
> GET / HTTP/2
> Host: www.google.com
> user-agent: curl/7.71.1
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0< HTTP/2 302
< location: https://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=https://www.google.com.hk/&ust=1617001044461397&usg=AOvVaw3mSsTaABMACaOZJhgSpaDZ
< cache-control: private
< content-type: text/html; charset=UTF-8
< p3p: CP="This is not a P3P policy! See g.co/p3phelp for more info."
< date: Mon, 29 Mar 2021 06:56:54 GMT
< server: gws
< content-length: 372
< x-xss-protection: 0
< x-frame-options: SAMEORIGIN
< set-cookie: 1P_JAR=2021-03-29-06; expires=Wed, 28-Apr-2021 06:56:54 GMT; path=/; domain=.google.com; Secure
< set-cookie: NID=212=BIzRA5SsqWjgyHLSNIoSX868ww-P7S8i0i0mfupYOHsJV2TWuGGsoyZOL7Qy01Z2m9nMiZjUMXgO2Ol4t9oKvyqGF2wlTrZCZOGJhJFxbUDA_WWt0KBzaTpeIc3r3CQOEynPp4OJdeeQEibZpH8rFJNft33_0mcqKqkGPLbibFY; expires=Tue, 28-Sep-2021 06:56:54 GMT; path=/; domain=.google.com; HttpOnly
< alt-svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
<
{ [372 bytes data]
100   372  100   372    0     0    732      0 --:--:-- --:--:-- --:--:--   730
* Connection #0 to host www.google.com left intact

UDP 测试


time="2021-03-30T18:55:28Z" level=info msg="[UDP] [240e:xxxx::9e2]:48762 --> imciel.com match Match() using 🚀 Proxy[x1.0 美西 - 直连2]"



➜  ~ docker run -it --network bridge  --rm cielpy/curl-http3:7.75.0-0.7.0 curl -ILv --http3 --max-time 8 https://imciel.com/ -6
*   Trying 2606:4700:3031::6815:4b73:443...
* Connect socket 5 over QUIC to 2606:4700:3031::6815:4b73:443
* Sent QUIC client Initial, ALPN: h3-29,h3-28,h3-27
* Connected to imciel.com () port 443 (#0)
* h3 [:method: HEAD]
* h3 [:path: /]
* h3 [:scheme: https]
* h3 [:authority: imciel.com]
* h3 [user-agent: curl/7.75.0-DEV]
* h3 [accept: */*]
* Using HTTP/3 Stream ID: 0 (easy handle 0x559305d1d180)
> HEAD / HTTP/3
> Host: imciel.com
> user-agent: curl/7.75.0-DEV
> accept: */*
>
< HTTP/3 200
HTTP/3 200
< date: Tue, 30 Mar 2021 18:55:28 GMT
date: Tue, 30 Mar 2021 18:55:28 GMT
< content-type: text/html; charset=utf-8
content-type: text/html; charset=utf-8
< set-cookie: __cfduid=daaf041b414af76b452bde17dc305054f1617130528; expires=Thu, 29-Apr-21 18:55:28 GMT; path=/; domain=.imciel.com; HttpOnly; SameSite=Lax
set-cookie: __cfduid=daaf041b414af76b452bde17dc305054f1617130528; expires=Thu, 29-Apr-21 18:55:28 GMT; path=/; domain=.imciel.com; HttpOnly; SameSite=Lax
< cache-control: public, max-age=0, must-revalidate
cache-control: public, max-age=0, must-revalidate
< cf-cache-status: DYNAMIC
cf-cache-status: DYNAMIC
< cf-request-id: 092616b74c0000ed3f2696b000000001
cf-request-id: 092616b74c0000ed3f2696b000000001
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< report-to: {"max_age":604800,"group":"cf-nel","endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=i1Z5TLmAGpn4MG6JX7D630Zp9X8Wr6Z%2BOBTndBS3uPlslfr6sHn8arJCvOw6hhpkIZrSsl1c653KrzHkTj4RH96JAe%2FUkl087NzY"}]}
report-to: {"max_age":604800,"group":"cf-nel","endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=i1Z5TLmAGpn4MG6JX7D630Zp9X8Wr6Z%2BOBTndBS3uPlslfr6sHn8arJCvOw6hhpkIZrSsl1c653KrzHkTj4RH96JAe%2FUkl087NzY"}]}
< nel: {"report_to":"cf-nel","max_age":604800}
nel: {"report_to":"cf-nel","max_age":604800}
< vary: Accept-Encoding
vary: Accept-Encoding
< x-content-type-options: nosniff
x-content-type-options: nosniff
< server: cloudflare
server: cloudflare
< cf-ray: 63838d6bac34ed3f-SJC
cf-ray: 63838d6bac34ed3f-SJC
< alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
* Connection #0 to host imciel.com left intact

相关 issue

#1311 #1072 #1078

剩余工作

  • 确认 UDP 工作正常 (缺测试用例)
  • 适配绕过中国大陆IP模式
  • 适配仅允许常用端口流量
  • 其他?

@EkkoG EkkoG changed the title 初步实现 TProxy IPv6 支持 初步实现 TProxy IPv6 透明代理 Mar 29, 2021
@JosephCN

Copy link
Copy Markdown

ipv6的支持有啥新的进展不这两天

@icucuio

icucuio commented Apr 20, 2021

Copy link
Copy Markdown

0.43.01 还没有发布?
我看最新的是0.42.04?
咋回事?
luci-app-openclash_0.43.01-beta_all.ipk.zip

@EkkoG

EkkoG commented Apr 20, 2021

Copy link
Copy Markdown
Contributor Author

0.43.01 还没有发布?
我看最新的是0.42.04?
咋回事?
luci-app-openclash_0.43.01-beta_all.ipk.zip

版本号是随便改的,跟项目的版本号没关系

@EkkoG

EkkoG commented Apr 20, 2021

Copy link
Copy Markdown
Contributor Author

ipv6的支持有啥新的进展不这两天

没有进展,这个用法有点复杂,最近在关注另一个项目来解决这个问题

@icucuio

icucuio commented Apr 20, 2021

Copy link
Copy Markdown

0.43.01 还没有发布?
我看最新的是0.42.04?
咋回事?
luci-app-openclash_0.43.01-beta_all.ipk.zip

版本号是随便改的,跟项目的版本号没关

也就是现在还不能开启ipv6,是吗?

@EkkoG

EkkoG commented Apr 20, 2021

Copy link
Copy Markdown
Contributor Author

0.43.01 还没有发布?
我看最新的是0.42.04?
咋回事?
luci-app-openclash_0.43.01-beta_all.ipk.zip

版本号是随便改的,跟项目的版本号没关

也就是现在还不能开启ipv6,是吗?

https://github.com/vernesong/OpenClash/releases 这里的包,不包含本 PR 的代码,不支持代理 IPv6

@vernesong
vernesong merged commit e7f1a85 into vernesong:master Aug 22, 2021
@paladin4fan

Copy link
Copy Markdown
Contributor

当前模式下所有IPv6流量过Openclash 是指经过插件内核还是指要走代理流量?

@EkkoG

EkkoG commented Sep 9, 2021

Copy link
Copy Markdown
Contributor Author

当前模式下所有IPv6流量过Openclash 是指经过插件内核还是指要走代理流量?

@paladin4fan clash 内核本身的流量直接出去

@LisonFan

LisonFan commented Sep 10, 2021 •

Copy link
Copy Markdown

Redir-Host 模式下 v6 流量不经过 Clash
还需要设置哪吗?
目前使用的版本是v0.43.04-beta
image
image
image

@EkkoG

EkkoG commented Sep 10, 2021

Copy link
Copy Markdown
Contributor Author

使用问题建议在 disccussion 区再开一贴讨论吧,这个 PR 只是添加了基本功能(接管流量)

solomonricky pushed a commit to solomonricky/OpenClash that referenced this pull request May 6, 2022
* feat: initial IPv6 TProxy support

* chore: fixed typo

* fix: TProxy mode traffic loop

* fix: remove clash rule in OUTPUT and PREROUTING chain when stoped

* chore: remove unused rule and refine rules

* fix: tproxy_port emtpy when upgrade from old version
@by-justin by-justin mentioned this pull request Jan 30, 2023
4 tasks done
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.

6 participants