mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 18:11:28 +00:00
Make v2ray http2 conn public
This commit is contained in:
parent
df0eef770e
commit
438de36749
|
@ -139,16 +139,16 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) {
|
||||||
default:
|
default:
|
||||||
request.Host = c.host[rand.Intn(hostLen)]
|
request.Host = c.host[rand.Intn(hostLen)]
|
||||||
}
|
}
|
||||||
conn := newLateHTTPConn(pipeInWriter)
|
conn := NewLateHTTPConn(pipeInWriter)
|
||||||
go func() {
|
go func() {
|
||||||
response, err := c.transport.RoundTrip(request)
|
response, err := c.transport.RoundTrip(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.setup(nil, err)
|
conn.Setup(nil, err)
|
||||||
} else if response.StatusCode != 200 {
|
} else if response.StatusCode != 200 {
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
conn.setup(nil, E.New("unexpected status: ", response.StatusCode, " ", response.Status))
|
conn.Setup(nil, E.New("unexpected status: ", response.StatusCode, " ", response.Status))
|
||||||
} else {
|
} else {
|
||||||
conn.setup(response.Body, nil)
|
conn.Setup(response.Body, nil)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return conn, nil
|
return conn, nil
|
||||||
|
|
|
@ -140,14 +140,14 @@ func NewHTTPConn(reader io.Reader, writer io.Writer) HTTP2Conn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLateHTTPConn(writer io.Writer) *HTTP2Conn {
|
func NewLateHTTPConn(writer io.Writer) *HTTP2Conn {
|
||||||
return &HTTP2Conn{
|
return &HTTP2Conn{
|
||||||
create: make(chan struct{}),
|
create: make(chan struct{}),
|
||||||
writer: writer,
|
writer: writer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HTTP2Conn) setup(reader io.Reader, err error) {
|
func (c *HTTP2Conn) Setup(reader io.Reader, err error) {
|
||||||
c.reader = reader
|
c.reader = reader
|
||||||
c.err = err
|
c.err = err
|
||||||
close(c.create)
|
close(c.create)
|
||||||
|
|
Loading…
Reference in a new issue