mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00:00
XHTTP: Add "stream-up" mode for client & server (#3994)
This commit is contained in:
parent
94c02f090e
commit
bc4bf3d38f
8 changed files with 164 additions and 77 deletions
|
@ -25,6 +25,10 @@ type DialerClient interface {
|
|||
// (ctx, baseURL) -> (downloadReader, remoteAddr, localAddr)
|
||||
// baseURL already contains sessionId
|
||||
OpenDownload(context.Context, string) (io.ReadCloser, net.Addr, net.Addr, error)
|
||||
|
||||
// (ctx, baseURL) -> uploadWriter
|
||||
// baseURL already contains sessionId
|
||||
OpenUpload(context.Context, string) io.WriteCloser
|
||||
}
|
||||
|
||||
// implements splithttp.DialerClient in terms of direct network connections
|
||||
|
@ -38,6 +42,14 @@ type DefaultDialerClient struct {
|
|||
dialUploadConn func(ctxInner context.Context) (net.Conn, error)
|
||||
}
|
||||
|
||||
func (c *DefaultDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser {
|
||||
reader, writer := io.Pipe()
|
||||
req, _ := http.NewRequestWithContext(ctx, "POST", baseURL, reader)
|
||||
req.Header = c.transportConfig.GetRequestHeader()
|
||||
go c.client.Do(req)
|
||||
return writer
|
||||
}
|
||||
|
||||
func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) {
|
||||
var remoteAddr gonet.Addr
|
||||
var localAddr gonet.Addr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue