mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-04 14:13:03 +00:00
Send shadowsocks handshake with payload if available (#736)
This commit is contained in:
parent
490e360c20
commit
3b31189f13
@ -2,6 +2,7 @@ package shadowsocks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/transport/internet/stat"
|
"github.com/xtls/xray-core/transport/internet/stat"
|
||||||
|
|
||||||
@ -101,18 +102,22 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
|||||||
timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
|
timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
|
||||||
|
|
||||||
if request.Command == protocol.RequestCommandTCP {
|
if request.Command == protocol.RequestCommandTCP {
|
||||||
|
requestDone := func() error {
|
||||||
|
defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
|
||||||
bufferedWriter := buf.NewBufferedWriter(buf.NewWriter(conn))
|
bufferedWriter := buf.NewBufferedWriter(buf.NewWriter(conn))
|
||||||
bodyWriter, err := WriteTCPRequest(request, bufferedWriter)
|
bodyWriter, err := WriteTCPRequest(request, bufferedWriter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newError("failed to write request").Base(err)
|
return newError("failed to write request").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = buf.CopyOnceTimeout(link.Reader, bodyWriter, time.Millisecond*100); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {
|
||||||
|
return newError("failed to write A request payload").Base(err).AtWarning()
|
||||||
|
}
|
||||||
|
|
||||||
if err := bufferedWriter.SetBuffered(false); err != nil {
|
if err := bufferedWriter.SetBuffered(false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
requestDone := func() error {
|
|
||||||
defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
|
|
||||||
return buf.Copy(link.Reader, bodyWriter, buf.UpdateActivity(timer))
|
return buf.Copy(link.Reader, bodyWriter, buf.UpdateActivity(timer))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user