Add domain sniffer

This commit is contained in:
世界
2022-07-06 12:39:44 +08:00
parent 625bc649ee
commit 3e2dddfb16
15 changed files with 603 additions and 18 deletions

19
common/sniff/http.go Normal file
View 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
}