HTTPUpgrade 0-RTT (#3152)

* Add ed to enable HTTPUpgrade 0-RTT

https://github.com/XTLS/Xray-core/issues/3128#issuecomment-2002563369

* WebSocket hub.go MaxHeaderBytes: 4096 -> 8192
This commit is contained in:
RPRX 2024-03-17 20:43:19 +00:00 committed by GitHub
parent 69e1734e3a
commit 18b823b4a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 17 deletions

View file

@ -172,12 +172,10 @@ func (c *WebSocketConfig) Build() (proto.Message, error) {
}
}
config := &websocket.Config{
Path: path,
Header: header,
Ed: ed,
}
if c.AcceptProxyProtocol {
config.AcceptProxyProtocol = c.AcceptProxyProtocol
Path: path,
Header: header,
AcceptProxyProtocol: c.AcceptProxyProtocol,
Ed: ed,
}
return config, nil
}
@ -190,12 +188,22 @@ type HttpUpgradeConfig struct {
// Build implements Buildable.
func (c *HttpUpgradeConfig) Build() (proto.Message, error) {
config := &httpupgrade.Config{
Path: c.Path,
Host: c.Host,
path := c.Path
var ed uint32
if u, err := url.Parse(path); err == nil {
if q := u.Query(); q.Get("ed") != "" {
Ed, _ := strconv.Atoi(q.Get("ed"))
ed = uint32(Ed)
q.Del("ed")
u.RawQuery = q.Encode()
path = u.String()
}
}
if c.AcceptProxyProtocol {
config.AcceptProxyProtocol = c.AcceptProxyProtocol
config := &httpupgrade.Config{
Path: path,
Host: c.Host,
AcceptProxyProtocol: c.AcceptProxyProtocol,
Ed: ed,
}
return config, nil
}