-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New feature: Happy Eyeballs (RFC 8305) #4667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
最好只留一个delay,大于0代表启用,别的取默认就行了。结构体套娃最好少一点。maxConcurrentTry 4够了 算上 v6 8也够了,或者智能一点,单栈取4双栈取8,它的主要作用是遇到奇葩域名别一次性dial出去几十个连接。interleave选1就好。prioritizeIPv6字段没必要。prefer从前面的domainstrategy获取,比如 ForceIPv4v6 就是 prefer v4 |
first, thanks for your feedback and reviewing my code.
|
只查v4/6是之前结构下的无奈之举 因为只能随机roll一个IP出来 在这种情况下可以手动两种都查
python选项里有不代表要搬到golang的xray的config里来 我实在看不到这有啥配置的必要
很多时候一个域名下面应该不会存在那么多的IP 大于4个的A记录和AAAA都挺少见
设置为0禁用或者启用一个功能很常见 如果真的想快速发出一堆请求 设置为1并没有什么不同 说这么多主要目的还是为了压缩到只剩一个选项 当然只是我觉得这样更好 |
I explained the necessity of each of the options. |
看起来这个 PR 还在讨论中,所以四月累积更新版本暂不包含这个 PR |
Even @Fangliding accepted that. But he says to remove the extra-options and I explained to him why these options are needed, there is no other difference. Changing happy-eyeballs default parameters is useful for serverless-for-Iran (my main goal) and other goals. So please merge it as soon as possible, I have written these for almost a month. |
happy-eyeballs is a feature that most users don't need to know about, It is enabled by default for everyone and increases the quality of their Internet usage. They don't need to change anything in the configuration. It is true that the default values are sufficient for most users, but in many cases they need to be changed, so the existence of these options is essential. |
如果 Chrome 已经有了这样的行为则 Xray 可以默认改成一样的行为 |
If you are worried about Detection by firewall and different behavior Each connection Is independent and each connection behavior is similar to Chrome. So there is no need to worry about this. |
只是 Xray 不应出现过于独特的行为,要么 Golang 要么 Chrome 要么非默认 |
I implemented rfc-8305 exactly, and this is exactly python happy-eyeballs. So the behavior is exactly Python's behavior. |
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_connection I already looked at the Python codes, and my happy-eyeballs is exactly python's happy-eyeballs. |
i remove any other questions? |
when using "AsIs" mode, golang controls how to connect to a "domain" address.
currently, golang use RFC-6555 to connect to the domains, although it is obsolete, but it is better than nothing. it solve the problem when one IP-type is unreachable. but regardless of the IP type, some IPs may not be available, thus RFC 8305 was created #4473 (comment)
RFC 6555 is obsoleted by RFC 8305, and python use RFC-8305 from v3.8.
///
anyway, It doesn't matter what RFC is implemented for the "AsIs" mode, because we should use built-in-dns to bypass GFW DNS spoofing,
and for "useIP/forceIP" mode, we don't even have RFC-6555, and only one random IP is selected.
and also Iran-GFW blocked some range-IPs of meta(facebook, instagram,...) and some not, so with happy-eyeballs iranian-users can access instagram without using any server.(in 99% cases)
as a result, I implemented Happy Eyeballs RFC-8305 for "forceIP/useIP" mode.
///
because happy eyeballs only applies when sockopt-domainStrategy is "forceIP/useIP" and this options are in "sockopt" settings, so i put "happyEyeballs" settings in "sockopt" settings.
///
we can use happy eyeballs for all type of proxy: freedom, vless, ...
///
///
prioritizeIPv6
( bool): indicate "First Address Family" in RFC-8305, default is false(= prioritizeIPv4)interleave
(uint32): indicate "First Address Family count" in RFC-8305, default is 1maxConcurrentTry
(uint32): maximum concurrent attempt (this is only maximum and in most cases our concurrent attempts is less, unless all connection fail to connect) also we can always have a maximum of concurrent-attempt as many IPs as we have, and this option is useful when the number of IPs is too high, and we want to control the number of concurrent-attempts, default is 4. if it is 0, happy-eyeballs is disabled.tryDelayMs
: delay time between each attempt, RFC-8305 recommend 250ms, so the default is 250. if it is 0, happy-eyeballs is disabled.///
for example suppose our IP-list is [ip4-1, ip4-2, ip4-3, ip4-4, ip6-1, ip6-2, ip6-3, ip6-4]
when
interleave
is 1 andprioritizeIPv6
is false, the sorted-ip-list is:[ip4-1, ip6-1, ip4-2, ip6-2, ip4-3, ip6-3, ip4-4, ip6-4]
and when for example
interleave
is 2 andprioritizeIPv6
is true:[ip6-1, ip6-2, ip4-1, ip4-2, ip6-3, ip6-4, ip4-3, ip4-4]
then delay 250ms for each attempt until first connection is established.
the first-stablished-connection is winner connection and selected for sending/receiving data.