Skip to content

Commit a3eb1bb

Browse files
committed
portfwdserver: fix half-close
Fix issue 3685 Similar to 3684 Signed-off-by: Akihiro Suda <[email protected]>
1 parent d877648 commit a3eb1bb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/portfwdserver/server.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
package portfwdserver
55

66
import (
7+
"context"
78
"errors"
89
"io"
910
"net"
1011
"time"
1112

12-
"github.com/lima-vm/lima/pkg/bicopy"
1313
"github.com/lima-vm/lima/pkg/guestagent/api"
14+
15+
"github.com/containers/gvisor-tap-vsock/pkg/tcpproxy"
1416
)
1517

1618
type TunnelServer struct{}
@@ -30,12 +32,11 @@ func (s *TunnelServer) Start(stream api.GuestService_TunnelServer) error {
3032
}
3133

3234
// We simply forward data form GRPC stream to net.Conn for both tcp and udp. So simple proxy is sufficient
33-
conn, err := net.Dial(in.Protocol, in.GuestAddr)
34-
if err != nil {
35-
return err
36-
}
3735
rw := &GRPCServerRW{stream: stream, id: in.Id}
38-
bicopy.Bicopy(rw, conn, nil)
36+
proxy := tcpproxy.DialProxy{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
37+
return net.Dial(in.Protocol, in.GuestAddr)
38+
}}
39+
proxy.HandleConn(rw)
3940
return nil
4041
}
4142

0 commit comments

Comments
 (0)