Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Use webrtc for coder sh#408

Merged
Emyrk merged 3 commits intomasterfromstevenmasley/ch15591/webrtc_sh
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletioninternal/cmd/configssh.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -261,7 +261,7 @@ func makeSSHConfig(binPath, workspaceName, privateKeyFilepath string, additional
}
options = append(options,
fmt.Sprintf("HostName coder.%s", workspaceName),
fmt.Sprintf("ProxyCommand %q tunnel %s 12213 stdio", binPath, workspaceName),
fmt.Sprintf("ProxyCommand %s",proxyCommand(binPath, workspaceName, true)),
"StrictHostKeyChecking no",
"ConnectTimeout=0",
"IdentitiesOnly yes",
Expand All@@ -279,6 +279,13 @@ func makeSSHConfig(binPath, workspaceName, privateKeyFilepath string, additional
return fmt.Sprintf("Host coder.%s\n\t%s\n\n", workspaceName, strings.Join(options, "\n\t"))
}

func proxyCommand(binPath, workspaceName string, quoted bool) string {
if quoted {
binPath = fmt.Sprintf("%q", binPath)
}
return fmt.Sprintf(`%s tunnel %s 12213 stdio`, binPath, workspaceName)
}

func writeStr(filename, data string) error {
return ioutil.WriteFile(filename, []byte(data), 0777)
}
Expand Down
22 changes: 13 additions & 9 deletionsinternal/cmd/ssh.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"net/url"
"os"
"os/exec"
"os/user"
Expand DownExpand Up@@ -41,10 +40,7 @@ func shell(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
me, err := client.Me(ctx)
if err != nil {
return err
}

workspace, err := findWorkspace(ctx, client, args[0], coder.Me)
if err != nil {
return err
Expand All@@ -60,9 +56,9 @@ func shell(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
u, err := url.Parse(wp.EnvproxyAccessURL)
iferr != nil {
returnerr

if!wp.SSHEnabled {
returnclog.Error("SSH is disabled on this Workspace")
}

usr, err := user.Current()
Expand All@@ -75,13 +71,21 @@ func shell(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}

binPath, err := binPath()
if err != nil {
return xerrors.Errorf("Failed to get executable path: %w", err)
}

ssh := exec.CommandContext(ctx,
"ssh", "-i"+privateKeyFilepath,
fmt.Sprintf("%s-%s@%s", me.Username, workspace.Name, u.Hostname()),
"-o"+fmt.Sprintf("ProxyCommand=%s", proxyCommand(binPath, workspace.Name, false)),
workspace.Name,
)
if len(args) > 1 {
ssh.Args = append(ssh.Args, args[1:]...)
}

ssh.Stderr = os.Stderr
ssh.Stdout = os.Stdout
ssh.Stdin = os.Stdin
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp