1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-03 07:56:42 -05:00

fix protocol matching in routing (#2540)

* remove invalid http2 sniffer

* do not set metadata protocol for http inbound

http inbound may have transport settings

* fix doh metadata protocol
This commit is contained in:
dyhkwong 2023-09-14 08:27:36 +08:00 committed by GitHub
parent 7dbd3802bb
commit 8de2f27043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 22 deletions

View File

@ -231,7 +231,7 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n
} }
dnsCtx = session.ContextWithContent(dnsCtx, &session.Content{ dnsCtx = session.ContextWithContent(dnsCtx, &session.Content{
Protocol: "https", Protocol: "tls",
SkipDNSResolve: true, SkipDNSResolve: true,
}) })

View File

@ -11,25 +11,12 @@ import (
type version byte type version byte
const (
HTTP1 version = iota
HTTP2
)
type SniffHeader struct { type SniffHeader struct {
version version
host string host string
} }
func (h *SniffHeader) Protocol() string { func (h *SniffHeader) Protocol() string {
switch h.version {
case HTTP1:
return "http1" return "http1"
case HTTP2:
return "http2"
default:
return "unknown"
}
} }
func (h *SniffHeader) Domain() string { func (h *SniffHeader) Domain() string {
@ -62,9 +49,7 @@ func SniffHTTP(b []byte) (*SniffHeader, error) {
return nil, err return nil, err
} }
sh := &SniffHeader{ sh := &SniffHeader{}
version: HTTP1,
}
headers := bytes.Split(b, []byte{'\n'}) headers := bytes.Split(b, []byte{'\n'})
for i := 1; i < len(headers); i++ { for i := 1; i < len(headers); i++ {

View File

@ -242,9 +242,7 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, wri
request.Header.Set("User-Agent", "") request.Header.Set("User-Agent", "")
} }
content := &session.Content{ content := &session.Content{}
Protocol: "http/1.1",
}
content.SetAttribute(":method", strings.ToUpper(request.Method)) content.SetAttribute(":method", strings.ToUpper(request.Method))
content.SetAttribute(":path", request.URL.Path) content.SetAttribute(":path", request.URL.Path)