-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for connecting to local WSL installations on Windows. (also adds wshrpcmmultiproxy / connserver router)
- Loading branch information
1 parent
4e86b67
commit 8248637
Showing
31 changed files
with
2,101 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* text=auto | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2024, Command Line Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cmd | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/wavetermdev/waveterm/pkg/waveobj" | ||
"github.com/wavetermdev/waveterm/pkg/wshrpc" | ||
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient" | ||
) | ||
|
||
var distroName string | ||
|
||
var wslCmd = &cobra.Command{ | ||
Use: "wsl [-d <Distro>]", | ||
Short: "connect this terminal to a local wsl connection", | ||
Args: cobra.NoArgs, | ||
Run: wslRun, | ||
PreRunE: preRunSetupRpcClient, | ||
} | ||
|
||
func init() { | ||
wslCmd.Flags().StringVarP(&distroName, "distribution", "d", "", "Run the specified distribution") | ||
rootCmd.AddCommand(wslCmd) | ||
} | ||
|
||
func wslRun(cmd *cobra.Command, args []string) { | ||
var err error | ||
if distroName == "" { | ||
// get default distro from the host | ||
distroName, err = wshclient.WslDefaultDistroCommand(RpcClient, nil) | ||
if err != nil { | ||
WriteStderr("[error] %s\n", err) | ||
return | ||
} | ||
} | ||
if !strings.HasPrefix(distroName, "wsl://") { | ||
distroName = "wsl://" + distroName | ||
} | ||
blockId := RpcContext.BlockId | ||
if blockId == "" { | ||
WriteStderr("[error] cannot determine blockid (not in JWT)\n") | ||
return | ||
} | ||
data := wshrpc.CommandSetMetaData{ | ||
ORef: waveobj.MakeORef(waveobj.OType_Block, blockId), | ||
Meta: map[string]any{ | ||
waveobj.MetaKey_Connection: distroName, | ||
}, | ||
} | ||
err = wshclient.SetMetaCommand(RpcClient, data, nil) | ||
if err != nil { | ||
WriteStderr("[error] setting switching connection: %v\n", err) | ||
return | ||
} | ||
WriteStderr("switched connection to %q\n", distroName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.