-
Notifications
You must be signed in to change notification settings - Fork 4.9k
kcp masks #5560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
kcp masks #5560
Conversation
Announcement of NFTs by Project X: XTLS#3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 VLESS Post-Quantum Encryption: XTLS#5067 VLESS NFT: https://opensea.io/collection/vless XHTTP: Beyond REALITY: XTLS#4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2
|
|
|
让kcp能用 salamander 就差不多得了吧 那堆伪装就是兼容选项 这一break反而让它们没有意义了 让AI把它挪到udp mask就是把旧史搬上去 |
并不是 AI,我移了几天
这个头确实有问题,服务端回包格式和客户端发包格式是一样的,也许以后根据 rfc 改下就有资格上桌了
noise 要延迟发包和只加头或者异或/加密混淆不同,还不打算看这个,如果不需要 kcp mask 我就先去看 hy transport hub 了 |
|
那还是先弄hy入站吧 这个有用点 不然复现问题还得让人装个singbox非常难绷 |
|
正想把分享链接中那个 mKCP seed 删掉给 VLESS Seed 让位,所以 udpmasks 里别再叫 seed 了改名 psk 之类的吧 |
|
如果不是真正的前面就加个 |
|
@Fangliding 现在有了 hy2 要不把 kcp 删了吧,没几个人用就是说,现在想暴力发包的都去用 hy2 了 如果想用 VLESS 的 reverse 等特性,VLESS 也能接上 hy2 传输层, |
|
别 有人用的 |
|
他们用的逻辑不就是 kcp 还有那些伪装吗,那些伪装会被迁移到 udpmasks 然后催 UI 更新一下就能完全取代 kcp 了 |
|
我是觉得 UDP 可靠传输/暴力发包这块比起来土制协议还是全部基于 QUIC 更好,要什么外观把伪装叠上去就行 |
|
我觉得一个更精简的UDP协议还是有必要的 quic太重了 自己想改点都无从下手 |
|
也是那就先留着吧,不过等 udpmasks 弄差不多了、Xray 支持 hy2 服务端了,估计用 kcp 更没人用了, |
|
@LjhAUMEM 话说这 QUIC 库方便改 UDP 包最大长度不,不然 udpmasks 叠两层就炸了 |
|
@LjhAUMEM 还有 udpmasks 层能实现个统一的预留长度不,不然对于先弄成全随机数再叠上 fake header 来说性能上太吃亏了 |
|
无优化的“先弄成全随机数再叠上 fake header”直接多了一次没必要的 copy,所以肯定先要给后面的 udpmask 留一些头部空间 |
看了下只能设置 datagram 的包长度大小,对于 steam 的只能设置缓冲区大小,
应该可以在第一次 writeto 获取后面 header 的 size 和加密的 overhead 一起申请了,我看看, |
|
XOR 的本来就要多 copy 一次倒无所谓,只是有没有复用原内存的问题,不过 AEAD 的话 |
|
|
|
重构了一下 salamander 改为 buf 的实现,删掉了独有的缓冲区 现在每个 udpmask 都支持作为第一个 writeto 时为后面的写入预留空间, aead 加解密后的长度是会变化的,好消息是不会影响预留出来的空间,但是会延长后面的空间,如果作为 first 时申请的空间不够多可能会出问题 |
|
其实 salamander 搞这个缓冲区还是不错的,不然并发写入都 stacknew 一下有点难崩,可以只在 first 维护一个 8192 的缓冲区,后面的都共享这块读写 |
|
看了下 aead 加密后的长度其实是固定的,为 overhead+len(plaintext),然后 nonce 也要传过去再加个 nonceSize,我写了个 test 可以跑一下, udpmask 应该可以了,剩下的就是上配置文件测试, |
|
|
那你再研究一下吧,而且似乎它们传数据不是 query name 而是 txt 记录? |
|
整个DNS payload 加在一起不能超过512 之前研究过的 考虑到DNS Message还有其他东西要长也长不了很多 |
对,回传是 txt,1035 的 4.1.3 和 3.3.14 大小应该不太是问题,就是根据查询才能回包的机制有点恶心,好像还要搞个队列存服务器 writeto 的消息,还没看懂 turbotunnel 的 clientid 是不是必须的 |
这个直接用 pipe 就行 |
或许返回的时候告知客户端服务端还缓存了多少数据以触发多个并行查询,不过用户要配置个请求速率上限 空闲的时候也是,用户需要配置个一秒一次查询,合起来就是请求速率上下限吧,支持范围与随机
这个是用来区分承载的不同 TCP 流的吗 |
|
@LjhAUMEM 话说 udphop 的 port 是 range, 之前没让加是因为 udphop 本来就是强特征就无所谓,且官方版本没支持 range、分享链接也不支持, |
从行为上来看不是,把每个客户端的 pktconn 生成一个 clientid,服务端那边再存一个 clientid 和 addr 的 map,
ok,没问题,把 dnstt 完成之后就加 |
|
不用管 DNSTT 具体是怎么实现的,参考基本思路就行,不同的被代理的流肯定要加个 ID 来区分的放到 query name 中 |
|
Could you please add a Custom Mask for both Inbound and Outbound to mimic different UDP and TCP services? And my suggestion about DNSTT is that if you added it, please don't mention or document it so it get less attention, as it's easy to block |
freedom 出站的 udp noise 有计划加入,
所以放在 mask 里,只是个可选的玩具,但这放在只能使用 DNSTT 的国家确实是个问题,不过暂时不会加入 DOT 和 DOH, |
|
|
You are right About the Custom Mask, outbound already has noises feature, but the Inbound should be able to Approve it, and have a behavior to answer unauthenticated requests, or forwarded the unauthenticated incoming request to a real local server or remote server then forward it's response to the unauthenticated request And there is nothing for TCP also |
|
@LjhAUMEM 人家 DNSTT 是似乎是专有名称,不是实现那个协议的话换个名吧, |
哦哦可以, |
|
已在本地测试跑通,明天测试下公共 DNS 转发 顺便说下 mtu 计算方法,客户端最大 253(query name),域名中的点为分割一个 lable,单个 lable 最大 63,其中 8(clientid)+3(padding) 是占死的,还有设置的域名,以及 base32 编码的损耗,服务端最大 934 测试配置 {
"log": { "loglevel": "debug" },
"inbounds": [
{
"listen": "127.0.0.1",
"port": 1080,
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true
}
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"address": "127.0.0.1",
"port": 1081,
"id": "5783a3e7-e373-51cd-8642-c83782b807c5",
"encryption": "none"
},
"streamSettings": {
"network": "kcp",
"kcpSettings": {
"mtu": 100
},
"udpmasks": [
{
"type": "xdns",
"settings": {
"domain": "a.com"
}
}
]
}
}
]
}{
"log": { "loglevel": "debug" },
"inbounds": [
{
"listen": "127.0.0.1",
"port": 1081,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "5783a3e7-e373-51cd-8642-c83782b807c5"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "kcp",
"kcpSettings": {
"mtu": 900
},
"udpmasks": [
{
"type": "xdns",
"settings": {
"domain": "a.com"
}
}
]
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
} |
将 kcp header/security 移到 udpmasks
整理的过程发现两个问题,1. header 双端发送格式都是一样,2. kcp 的 ReadBuffer 参数并没有用到,
不过都是以后再说改动太大需要测试
已测试的配置,新旧 客 服 可双双互连
新客户端配置
{ "log": { "loglevel": "debug" }, "inbounds": [ { "listen": "127.0.0.1", "port": 1080, "protocol": "socks", "settings": { "auth": "noauth", "udp": true } } ], "outbounds": [ { "protocol": "vless", "settings": { "address": "127.0.0.1", "port": 1081, "id": "5783a3e7-e373-51cd-8642-c83782b807c5", "encryption": "none" }, "streamSettings": { "network": "kcp", "kcpSettings": { }, "udpmasks": [ { "type": "dtls" }, { "type": "aesgcm128", "settings": { "psk": "123" } } ] } } ] }新服务端配置
{ "log": { "loglevel": "debug" }, "inbounds": [ { "listen": "127.0.0.1", "port": 1081, "protocol": "vless", "settings": { "clients": [ { "id": "5783a3e7-e373-51cd-8642-c83782b807c5" } ], "decryption": "none" }, "streamSettings": { "network": "kcp", "kcpSettings": { }, "udpmasks": [ { "type": "dtls" }, { "type": "aesgcm128", "settings": { "psk": "123" } } ] } } ], "outbounds": [ { "protocol": "freedom" } ] }旧客户端配置
{ "log": { "loglevel": "debug" }, "inbounds": [ { "listen": "127.0.0.1", "port": 1080, "protocol": "socks", "settings": { "auth": "noauth", "udp": true } } ], "outbounds": [ { "protocol": "vless", "settings": { "address": "127.0.0.1", "port": 1081, "id": "5783a3e7-e373-51cd-8642-c83782b807c5", "encryption": "none" }, "streamSettings": { "network": "kcp", "kcpSettings": { "seed": "123", "header": { "type": "dtls" } } } } ] }旧服务端配置
{ "log": { "loglevel": "debug" }, "inbounds": [ { "listen": "127.0.0.1", "port": 1081, "protocol": "vless", "settings": { "clients": [ { "id": "5783a3e7-e373-51cd-8642-c83782b807c5" } ], "decryption": "none" }, "streamSettings": { "network": "kcp", "kcpSettings": { "seed": "123", "header": { "type": "dtls" } } } } ], "outbounds": [ { "protocol": "freedom" } ] }