mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 00:29:03 +01: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:
@@ -192,9 +192,9 @@ Tips:
|
||||
{
|
||||
subtask := t.Subtask("agent-tls-mux", true)
|
||||
t.OnCancel("stop_mux", func() {
|
||||
_ = tcpListener.Close()
|
||||
_ = httpLn.Close()
|
||||
_ = streamLn.Close()
|
||||
_ = tcpListener.Close()
|
||||
})
|
||||
go func() {
|
||||
defer subtask.Finish(subtask.FinishCause())
|
||||
|
||||
@@ -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