This commit is contained in:
世界 2023-10-08 22:05:03 +08:00
parent aa3255f763
commit 1329edf42e
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
6 changed files with 14 additions and 12 deletions

View File

@ -31,5 +31,5 @@ type HTTPOutboundOptions struct {
Password string `json:"password,omitempty"`
TLS *OutboundTLSOptions `json:"tls,omitempty"`
Path string `json:"path,omitempty"`
Headers OutboundHeader `json:"headers,omitempty"`
Headers HTTPHeader `json:"headers,omitempty"`
}

View File

@ -236,12 +236,14 @@ func DNSQueryTypeToString(queryType uint16) string {
return F.ToString(queryType)
}
type OutboundHeader map[string]Listable[string]
type HTTPHeader map[string]Listable[string]
func (h OutboundHeader) HTTPHeader() http.Header {
func (h HTTPHeader) Build() http.Header {
header := make(http.Header)
for name, values := range h {
header[http.CanonicalHeaderKey(name)] = values
for _, value := range values {
header.Add(name, value)
}
}
return header
}

View File

@ -64,14 +64,14 @@ type V2RayHTTPOptions struct {
Host Listable[string] `json:"host,omitempty"`
Path string `json:"path,omitempty"`
Method string `json:"method,omitempty"`
Headers OutboundHeader `json:"headers,omitempty"`
Headers HTTPHeader `json:"headers,omitempty"`
IdleTimeout Duration `json:"idle_timeout,omitempty"`
PingTimeout Duration `json:"ping_timeout,omitempty"`
}
type V2RayWebsocketOptions struct {
Path string `json:"path,omitempty"`
Headers OutboundHeader `json:"headers,omitempty"`
Headers HTTPHeader `json:"headers,omitempty"`
MaxEarlyData uint32 `json:"max_early_data,omitempty"`
EarlyDataHeaderName string `json:"early_data_header_name,omitempty"`
}

View File

@ -48,7 +48,7 @@ func NewHTTP(ctx context.Context, router adapter.Router, logger log.ContextLogge
Username: options.Username,
Password: options.Password,
Path: options.Path,
Headers: options.Headers.HTTPHeader(),
Headers: options.Headers.Build(),
}),
}, nil
}

View File

@ -64,7 +64,7 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
serverAddr: serverAddr,
host: options.Host,
method: options.Method,
headers: options.Headers.HTTPHeader(),
headers: options.Headers.Build(),
transport: transport,
http2: tlsConfig != nil,
}

View File

@ -55,7 +55,7 @@ func NewServer(ctx context.Context, options option.V2RayHTTPOptions, tlsConfig t
host: options.Host,
path: options.Path,
method: options.Method,
headers: options.Headers.HTTPHeader(),
headers: options.Headers.Build(),
}
if server.method == "" {
server.method = "PUT"