mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-19 09:24:59 +03:00
Add domain sniffer
This commit is contained in:
19
common/sniff/http.go
Normal file
19
common/sniff/http.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package sniff
|
||||
|
||||
import (
|
||||
std_bufio "bufio"
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing/protocol/http"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user