0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-15 21:07:15 +03:00

transport: add httpupgrade

This commit is contained in:
Eken Chan
2024-03-03 13:12:38 +08:00
committed by yuhan6665
parent a3f50d0f5d
commit 173b03448f
11 changed files with 524 additions and 21 deletions

View File

@ -7,14 +7,15 @@ import (
)
type TransportConfig struct {
TCPConfig *TCPConfig `json:"tcpSettings"`
KCPConfig *KCPConfig `json:"kcpSettings"`
WSConfig *WebSocketConfig `json:"wsSettings"`
HTTPConfig *HTTPConfig `json:"httpSettings"`
DSConfig *DomainSocketConfig `json:"dsSettings"`
QUICConfig *QUICConfig `json:"quicSettings"`
GRPCConfig *GRPCConfig `json:"grpcSettings"`
GUNConfig *GRPCConfig `json:"gunSettings"`
TCPConfig *TCPConfig `json:"tcpSettings"`
KCPConfig *KCPConfig `json:"kcpSettings"`
WSConfig *WebSocketConfig `json:"wsSettings"`
HTTPConfig *HTTPConfig `json:"httpSettings"`
DSConfig *DomainSocketConfig `json:"dsSettings"`
QUICConfig *QUICConfig `json:"quicSettings"`
GRPCConfig *GRPCConfig `json:"grpcSettings"`
GUNConfig *GRPCConfig `json:"gunSettings"`
HTTPUPGRADEConfig *HttpUpgradeConfig `json:"httpupgradeSettings"`
}
// Build implements Buildable.
@ -101,5 +102,16 @@ func (c *TransportConfig) Build() (*global.Config, error) {
})
}
if c.HTTPUPGRADEConfig != nil {
hs, err := c.HTTPUPGRADEConfig.Build()
if err != nil {
return nil, newError("failed to build HttpUpgrade config").Base(err)
}
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
ProtocolName: "httpupgrade",
Settings: serial.ToTypedMessage(hs),
})
}
return config, nil
}