File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 4
4
package portfwdserver
5
5
6
6
import (
7
+ "context"
7
8
"errors"
8
9
"io"
9
10
"net"
10
11
"time"
11
12
12
- "github.com/lima-vm/lima/pkg/bicopy"
13
+ "github.com/containers/gvisor-tap-vsock/pkg/tcpproxy"
14
+
13
15
"github.com/lima-vm/lima/pkg/guestagent/api"
14
16
)
15
17
@@ -29,13 +31,13 @@ func (s *TunnelServer) Start(stream api.GuestService_TunnelServer) error {
29
31
return err
30
32
}
31
33
32
- // 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
- }
37
34
rw := & GRPCServerRW {stream : stream , id : in .Id }
38
- bicopy .Bicopy (rw , conn , nil )
35
+ proxy := tcpproxy.DialProxy {DialContext : func (ctx context.Context , _ , _ string ) (net.Conn , error ) {
36
+ // We simply forward data form GRPC stream to net.Conn for both tcp and udp. So simple proxy is sufficient
37
+ var d net.Dialer
38
+ return d .DialContext (ctx , in .Protocol , in .GuestAddr )
39
+ }}
40
+ proxy .HandleConn (rw )
39
41
return nil
40
42
}
41
43
You can’t perform that action at this time.
0 commit comments