1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

fix: always send Trojan header

This commit is contained in:
AkinoKaede 2023-05-23 14:05:10 +08:00
parent 62bef88a19
commit 72475c2924
No known key found for this signature in database
GPG Key ID: D2192CF5FF4AC1C7
2 changed files with 10 additions and 3 deletions

View File

@ -146,7 +146,14 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
}
// write some request payload to buffer
if err = buf.CopyOnceTimeout(link.Reader, bodyWriter, proxy.FirstPayloadTimeout); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {
err = buf.CopyOnceTimeout(link.Reader, bodyWriter, proxy.FirstPayloadTimeout)
switch err {
case buf.ErrNotTimeoutReader, buf.ErrReadTimeout:
if err := connWriter.WriteHeader(); err != nil {
return newError("failed to write request header").Base(err).AtWarning()
}
case nil:
default:
return newError("failed to write a request payload").Base(err).AtWarning()
}

View File

@ -37,7 +37,7 @@ type ConnWriter struct {
// Write implements io.Writer
func (c *ConnWriter) Write(p []byte) (n int, err error) {
if !c.headerSent {
if err := c.writeHeader(); err != nil {
if err := c.WriteHeader(); err != nil {
return 0, newError("failed to write request header").Base(err)
}
}
@ -60,7 +60,7 @@ func (c *ConnWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
return nil
}
func (c *ConnWriter) writeHeader() error {
func (c *ConnWriter) WriteHeader() error {
buffer := buf.StackNew()
defer buffer.Release()