Skip to content

Commit

Permalink
cleanup: remove package bicopy
Browse files Browse the repository at this point in the history
This has a single caller that doesn't even use the full interface.

Signed-off-by: Tamir Duberstein <[email protected]>
  • Loading branch information
tamird committed Nov 25, 2024
1 parent 9248baf commit 4ec7fa0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 84 deletions.
81 changes: 0 additions & 81 deletions pkg/bicopy/bicopy.go

This file was deleted.

25 changes: 22 additions & 3 deletions pkg/hostagent/port_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ package hostagent

import (
"context"
"errors"
"fmt"
"io"
"net"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/lima-vm/lima/pkg/bicopy"
"github.com/lima-vm/lima/pkg/portfwd"
"github.com/lima-vm/sshocker/pkg/ssh"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
)

// forwardTCP is not thread-safe.
Expand Down Expand Up @@ -149,8 +151,25 @@ func (plf *pseudoLoopbackForwarder) forward(ac *net.TCPConn) error {
return err
}
defer unixConn.Close()
bicopy.Bicopy(ac, unixConn, nil)
return nil

g, _ := errgroup.WithContext(context.Background())

g.Go(func() error {
_, err := io.Copy(unixConn, ac)
if errors.Is(err, io.EOF) {
err = nil
}
return errors.Join(err, unixConn.CloseRead(), ac.CloseWrite())
})
g.Go(func() error {
_, err := io.Copy(ac, unixConn)
if errors.Is(err, io.EOF) {
err = nil
}
return errors.Join(err, ac.CloseRead(), unixConn.CloseWrite())
})

return g.Wait()
}

func (plf *pseudoLoopbackForwarder) Close() error {
Expand Down

0 comments on commit 4ec7fa0

Please sign in to comment.