badvpn icon indicating copy to clipboard operation
badvpn copied to clipboard

Add local response to ICMP PING requests (IPv4 & IPv6)

Open RPRX opened this issue 5 years ago • 10 comments

https://github.com/2dust/v2rayNG/issues/1027

高效实现,十分感谢 @yuhan6665 协助测试

RPRX avatar Apr 25 '21 12:04 RPRX

一些 APP 会使用 ping 来检测连通性,而 socks 不支持代理 icmp 流量,tun2socks 此前的行为则是不处理、不响应

RPRX avatar Apr 25 '21 14:04 RPRX

这个 PR 非常高效地实现了对 ping 请求的本地响应,支持 IPv4 和 IPv6,使这些 APP 可以正常工作

RPRX avatar Apr 25 '21 14:04 RPRX

What app? I do not assume any app relies on ping these days.

Mygod avatar Apr 25 '21 14:04 Mygod

@Mygod 比如 https://t.me/projectXray/424048

此外,实测 Netch 是本地响应 ping,@Dreamacro 说 Clash 也是本地响应 ping,我认为他们的做法具有参考意义,毕竟 ping 全丢是有些奇怪的事情,加个本地响应并不多余,可以减少一些非预期情况、解决一些潜在的问题

我使用的是 XTLS 的版本,这是一个礼貌性 PR,看你们是否需要了

RPRX avatar Apr 25 '21 15:04 RPRX

@madeye

根据原有代码,添加了 #define IPV4_PROTOCOL_ICMP 1#define IPV6_NEXT_ICMP 58;ping 和 ping6 那两段需要保持 hard code,因为它们与其 response 的差值决定了响应的 checksum 的快速算法,需要体现出来,且只有这里的代码在解析 ICMP,原有代码对这种情况也是 hard code

RPRX avatar Apr 26 '21 07:04 RPRX

If I understand correctly, does this respond to every single ping packet to every IP address? This is very confusing behavior and possibly a fingerprint for the VPN.

It is common for firewalls to block all ping traffic so no modern apps should ever expect ping to work.

Mygod avatar Apr 26 '21 15:04 Mygod

@Mygod

Well, my points are already clear above.

  1. And I don't see this behavior a fingerprint for the VPN, because it's not hard for an APP to find itself being proxied.
  2. It's definitely not common for firewalls to block all ping traffic. And you can't define what modern apps should do.
  3. But indeed we can make apps believe target's accessible whenever they want to ping, it's an access tool, after all.

It makes me feel better to see ping's available in Termux when I use v2rayNG, and it's beautiful, rather than no response. I believe Clash and Netch feel the same. So if you don't need this PR, you can just close it. At last, I respect @madeye's decision.

RPRX avatar Apr 26 '21 17:04 RPRX

刚刚尝试将 main 分支改名为 ping 以专用于此 PR,结果不行,麻烦尽快作出决定,因为若 main 有新的 commit 也会乱入这个 PR

RPRX avatar Apr 30 '21 09:04 RPRX

You can close this PR and open a new one with a new branch called ping

madeye avatar Apr 30 '21 09:04 madeye

@madeye Thanks for your advice, I'll keep this PR as is for now.

RPRX avatar Apr 30 '21 12:04 RPRX