Skip to content

Commit

Permalink
fix protocol matching in routing (#2540)
Browse files Browse the repository at this point in the history
* remove invalid http2 sniffer

* do not set metadata protocol for http inbound

http inbound may have transport settings

* fix doh metadata protocol
  • Loading branch information
dyhkwong authored Sep 14, 2023
1 parent 7dbd380 commit 8de2f27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/dns/nameserver_doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n
}

dnsCtx = session.ContextWithContent(dnsCtx, &session.Content{
Protocol: "https",
Protocol: "tls",
SkipDNSResolve: true,
})

Expand Down
21 changes: 3 additions & 18 deletions common/protocol/http/sniff.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,12 @@ import (

type version byte

const (
HTTP1 version = iota
HTTP2
)

type SniffHeader struct {
version version
host string
host string
}

func (h *SniffHeader) Protocol() string {
switch h.version {
case HTTP1:
return "http1"
case HTTP2:
return "http2"
default:
return "unknown"
}
return "http1"
}

func (h *SniffHeader) Domain() string {
Expand Down Expand Up @@ -62,9 +49,7 @@ func SniffHTTP(b []byte) (*SniffHeader, error) {
return nil, err
}

sh := &SniffHeader{
version: HTTP1,
}
sh := &SniffHeader{}

headers := bytes.Split(b, []byte{'\n'})
for i := 1; i < len(headers); i++ {
Expand Down
4 changes: 1 addition & 3 deletions proxy/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, wri
request.Header.Set("User-Agent", "")
}

content := &session.Content{
Protocol: "http/1.1",
}
content := &session.Content{}

content.SetAttribute(":method", strings.ToUpper(request.Method))
content.SetAttribute(":path", request.URL.Path)
Expand Down

0 comments on commit 8de2f27

Please sign in to comment.