github.com/sagernet/sing-box@v1.9.0-rc.20/common/sniff/http.go (about) 1 package sniff 2 3 import ( 4 std_bufio "bufio" 5 "context" 6 "io" 7 8 "github.com/sagernet/sing-box/adapter" 9 C "github.com/sagernet/sing-box/constant" 10 M "github.com/sagernet/sing/common/metadata" 11 "github.com/sagernet/sing/protocol/http" 12 ) 13 14 func HTTPHost(ctx context.Context, reader io.Reader) (*adapter.InboundContext, error) { 15 request, err := http.ReadRequest(std_bufio.NewReader(reader)) 16 if err != nil { 17 return nil, err 18 } 19 return &adapter.InboundContext{Protocol: C.ProtocolHTTP, Domain: M.ParseSocksaddr(request.Host).AddrString()}, nil 20 }