mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
Added json configure file parsing of h2 transport
This commit is contained in:
parent
2847bc3271
commit
1d7e497599
@ -13,6 +13,7 @@ import (
|
||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
|
||||
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
||||
"github.com/v2fly/v2ray-core/v4/transport/internet/domainsocket"
|
||||
httpheader "github.com/v2fly/v2ray-core/v4/transport/internet/headers/http"
|
||||
"github.com/v2fly/v2ray-core/v4/transport/internet/http"
|
||||
"github.com/v2fly/v2ray-core/v4/transport/internet/kcp"
|
||||
"github.com/v2fly/v2ray-core/v4/transport/internet/quic"
|
||||
@ -173,6 +174,8 @@ func (c *WebSocketConfig) Build() (proto.Message, error) {
|
||||
type HTTPConfig struct {
|
||||
Host *cfgcommon.StringList `json:"host"`
|
||||
Path string `json:"path"`
|
||||
Method string `json:"method"`
|
||||
Headers map[string]*cfgcommon.StringList `json:"headers"`
|
||||
}
|
||||
|
||||
// Build implements Buildable.
|
||||
@ -183,6 +186,23 @@ func (c *HTTPConfig) Build() (proto.Message, error) {
|
||||
if c.Host != nil {
|
||||
config.Host = []string(*c.Host)
|
||||
}
|
||||
if c.Method != "" {
|
||||
config.Method = c.Method
|
||||
}
|
||||
if len(c.Headers) > 0 {
|
||||
config.Header = make([]*httpheader.Header, 0, len(c.Headers))
|
||||
headerNames := sortMapKeys(c.Headers)
|
||||
for _, key := range headerNames {
|
||||
value := c.Headers[key]
|
||||
if value == nil {
|
||||
return nil, newError("empty HTTP header value: " + key).AtError()
|
||||
}
|
||||
config.Header = append(config.Header, &httpheader.Header{
|
||||
Name: key,
|
||||
Value: append([]string(nil), (*value)...),
|
||||
})
|
||||
}
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user