Direct/Freedom outbound: Add ipsBlocked (supports IP, CIDR, "geoip:", "ext:") and apply a default safe policy#5947
Direct/Freedom outbound: Add ipsBlocked (supports IP, CIDR, "geoip:", "ext:") and apply a default safe policy#5947
ipsBlocked (supports IP, CIDR, "geoip:", "ext:") and apply a default safe policy#5947Conversation
|
虽然我不喜欢这个但是为了不恶心我自己的眼球其实有一个东西叫 Conn.RemoteAddr() |
|
以及UDP估计是没法管了 一个包匹一次那确实炸裂 |
|
|
|
|
|
@Fangliding 你直接动手吧,这块我除了之前 review 老哥 PR 的时候看过几次,基本全忘了现在,根本不熟 |
首先攻击向量来源于精心伪造请求的黑客(假设这种东西存在) 那用一个常规请求骗过去后续再往本地发是很自然的事情 所以匹首个目标没用 虽然我说了很多次掩耳盗铃但是这是最掩耳盗铃的 要么就认为认为UDP不会有威胁 少写两行代码 |
|
|
|
如果 json 里没有 |
|
|
|
为啥你们都看不起 ipmatcher |
func buildIPMatcher(rawRules ...string) IPMatcher {
rules, err := ParseIPRules(rawRules)
common.Must(err)
matcher, err := newIPRegistry().BuildIPMatcher(rules)
common.Must(err)
return matcher
}
func BenchmarkIPMatcherPrivate(b *testing.B) {
matcher := buildIPMatcher(
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.88.99.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"224.0.0.0/3",
"::/127",
"fc00::/7",
"fe80::/10",
"ff00::/8",
)
ip := net.IP{8, 8, 8, 8}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = matcher.Match(ip)
}
} |
|
|
我以为你是要默认 block 所有的 freedom |
|
|
This reverts commit f5145f7.
|
Freedom 出站判断入站是 VLESS、VMess、Trojan、Shadowsocks、Hysteria、WireGuard 这六个才默认 block private ip
|
|
|
|
okk 我还要想一下配置文件该怎么弄 |
|
|
|
如果用户没配置 ipsBlocked 就判断 ctx,如果用户配置了(或者没成员)就不用判断 |
|
关键在于没成员。。。 因为 infra/conf 那边传到 core 必须是个合法的 ip 规则,要么就是空数组也行 |
|
|
|
然后这里面的东西又不能写个魔法字符串,会报错的。除非硬改 geodata 太丑了 |
|
除非用户去写个 255.255.255.255 |
|
代码里全改一下"target IP is blocked: "->"blocked target IP: "
|
|
我再跑一下 test |
|
|
|
一堆测试都被 block 了,等我这老爷机跑完一轮,我挨个加策略 |
|
return defaultPrivateBlockIPMatcher 的时候加个日志告诉用户吧?要什么级别的 |
|
一亿个测试都被安全策略拦截,我批量替换了直接 |
|
发版吧,发完回头会有一堆人说小鸡连不上的 |
|
对外只暴露 443 然后就只能 console 了 |
|
info 吧,逐包拦截的日志改为 debug, |
|
说到 debug 我记得有不少热点代码都有这玩意 |
|
光生产不消费,跟某国经济一样 |
ipsBlocked (supports IP, CIDR, "geoip:", "ext:") and apply a default safe policyipsBlocked (supports IP, CIDR, "geoip:", "ext:") and apply a default safe policy
保险起见我先把 WG 从 XUDP Global ID 的判断里摘掉吧,也就是 WG 入加 VLESS/VMess/Mux 出的 XUDP 没有 Global ID 了 |
|
|
不知道为啥不用现成的轮子,这里的实现的确有点辣眼睛 |
|
ipmatcher 的 cidr 应该支持取反语义 比如反向代理只想放通 127.0.0.1:80 现在办不到 |
|
重新在freedom做一套路由。。 |
最多算个 acl 吧 xray-enterprise 这不就来了吗 |
|
总之这个 PR 所实现的 TCP 只看 dial 后的 remoteAddr,以及 UDP 逐包匹配确实封得更彻底,没有死角了 再做绝些就是把 UDP 回包也过滤一下,来自那些地址的话就 drop 掉,@Meo597 PR 一下吧
|
|
回包过滤意义不大吧 |
|
怎么说呢,从 |
#5892 (comment)