sing-box/common/sniff/http.go

20 lines
465 B
Go
Raw Permalink Normal View History

2022-07-06 04:39:44 +00:00
package sniff
import (
std_bufio "bufio"
"context"
"io"
"github.com/sagernet/sing-box/adapter"
C "github.com/sagernet/sing-box/constant"
2022-07-08 15:03:57 +00:00
"github.com/sagernet/sing/protocol/http"
2022-07-06 04:39:44 +00:00
)
func HTTPHost(ctx context.Context, reader io.Reader) (*adapter.InboundContext, error) {
request, err := http.ReadRequest(std_bufio.NewReader(reader))
if err != nil {
return nil, err
}
return &adapter.InboundContext{Protocol: C.ProtocolHTTP, Domain: request.Host}, nil
}