quicproxy: increase UDP send and receive buffer sizes (#3813)

This commit is contained in:
Marten Seemann 2023-05-28 17:08:17 +03:00 committed by GitHub
parent 378e3c8b74
commit f5516715eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -169,6 +169,12 @@ func NewQuicProxy(local string, opts *Opts) (*QuicProxy, error) {
if err != nil {
return nil, err
}
if err := conn.SetReadBuffer(protocol.DesiredReceiveBufferSize); err != nil {
return nil, err
}
if err := conn.SetWriteBuffer(protocol.DesiredSendBufferSize); err != nil {
return nil, err
}
raddr, err := net.ResolveUDPAddr("udp", opts.RemoteAddr)
if err != nil {
return nil, err
@ -225,13 +231,19 @@ func (p *QuicProxy) LocalPort() int {
}
func (p *QuicProxy) newConnection(cliAddr *net.UDPAddr) (*connection, error) {
srvudp, err := net.DialUDP("udp", nil, p.serverAddr)
conn, err := net.DialUDP("udp", nil, p.serverAddr)
if err != nil {
return nil, err
}
if err := conn.SetReadBuffer(protocol.DesiredReceiveBufferSize); err != nil {
return nil, err
}
if err := conn.SetWriteBuffer(protocol.DesiredSendBufferSize); err != nil {
return nil, err
}
return &connection{
ClientAddr: cliAddr,
ServerConn: srvudp,
ServerConn: conn,
incomingPackets: make(chan packetEntry, 10),
Incoming: newQueue(),
Outgoing: newQueue(),