sing-box/common/sniff/http.go

23 lines
537 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"
2023-04-19 08:05:11 +00:00
M "github.com/sagernet/sing/common/metadata"
2022-07-08 15:03:57 +00:00
"github.com/sagernet/sing/protocol/http"
2022-07-06 04:39:44 +00:00
)
2024-07-07 07:45:50 +00:00
func HTTPHost(_ context.Context, metadata *adapter.InboundContext, reader io.Reader) error {
2022-07-06 04:39:44 +00:00
request, err := http.ReadRequest(std_bufio.NewReader(reader))
if err != nil {
2024-07-07 07:45:50 +00:00
return err
2022-07-06 04:39:44 +00:00
}
2024-07-07 07:45:50 +00:00
metadata.Protocol = C.ProtocolHTTP
metadata.Domain = M.ParseSocksaddr(request.Host).AddrString()
return nil
2022-07-06 04:39:44 +00:00
}