0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-04-28 22:31:25 +03:00

62 lines
1.1 KiB
Go
Raw Normal View History

2025-01-12 14:49:34 -05:00
package quic
import (
"context"
"time"
2025-02-02 11:11:09 -05:00
"github.com/quic-go/quic-go"
2025-01-12 14:49:34 -05:00
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/net"
)
type interConn struct {
ctx context.Context
quicConn quic.Connection
local net.Addr
remote net.Addr
}
func (c *interConn) Read(b []byte) (int, error) {
received, e := c.quicConn.ReceiveDatagram(c.ctx)
if e != nil {
return 0, e
}
nBytes := copy(b, received[:])
return nBytes, nil
}
func (c *interConn) WriteMultiBuffer(mb buf.MultiBuffer) error {
mb = buf.Compact(mb)
mb, err := buf.WriteMultiBuffer(c, mb)
buf.ReleaseMulti(mb)
return err
}
func (c *interConn) Write(b []byte) (int, error) {
return len(b), c.quicConn.SendDatagram(b)
}
func (c *interConn) Close() error {
return nil
}
func (c *interConn) LocalAddr() net.Addr {
return c.local
}
func (c *interConn) RemoteAddr() net.Addr {
return c.remote
}
func (c *interConn) SetDeadline(t time.Time) error {
return nil
}
func (c *interConn) SetReadDeadline(t time.Time) error {
return nil
}
func (c *interConn) SetWriteDeadline(t time.Time) error {
return nil
}