From bfe60c01ba2b1283123556bd7194238ba0d0ee4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Fri, 21 Jun 2024 00:55:30 +0200 Subject: [PATCH] Close proxy reading in case of eof --- client/internal/wgproxy/proxy_userspace.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/internal/wgproxy/proxy_userspace.go b/client/internal/wgproxy/proxy_userspace.go index 234ea2a42..e51bfbdcd 100644 --- a/client/internal/wgproxy/proxy_userspace.go +++ b/client/internal/wgproxy/proxy_userspace.go @@ -3,6 +3,7 @@ package wgproxy import ( "context" "fmt" + "io" "net" log "github.com/sirupsen/logrus" @@ -64,7 +65,6 @@ func (p *WGUserSpaceProxy) Free() error { // proxyToRemote proxies everything from Wireguard to the RemoteKey peer // blocks func (p *WGUserSpaceProxy) proxyToRemote() { - buf := make([]byte, 1500) for { select { @@ -78,6 +78,9 @@ func (p *WGUserSpaceProxy) proxyToRemote() { _, err = p.remoteConn.Write(buf[:n]) if err != nil { + if err == io.EOF { + p.cancel() + } continue } } @@ -96,6 +99,10 @@ func (p *WGUserSpaceProxy) proxyToLocal() { default: n, err := p.remoteConn.Read(buf) if err != nil { + if err == io.EOF { + p.cancel() + return + } continue }