mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-06-07 21:09:55 +00:00
fix: sniffing handled HTTP host header incorrectly
This commit is contained in:
parent
442ee3898c
commit
48bf9b964a
@ -112,11 +112,21 @@ func (h *Sniffer) TCP(stream quic.Stream, reqAddr *string) ([]byte, error) {
|
||||
tr := &teeReader{Stream: stream, Pre: pre}
|
||||
req, _ := http.ReadRequest(bufio.NewReader(tr))
|
||||
if req != nil && req.Host != "" {
|
||||
_, port, err := net.SplitHostPort(*reqAddr)
|
||||
// req.Host may already contain the port.
|
||||
// If it does, just overwrite the whole address with req.Host.
|
||||
// Otherwise, use the port in reqAddr.
|
||||
_, _, err := net.SplitHostPort(req.Host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// Not host:port format, append the port from reqAddr
|
||||
_, port, err := net.SplitHostPort(*reqAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
*reqAddr = net.JoinHostPort(req.Host, port)
|
||||
} else {
|
||||
// Already host:port format
|
||||
*reqAddr = req.Host
|
||||
}
|
||||
*reqAddr = net.JoinHostPort(req.Host, port)
|
||||
}
|
||||
return tr.Buffer(), nil
|
||||
} else if h.isTLS(pre) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user