github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/common/sniff/http.go (about) 1 package sniff 2 3 import ( 4 std_bufio "bufio" 5 "context" 6 "io" 7 8 "github.com/inazumav/sing-box/adapter" 9 C "github.com/inazumav/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 }