SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
17.84k stars 2.14k forks source link

[Feature Request] check status code in URLTest #1676

Closed liblaf closed 4 months ago

liblaf commented 4 months ago

Sometimes we can connect to a website, but it will deny access, such as returning 403. We should check status code in URLTest.

This feature should only require a few minor changes to the code shown below.

https://github.com/SagerNet/sing-box/blob/bf612bef5f8b27ff4d5cc7cf984cc422754d1dc1/common/urltest/urltest.go#L103-L121

[!WARNING] This feature may conflict with #1494.

Should this request be accepted, I can help make a PR.

hellodword commented 4 months ago

👏 Hi.

In my opinion, a trusted urltest endpoint should be trusted after the successful TLS handshake. There're too many reasons that may mess up the status code, such as some anti-bot rules of CDN. But for healthcheck (of sing-box), pingframe is enough, because we do not really care about the service status of the urltest endpoint, we only care about the (TLS) connection.