mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-26 13:56:12 -04:00
Feat: implement set buffer methods in QUIC sysConn (#1404)
This commit is contained in:
parent
8107b73082
commit
7413246fb8
@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
@ -15,12 +16,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type sysConn struct {
|
type sysConn struct {
|
||||||
conn net.PacketConn
|
conn *net.UDPConn
|
||||||
header internet.PacketHeader
|
header internet.PacketHeader
|
||||||
auth cipher.AEAD
|
auth cipher.AEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrapSysConn(rawConn net.PacketConn, config *Config) (*sysConn, error) {
|
func wrapSysConn(rawConn *net.UDPConn, config *Config) (*sysConn, error) {
|
||||||
header, err := getHeader(config)
|
header, err := getHeader(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -128,6 +129,14 @@ func (c *sysConn) LocalAddr() net.Addr {
|
|||||||
return c.conn.LocalAddr()
|
return c.conn.LocalAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *sysConn) SetReadBuffer(bytes int) error {
|
||||||
|
return c.conn.SetReadBuffer(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *sysConn) SetWriteBuffer(bytes int) error {
|
||||||
|
return c.conn.SetWriteBuffer(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *sysConn) SetDeadline(t time.Time) error {
|
func (c *sysConn) SetDeadline(t time.Time) error {
|
||||||
return c.conn.SetDeadline(t)
|
return c.conn.SetDeadline(t)
|
||||||
}
|
}
|
||||||
@ -140,6 +149,10 @@ func (c *sysConn) SetWriteDeadline(t time.Time) error {
|
|||||||
return c.conn.SetWriteDeadline(t)
|
return c.conn.SetWriteDeadline(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *sysConn) SyscallConn() (syscall.RawConn, error) {
|
||||||
|
return c.conn.SyscallConn()
|
||||||
|
}
|
||||||
|
|
||||||
type interConn struct {
|
type interConn struct {
|
||||||
stream quic.Stream
|
stream quic.Stream
|
||||||
local net.Addr
|
local net.Addr
|
||||||
|
@ -154,7 +154,7 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
|||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := wrapSysConn(rawConn, config)
|
conn, err := wrapSysConn(rawConn.(*net.UDPConn), config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rawConn.Close()
|
rawConn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -110,7 +110,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := wrapSysConn(rawConn, config)
|
conn, err := wrapSysConn(rawConn.(*net.UDPConn), config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user