Skip to content

UDP noises: Add base64 and multi-packet support#3794

Merged
RPRX merged 10 commits intoXTLS:mainfrom
dragonbreath2000:udp-noise-base64_and_mulipacket_support
Sep 16, 2024
Merged

UDP noises: Add base64 and multi-packet support#3794
RPRX merged 10 commits intoXTLS:mainfrom
dragonbreath2000:udp-noise-base64_and_mulipacket_support

Conversation

@dragonbreath2000
Copy link
Contributor

This was per request of maintainers(mostly RPRX)
usage:

      {
        "protocol": "freedom",
        "settings": {
          "noise":[
          {
            "packet":"base64:7nQBAAABAAAAAAAABnQtcmluZwZtc2VkZ2UDbmV0AAABAAE=",
            "delay":"5-10"
          },
          {
            "packet":"rand:10-20",
            "delay":"10-20"
          }
        ]
        },
        "tag": "direct"
      }

the use of array is optional(to avoid a breaking change)
some cleanup is happened: used int32Range for delay instead of string,moved the config parsing part of noise to another function
now u can send as many noise packets as u want,the code will loop through and send all of them
u can add a base64 encoded string ,copy it straight from wireshark and boom
Note:if u want to use this with h3,do not send a quic client hello as noise,it will confuse the server and respond to that packet instead of intended one

@mmmray mmmray changed the title Udp noise base64 and mulipacket support UDP noise: Base64 and multi-packet support Sep 12, 2024
@yuhan6665
Copy link
Member

@RPRX

@RPRX
Copy link
Member

RPRX commented Sep 12, 2024

看起来换成了 SplitN

按照惯例,noise 改名 noises 以支持数组,noise 留下报错(参考 fallback->fallbacks)

@Fangliding
Copy link
Member

看起来换成了 SplitN

按照惯例,noise 改名 noises 以支持数组,noise 留下报错(参考 fallback->fallbacks)

本来就是故意同时支持数组和非数组避免break change的 这样不是白搞了

@Fangliding
Copy link
Member

我觉得现在这样就挺好的 单个noise就一个结构体 不用写数组 更简洁不用套一层中括号 也兼容上版本的写法
多个noise就上数组

@mmmray
Copy link
Contributor

mmmray commented Sep 12, 2024

I also like this form more, but if the convention in xray is to have separate pluralized keys, I think it is more important to follow it. I think xray suffers a lot from multiple ways of writing config, depending on who wrote a feature.

@dragonbreath2000
Copy link
Contributor Author

看起来换成了 SplitN

按照惯例,noise 改名 noises 以支持数组,noise 留下报错(参考 fallback->fallbacks)

Ok I will change it to noises
Do I keep the optional array type or remove it?personally I like to keep it since if I only want to have one noise why write a array but if that is the convention here then fine

@mmmray
Copy link
Contributor

mmmray commented Sep 13, 2024

If noise and noises exists, then they can each be object and array, and a dynamic Listable type is not necessary

}
if c.Noise != nil {
for _, n := range c.Noise {
return nil, errors.New(`Freedom settings: please use "noises":[{}] instead of "noise":{}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to maintain backwards compat, I suggest to append to config.Noises instead. The behavior when both are defined can be an error, I think.

NConfig, err := ParseNoise(n)
if err != nil {
return nil, err
return nil, errors.New(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this wrapping necessary?

@APT-ZERO
Copy link

APT-ZERO commented Sep 13, 2024

What do you think about a new option to merge current packet with next one?
needed when user wants to add a static data with a some random bytes between it [packet header + N random bytes + packet footer]
or you can make it when there is no delay between two packet, merge them by default (or if delay is '-1')

And a option to set multiple packets, and select one of them randomly
useful with a packet of DNS and a list of domains [packet header + list of multiple domains + packet footer]

Note:if u want to use this with h3,do not send a quic client hello as noise,it will confuse the server and respond to that packet instead of intended one

For direct connections(no cdn & no webserver), it is possible to hardcode fake packets in server and make it ignore the known fake packets, in this way it is possible to make noise to work with TCP too, when client sends known fake packets, must ignore it and continue the connections, fake packets + random data of vmess/ss+tcp for sure will bypass firewall

@dragonbreath2000
Copy link
Contributor Author

For direct connections(no cdn & no webserver), it is possible to hardcode fake packets in server and make it ignore the known fake packets, in this way it is possible to make noise to work with TCP too, when client sends known fake packets, must ignore it and continue the connections, fake packets + random data of vmess/ss+tcp for sure will bypass firewall

If we want to this to work for any tcp based protocol,it needs to be implemented in transport layer,not in freedom which is way outside the scope of this pr

@RPRX
Copy link
Member

RPRX commented Sep 15, 2024

不喜欢搞那么多语法糖,大道至简,这功能刚加的该 break 就 break,不然单个 inbound 和 outbound 就不该移除了

干脆彻底不兼容,参考 #3812 (comment) ,分成 type 和 value,别 SplitN 了,只要 noises,配置 noise 就报错

@RPRX
Copy link
Member

RPRX commented Sep 15, 2024

#3804 (comment)

@RPRX
Copy link
Member

RPRX commented Sep 15, 2024

分成 type 和 value,别 SplitN 了,只要 noises,配置 noise 就报错

@mmmray 有空改一下吗,不过能不能叫 type 我不确定

@Fangliding
Copy link
Member

确实该分 写文档的时候就觉得这写法老奇怪了

@Fangliding
Copy link
Member

我稍微改一下吧 这应该很简单

@Fangliding
Copy link
Member

分成 type 和 value,别 SplitN 了,只要 noises,配置 noise 就报错

@mmmray 有空改一下吗,不过能不能叫 type 我不确定

小改了一下 这样应该就可以了
可以叫type 之前我写的自定义sockopt结构其实和这个很类似
image

@RPRX
Copy link
Member

RPRX commented Sep 16, 2024

@RPRX
Copy link
Member

RPRX commented Sep 16, 2024

@Fangliding 把 type 移到最上面

@RPRX
Copy link
Member

RPRX commented Sep 16, 2024

@mmmray 可以帮忙改一下吗,感觉风扇好像没看到上两条评论

@mmmray
Copy link
Contributor

mmmray commented Sep 16, 2024

not sure I understood, here you go (I feel that providing an example of the new syntax is nice-to-have in the error msg)

@RPRX RPRX merged commit 363e86c into XTLS:main Sep 16, 2024
@RPRX RPRX changed the title UDP noise: Base64 and multi-packet support UDP noises: Add base64 and multi-packet support Sep 16, 2024
@Fangliding
Copy link
Member

@mmmray 可以帮忙改一下吗,感觉风扇好像没看到上两条评论

确实才看到 这不是github网页点一下小铅笔改就行了 换个行而已

@dragonbreath2000 dragonbreath2000 deleted the udp-noise-base64_and_mulipacket_support branch September 16, 2024 21:13
@RPRX
Copy link
Member

RPRX commented Sep 17, 2024

@Fangliding Freedom 标题改为 noises

@Fangliding
Copy link
Member

刚好有一些小修改 顺便加进去就好了

leninalive pushed a commit to amnezia-vpn/amnezia-xray-core that referenced this pull request Oct 29, 2024
dragonbreath2000 added a commit to dragonbreath2000/Xray-core that referenced this pull request Dec 11, 2024
dragonbreath2000 added a commit to dragonbreath2000/Xray-core that referenced this pull request Dec 12, 2024
it2konst pushed a commit to it2konst/gametunnel-core that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants