mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-21 16:01:22 +02:00
fix(agent/stream): handle EOF error in UDP server connection
- Updated error handling in the UDP server to ignore io.EOF errors when reading from client connections. - Added a check to return early if no bytes are read from the client connection. - Ensured proper closure of tcpListener in the main.go file during cancellation.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"time"
|
||||
@@ -119,10 +120,13 @@ func (s *UDPServer) handleDTLSConnection(clientConn net.Conn) {
|
||||
return
|
||||
default:
|
||||
n, err := clientConn.Read(buf)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
s.logger(clientConn).Err(err).Msg("failed to read from client")
|
||||
return
|
||||
}
|
||||
if n == 0 {
|
||||
return
|
||||
}
|
||||
if _, err := dstConn.Write(buf[:n]); err != nil {
|
||||
s.logger(clientConn).Err(err).Msgf("failed to write %d bytes to destination", n)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user