mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00:00
Add SplitHTTP Transport (#3412)
This commit is contained in:
parent
501d5dec60
commit
c10bd28731
16 changed files with 1288 additions and 19 deletions
59
transport/internet/splithttp/connection.go
Normal file
59
transport/internet/splithttp/connection.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
package splithttp
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type splitConn struct {
|
||||
writer io.WriteCloser
|
||||
reader io.ReadCloser
|
||||
remoteAddr net.Addr
|
||||
localAddr net.Addr
|
||||
}
|
||||
|
||||
func (c *splitConn) Write(b []byte) (int, error) {
|
||||
return c.writer.Write(b)
|
||||
}
|
||||
|
||||
func (c *splitConn) Read(b []byte) (int, error) {
|
||||
return c.reader.Read(b)
|
||||
}
|
||||
|
||||
func (c *splitConn) Close() error {
|
||||
err := c.writer.Close()
|
||||
err2 := c.reader.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err2 != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *splitConn) LocalAddr() net.Addr {
|
||||
return c.localAddr
|
||||
}
|
||||
|
||||
func (c *splitConn) RemoteAddr() net.Addr {
|
||||
return c.remoteAddr
|
||||
}
|
||||
|
||||
func (c *splitConn) SetDeadline(t time.Time) error {
|
||||
// TODO cannot do anything useful
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *splitConn) SetReadDeadline(t time.Time) error {
|
||||
// TODO cannot do anything useful
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *splitConn) SetWriteDeadline(t time.Time) error {
|
||||
// TODO cannot do anything useful
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue