ShellCrash icon indicating copy to clipboard operation
ShellCrash copied to clipboard

[Bug] 代理常见端口对UDP流量不适用

Open hrz6976 opened this issue 7 months ago • 6 comments

Verify steps

  • [x] 我已经在 Issue Tracker 中找过我要提出的问题 I have searched on the issue tracker for a related issue.
  • [x] 我已经使用公测版本测试过,问题依旧存在 I have tested using the test mod, and the issue still exists.
  • [x] 我已经仔细看过 常见问题 并无法自行解决问题

Description

OS: Openwrt 24.10 snapshot 防火墙:nftables

在配置了仅代理常见端口后,我发现BT客户端仍然无法不通过代理直连境外Peer。研究了一下,发现问题出在这里:

https://github.com/juewuy/ShellCrash/blob/0d09ba9b2e61ab2ab4c1aad3dcdac9313f680acc/scripts/start.sh#L1233-L1237

当前仅代理常见端口防火墙规则无法匹配不开启fakeip、不使用tcp的流量。可以更改如下:

	#过滤常用端口
	[ -n "$PORTS" ] && {
		nft add rule inet shellcrash $1 tcp dport != {$PORTS} return
		nft add rule inet shellcrash $1 udp dport != {$PORTS} return
	}

iptables规则也许也存在一样的问题。

hrz6976 avatar Jun 11 '25 07:06 hrz6976

https://github.com/juewuy/ShellCrash/blob/0d09ba9b2e61ab2ab4c1aad3dcdac9313f680acc/scripts/start.sh#L999-L1002

这里的 -d 规则也许可以删除?不指向fake ip的流量直接accept应该不会造成什么问题

hrz6976 avatar Jun 11 '25 09:06 hrz6976

@hrz6976 fakeip的非常用端口流量是不适用过滤的,如果过滤掉会导致很多访问异常

juewuy avatar Jun 11 '25 10:06 juewuy

感谢回复!如果不使用fake ip(手动在dns.json内指定海外ip的dns走proxy)如此配置应该没有什么问题?

hrz6976 avatar Jun 11 '25 12:06 hrz6976

@hrz6976 不用fakeip可以无视

juewuy avatar Jun 11 '25 12:06 juewuy

我在dns.json中自定义了不使用fakeip的dns配置,但shellcrash里选择的是mix模式,可能这并不是标准的使用场景。如果我没有理解错的话,当前脚本nftables配置中并没有适用于udp的绕过规则,那需要添加这两行:

nft add rule inet shellcrash $1 ip daddr != {198.18.0.0/16} udp dport != {$PORTS} return 
nft add rule inet shellcrash $1 ip6 daddr != {fc00::/16} udp dport != {$PORTS} return 

hrz6976 avatar Jun 11 '25 18:06 hrz6976

@hrz6976 如非必要不建议绕过udp,可能会导致一部分代理异常

juewuy avatar Jun 12 '25 00:06 juewuy