Skip to content

Commit 87761ff

Browse files
committed
bug fix in server_udp_adapter.go
1 parent 3b11e32 commit 87761ff

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/infrastructure/network/udp/adapters/server_udp_adapter.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package adapters
22

33
import (
4-
"io"
54
"net/netip"
65
"tungo/application"
76
"tungo/application/listeners"
@@ -13,13 +12,13 @@ type ServerUdpAdapter struct {
1312
addrPort netip.AddrPort
1413

1514
readBuffer [settings.DefaultEthernetMTU + settings.UDPChacha20Overhead]byte
16-
oob [1024]byte
15+
oob [8 * 1024]byte
1716
}
1817

19-
func NewUdpAdapter(UdpConn listeners.UdpListener, AddrPort netip.AddrPort) application.ConnectionAdapter {
18+
func NewUdpAdapter(udpConn listeners.UdpListener, addrPort netip.AddrPort) application.ConnectionAdapter {
2019
return &ServerUdpAdapter{
21-
conn: UdpConn,
22-
addrPort: AddrPort,
20+
conn: udpConn,
21+
addrPort: addrPort,
2322
}
2423
}
2524

@@ -33,7 +32,8 @@ func (ua *ServerUdpAdapter) Read(buffer []byte) (int, error) {
3332
return 0, err
3433
}
3534
if len(buffer) < n {
36-
return 0, io.ErrShortBuffer
35+
copy(buffer, ua.readBuffer[:len(buffer)])
36+
return len(buffer), nil
3737
}
3838
copy(buffer, ua.readBuffer[:n])
3939
return n, nil

0 commit comments

Comments
 (0)