Skip to content

Commit 5fe7f8f

Browse files
committed
Replace pkg/bicopy and g-t-v/pkg/tcpproxy with pkg/tcpproxy
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 736e7fb commit 5fe7f8f

File tree

4 files changed

+12
-89
lines changed

4 files changed

+12
-89
lines changed

pkg/bicopy/bicopy.go

Lines changed: 0 additions & 84 deletions
This file was deleted.

pkg/hostagent/port_darwin.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"github.com/lima-vm/sshocker/pkg/ssh"
1616
"github.com/sirupsen/logrus"
1717

18-
"github.com/lima-vm/lima/pkg/bicopy"
1918
"github.com/lima-vm/lima/pkg/portfwd"
19+
"github.com/lima-vm/lima/pkg/tcpproxy"
2020
)
2121

2222
// forwardTCP is not thread-safe.
@@ -153,7 +153,10 @@ func (plf *pseudoLoopbackForwarder) forward(ac *net.TCPConn) error {
153153
return err
154154
}
155155
defer unixConn.Close()
156-
bicopy.Bicopy(ac, unixConn, nil)
156+
proxy := tcpproxy.DialProxy{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
157+
return unixConn, nil
158+
}}
159+
proxy.HandleConn(ac)
157160
return nil
158161
}
159162

pkg/portfwd/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
"time"
1111

1212
"github.com/containers/gvisor-tap-vsock/pkg/services/forwarder"
13-
"github.com/containers/gvisor-tap-vsock/pkg/tcpproxy"
1413
"github.com/sirupsen/logrus"
1514

1615
"github.com/lima-vm/lima/pkg/guestagent/api"
1716
guestagentclient "github.com/lima-vm/lima/pkg/guestagent/api/client"
17+
"github.com/lima-vm/lima/pkg/tcpproxy"
1818
)
1919

2020
func HandleTCPConnection(ctx context.Context, client *guestagentclient.GuestAgentClient, conn net.Conn, guestAddr string) {

pkg/portfwdserver/server.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
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+
"github.com/lima-vm/lima/pkg/tcpproxy"
1415
)
1516

1617
type TunnelServer struct{}
@@ -35,7 +36,10 @@ func (s *TunnelServer) Start(stream api.GuestService_TunnelServer) error {
3536
return err
3637
}
3738
rw := &GRPCServerRW{stream: stream, id: in.Id}
38-
bicopy.Bicopy(rw, conn, nil)
39+
proxy := tcpproxy.DialProxy{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
40+
return conn, nil
41+
}}
42+
proxy.HandleConn(rw)
3943
return nil
4044
}
4145

0 commit comments

Comments
 (0)