Skip to content
Snippets Groups Projects
Commit 1ac52ff1 authored by jkito's avatar jkito :skull:
Browse files

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
parent 0a0f7524
Branches
Tags
1 merge request!68recreate openvpn listener socket only when error is not `net.ErrClosed`
Pipeline #251051 failed
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment