Skip to content

Commit 12054ab

Browse files
committed
Feat: implement set buffer methods in QUIC sysConn
1 parent bd21b93 commit 12054ab

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

transport/internet/quic/conn.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"crypto/cipher"
55
"crypto/rand"
66
"errors"
7+
"syscall"
78
"time"
89

910
"github.com/lucas-clemente/quic-go"
@@ -15,12 +16,12 @@ import (
1516
)
1617

1718
type sysConn struct {
18-
conn net.PacketConn
19+
conn *net.UDPConn
1920
header internet.PacketHeader
2021
auth cipher.AEAD
2122
}
2223

23-
func wrapSysConn(rawConn net.PacketConn, config *Config) (*sysConn, error) {
24+
func wrapSysConn(rawConn *net.UDPConn, config *Config) (*sysConn, error) {
2425
header, err := getHeader(config)
2526
if err != nil {
2627
return nil, err
@@ -128,6 +129,14 @@ func (c *sysConn) LocalAddr() net.Addr {
128129
return c.conn.LocalAddr()
129130
}
130131

132+
func (c *sysConn) SetReadBuffer(bytes int) error {
133+
return c.conn.SetReadBuffer(bytes)
134+
}
135+
136+
func (c *sysConn) SetWriteBuffer(bytes int) error {
137+
return c.conn.SetWriteBuffer(bytes)
138+
}
139+
131140
func (c *sysConn) SetDeadline(t time.Time) error {
132141
return c.conn.SetDeadline(t)
133142
}
@@ -140,6 +149,10 @@ func (c *sysConn) SetWriteDeadline(t time.Time) error {
140149
return c.conn.SetWriteDeadline(t)
141150
}
142151

152+
func (c *sysConn) SyscallConn() (syscall.RawConn, error) {
153+
return c.conn.SyscallConn()
154+
}
155+
143156
type interConn struct {
144157
stream quic.Stream
145158
local net.Addr

transport/internet/quic/dialer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
154154
KeepAlive: true,
155155
}
156156

157-
conn, err := wrapSysConn(rawConn, config)
157+
conn, err := wrapSysConn(rawConn.(*net.UDPConn), config)
158158
if err != nil {
159159
rawConn.Close()
160160
return nil, err

transport/internet/quic/hub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
110110
KeepAlive: true,
111111
}
112112

113-
conn, err := wrapSysConn(rawConn, config)
113+
conn, err := wrapSysConn(rawConn.(*net.UDPConn), config)
114114
if err != nil {
115115
conn.Close()
116116
return nil, err

0 commit comments

Comments
 (0)