Skip to content

Commit

Permalink
Merge pull request #2864 from AkihiroSuda/revert-portfwd
Browse files Browse the repository at this point in the history
Revert the default port forwarder to SSH
  • Loading branch information
jandubois authored Nov 7, 2024
2 parents 0199911 + ed49354 commit adc5a71
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
14 changes: 12 additions & 2 deletions pkg/hostagent/hostagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,18 @@ func (a *HostAgent) processGuestAgentEvents(ctx context.Context, client *guestag
for _, f := range ev.Errors {
logrus.Warnf("received error from the guest: %q", f)
}
env, _ := strconv.ParseBool(os.Getenv("LIMA_SSH_PORT_FORWARDER"))
if env {
// useSSHFwd was false by default in v1.0, but reverted to true by default in v1.0.1
// due to stability issues
useSSHFwd := true
if envVar := os.Getenv("LIMA_SSH_PORT_FORWARDER"); envVar != "" {
b, err := strconv.ParseBool(os.Getenv("LIMA_SSH_PORT_FORWARDER"))
if err != nil {
logrus.WithError(err).Warnf("invalid LIMA_SSH_PORT_FORWARDER value %q", envVar)
} else {
useSSHFwd = b
}
}
if useSSHFwd {
a.portForwarder.OnEvent(ctx, ev)
} else {
a.grpcPortForwarder.OnEvent(ctx, client, ev)
Expand Down
17 changes: 12 additions & 5 deletions website/content/en/docs/config/Port/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ Lima supports automatic port-forwarding of localhost ports from guest to host.

## Port forwarding types

Lima supports two port forwarders: SSH and GRPC.

The default port forwarder is SSH.

The default was once changed to GRPC in Lima v1.0, but it was reverted to SSH in v1.0.1 due to stability reasons.
In future, it is expected that GRPC will take over the default position again.

### Using SSH

SSH based port forwarding is the default and current model that is supported in Lima prior to v1.0.
SSH based port forwarding is the default and current model that is supported in Lima.

To use SSH forwarding use the below command
To explicitly use SSH forwarding use the below command

```bash
LIMA_SSH_PORT_FORWARDER=true limactl start
Expand All @@ -22,18 +29,18 @@ LIMA_SSH_PORT_FORWARDER=true limactl start
- Doesn't support UDP based port forwarding
- Spans child process on host for running SSH master.

### Using GRPC (Default since Lima v1.0)
### Using GRPC

| ⚡ Requirement | Lima >= 1.0 |
|---------------|-------------|

In this model, lima uses existing GRPC communication (Host <-> Guest) to tunnel port forwarding requests.
For each port forwarding request, a GRPC tunnel is created and this will be used for transmitting data

To disable this feature and use SSH forwarding use the following environment variable
To enable this feature, set `LIMA_SSH_PORT_FORWARDER` to `false`:

```bash
LIMA_SSH_PORT_FORWARDER=true limactl start
LIMA_SSH_PORT_FORWARDER=false limactl start
```

#### Advantages
Expand Down

0 comments on commit adc5a71

Please sign in to comment.