Make v2ray http2 conn public

This commit is contained in:
世界 2023-04-21 17:49:43 +08:00
parent df0eef770e
commit 438de36749
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 6 additions and 6 deletions

View file

@ -139,16 +139,16 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) {
default:
request.Host = c.host[rand.Intn(hostLen)]
}
conn := newLateHTTPConn(pipeInWriter)
conn := NewLateHTTPConn(pipeInWriter)
go func() {
response, err := c.transport.RoundTrip(request)
if err != nil {
conn.setup(nil, err)
conn.Setup(nil, err)
} else if response.StatusCode != 200 {
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 {
conn.setup(response.Body, nil)
conn.Setup(response.Body, nil)
}
}()
return conn, nil

View file

@ -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{
create: make(chan struct{}),
writer: writer,
}
}
func (c *HTTP2Conn) setup(reader io.Reader, err error) {
func (c *HTTP2Conn) Setup(reader io.Reader, err error) {
c.reader = reader
c.err = err
close(c.create)