smartdns icon indicating copy to clipboard operation
smartdns copied to clipboard

建议增加 HTTP 测速模式

Open Hill-98 opened this issue 2 years ago • 9 comments

现在的两种测速模式都不能很好的适用于所有场景,ping 模式对无法直接访问的 IP 无效,tcp 模式如果设备设置了透明代理,那么 tcp open port 会很低。而 HTTP 可以很好的解决以上两种测速模式的不足,测速时可以只发送 HEAD 请求以节省时间。

路由器如果开启透明代理,延迟就会变成下面这样:

> tcping google.com

Probing 172.217.26.78:80/tcp - Port is open - time=1.688ms
Probing 172.217.26.78:80/tcp - Port is open - time=3.357ms
Probing 172.217.26.78:80/tcp - Port is open - time=2.612ms
Probing 172.217.26.78:80/tcp - Port is open - time=1.805ms

Ping statistics for 172.217.26.78:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 1.688ms, Maximum = 3.357ms, Average = 2.366ms

> tcping baidu.com

Probing 110.242.68.66:80/tcp - Port is open - time=34.587ms
Probing 110.242.68.66:80/tcp - Port is open - time=91.384ms
Probing 110.242.68.66:80/tcp - Port is open - time=26.044ms
Probing 110.242.68.66:80/tcp - Port is open - time=29.195ms

Ping statistics for 110.242.68.66:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 26.044ms, Maximum = 91.384ms, Average = 45.303ms

Hill-98 avatar Jan 31 '23 18:01 Hill-98

功能方面同意 确实加代理的时候TCP端口测速不准 实现上感觉http头太重了 也没啥好思路

openips avatar Feb 01 '23 10:02 openips

支持

devnakx avatar Feb 02 '23 03:02 devnakx

最好的方案还是指定域名白名单,对指定域名不进行测速,查询走TLS或代理。

pymumu avatar Feb 11 '23 12:02 pymumu

我现在用的就是域名列表分流,遇到污染的域名手动加入列表。

Hill-98 avatar Feb 11 '23 14:02 Hill-98

http测速是不是类似于chrome的跨域请求预测试 感觉那是相当的慢 而且不正确的http头可能会导致服务器拒绝连接 我不建议这么干

PikuZheng avatar Feb 11 '23 14:02 PikuZheng

@PikuZheng 不是,只是类似于用户正常访问网站的一个请求,SmartDNS 已经知道域名,不会造成服务器拒绝连接。

Hill-98 avatar Feb 11 '23 15:02 Hill-98

@PikuZheng 不是,只是类似于用户正常访问网站的一个请求,SmartDNS 已经知道域名,不会造成服务器拒绝连接。

不会啊 很多网站都是跨域脚本 打开一个网页后要请求另一个域名 但是smartdns直接处理的话,是不可能有referer的

PikuZheng avatar Feb 11 '23 15:02 PikuZheng

@PikuZheng 基本没有什么域名对无 referer 做断开连接,顶多就是404、403之类的,而且即使是断开连接,也可以测到延迟。

Hill-98 avatar Feb 11 '23 15:02 Hill-98

Http(s) ping 我在下面那直接暴力 write GET / HTTP/1.1\r\n\r\n ,再读返回的第一行,然后关闭连接,不能读全部,服务端可能会返回大量数据导致变慢。能测速,好像没啥问题,nginx 443 会认 http,cloudflare 不认,只好加上 tls 再 write 了。

https://github.com/mokeyish/smartdns-rs/blob/c8845a3abde88aafcb98f209dc53153dd9166b7d/src/infra/ping.rs#L520

mokeyish avatar Mar 13 '23 15:03 mokeyish