mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-22 05:29:50 +00:00
b1c6471eeb
https://github.com/XTLS/Xray-core/pull/3613#issuecomment-2351954957 Closes https://github.com/XTLS/Xray-core/issues/3560#issuecomment-2247495778 --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com>
65 lines
1014 B
Go
65 lines
1014 B
Go
package splithttp
|
|
|
|
import (
|
|
"io"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
type splitConn struct {
|
|
writer io.WriteCloser
|
|
reader io.ReadCloser
|
|
remoteAddr net.Addr
|
|
localAddr net.Addr
|
|
onClose func()
|
|
}
|
|
|
|
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 {
|
|
if c.onClose != nil {
|
|
c.onClose()
|
|
}
|
|
|
|
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
|
|
}
|