error handling for closed socket
This commit is contained in:
parent
d2f02d9782
commit
78cab7a871
@ -3,6 +3,7 @@ package netbounce
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
@ -231,7 +232,19 @@ func (b *backendUDP) udpBackend2Client(wg *sync.WaitGroup, rel udpRel) {
|
|||||||
udpBackendLoop:
|
udpBackendLoop:
|
||||||
for {
|
for {
|
||||||
if n, _, err = rel.backend.ReadFrom(buf); err != nil {
|
if n, _, err = rel.backend.ReadFrom(buf); err != nil {
|
||||||
//TODO: error handling
|
select {
|
||||||
|
case <-rel.ctx.Done():
|
||||||
|
break udpBackendLoop
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if errors.Is(err, net.ErrClosed) { //TODO: implement this error handling to all socket read/write operation
|
||||||
|
rel.ctxCancel()
|
||||||
|
break udpBackendLoop
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Error().Err(err).Str(CONNECTION, rel.clientAddr).Str(DIRECTION, BACKEND_TO_CLIENT).Msg("udpBackend2Client: read from udp")
|
||||||
|
continue udpBackendLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
clientAddr = rel.clientAddr
|
clientAddr = rel.clientAddr
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user