mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-02-06 16:30:37 +00:00
Fix https DNS transports
This commit is contained in:
parent
1c56213cbe
commit
314b25bccf
|
@ -62,9 +62,20 @@ func NewHTTPS(ctx context.Context, logger log.ContextLogger, tag string, options
|
||||||
if !common.Contains(tlsConfig.NextProtos(), "http/1.1") {
|
if !common.Contains(tlsConfig.NextProtos(), "http/1.1") {
|
||||||
tlsConfig.SetNextProtos(append(tlsConfig.NextProtos(), "http/1.1"))
|
tlsConfig.SetNextProtos(append(tlsConfig.NextProtos(), "http/1.1"))
|
||||||
}
|
}
|
||||||
|
headers := options.Headers.Build()
|
||||||
|
host := headers.Get("Host")
|
||||||
|
if host != "" {
|
||||||
|
headers.Del("Host")
|
||||||
|
} else {
|
||||||
|
if tlsConfig.ServerName() != "" {
|
||||||
|
host = tlsConfig.ServerName()
|
||||||
|
} else {
|
||||||
|
host = options.Server
|
||||||
|
}
|
||||||
|
}
|
||||||
destinationURL := url.URL{
|
destinationURL := url.URL{
|
||||||
Scheme: "https",
|
Scheme: "https",
|
||||||
Host: options.Host,
|
Host: host,
|
||||||
}
|
}
|
||||||
if destinationURL.Host == "" {
|
if destinationURL.Host == "" {
|
||||||
destinationURL.Host = options.Server
|
destinationURL.Host = options.Server
|
||||||
|
@ -89,7 +100,7 @@ func NewHTTPS(ctx context.Context, logger log.ContextLogger, tag string, options
|
||||||
logger,
|
logger,
|
||||||
transportDialer,
|
transportDialer,
|
||||||
&destinationURL,
|
&destinationURL,
|
||||||
options.Headers.Build(),
|
headers,
|
||||||
serverAddr,
|
serverAddr,
|
||||||
tlsConfig,
|
tlsConfig,
|
||||||
), nil
|
), nil
|
||||||
|
|
|
@ -60,9 +60,20 @@ func NewHTTP3(ctx context.Context, logger log.ContextLogger, tag string, options
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
headers := options.Headers.Build()
|
||||||
|
host := headers.Get("Host")
|
||||||
|
if host != "" {
|
||||||
|
headers.Del("Host")
|
||||||
|
} else {
|
||||||
|
if tlsConfig.ServerName() != "" {
|
||||||
|
host = tlsConfig.ServerName()
|
||||||
|
} else {
|
||||||
|
host = options.Server
|
||||||
|
}
|
||||||
|
}
|
||||||
destinationURL := url.URL{
|
destinationURL := url.URL{
|
||||||
Scheme: "HTTP3",
|
Scheme: "HTTP3",
|
||||||
Host: options.Host,
|
Host: host,
|
||||||
}
|
}
|
||||||
if destinationURL.Host == "" {
|
if destinationURL.Host == "" {
|
||||||
destinationURL.Host = options.Server
|
destinationURL.Host = options.Server
|
||||||
|
@ -87,7 +98,7 @@ func NewHTTP3(ctx context.Context, logger log.ContextLogger, tag string, options
|
||||||
logger: logger,
|
logger: logger,
|
||||||
dialer: transportDialer,
|
dialer: transportDialer,
|
||||||
destination: &destinationURL,
|
destination: &destinationURL,
|
||||||
headers: options.Headers.Build(),
|
headers: headers,
|
||||||
transport: &http3.Transport{
|
transport: &http3.Transport{
|
||||||
Dial: func(ctx context.Context, addr string, tlsCfg *tls.STDConfig, cfg *quic.Config) (quic.EarlyConnection, error) {
|
Dial: func(ctx context.Context, addr string, tlsCfg *tls.STDConfig, cfg *quic.Config) (quic.EarlyConnection, error) {
|
||||||
destinationAddr := M.ParseSocksaddr(addr)
|
destinationAddr := M.ParseSocksaddr(addr)
|
||||||
|
|
|
@ -281,7 +281,6 @@ type RemoteTLSDNSServerOptions struct {
|
||||||
|
|
||||||
type RemoteHTTPSDNSServerOptions struct {
|
type RemoteHTTPSDNSServerOptions struct {
|
||||||
RemoteTLSDNSServerOptions
|
RemoteTLSDNSServerOptions
|
||||||
Host string `json:"host,omitempty"`
|
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
Method string `json:"method,omitempty"`
|
Method string `json:"method,omitempty"`
|
||||||
Headers badoption.HTTPHeader `json:"headers,omitempty"`
|
Headers badoption.HTTPHeader `json:"headers,omitempty"`
|
||||||
|
|
Loading…
Reference in a new issue