From 1ac52ff1044194aaaaedcad4a3110b9560c64c7d Mon Sep 17 00:00:00 2001
From: jkito <belter@riseup.net>
Date: Thu, 7 Nov 2024 14:24:30 +0530
Subject: [PATCH] recreate openvpn listener socket when error is not
 net.ErrClosed

during the running of the client it might happen that there's an
actual error for which we need to restart the UDP listener where
openvpn send its traffic, but an error will also be  encountered
in the copy loop when tearing down the connection, we can filter
these types of errors by checking if it is a net.ErrClosed error
type and re-create the UDP listener only when the error is not a
net.ErrClosed
---
 client/client.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/client.go b/client/client.go
index 4220ee7..dca9a73 100644
--- a/client/client.go
+++ b/client/client.go
@@ -455,7 +455,7 @@ func (c *Client) readTCPWriteUDP() {
 			c.openvpnAddrLock.RLock()
 			_, err := c.openvpnConn.WriteToUDP(tcpBytes, c.openvpnAddr)
 			c.openvpnAddrLock.RUnlock()
-			if err != nil {
+			if err != nil && !errors.Is(err, net.ErrClosed) {
 				c.error("readTCPWriteUDP: Write err from %v to %v: %v", c.openvpnConn.LocalAddr(), c.openvpnConn.RemoteAddr(), err)
 				c.openvpnAddrLock.Lock()
 				c.openvpnConn.Close()
-- 
GitLab