http.go 465 B

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