Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Add vscodeipc subcommand for VS Code Extension #5326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add extio
  • Loading branch information
kylecarbs committed Dec 5, 2022
commit eae77d74ab093b012c8961273d4bd9b52c39bcc6
7 changes: 7 additions & 0 deletions cli/extension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cli

import "github.com/spf13/cobra"

func extension() *cobra.Command {
return &cobra.Command{}
}
66 changes: 66 additions & 0 deletions cli/vscodeipc/vscodeipc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package vscodeipc

import (
"context"
"io"
"net/http"

"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"golang.org/x/xerrors"

"github.com/coder/coder/codersdk"
)

// It's a lil http server that listens for messages from the VS Code extension.
// It can listen on macOS and Windows, and explicitly blocks any web requests.

type Dial struct {
//
}

type PortForward struct {
}

type Exec struct {
}

type ExecRequest struct {
Command string
}

type PortForwardRequest struct {
Port string
}

type NetworkStats struct {
P2P bool
Latency float64
PreferredDERP int
DERPLatency map[string]float64
}

func New(ctx context.Context, client *codersdk.Client, agentID uuid.UUID, options *codersdk.DialWorkspaceAgentOptions) (http.Handler, io.Closer, error) {
r := chi.NewRouter()
agentConn, err := client.DialWorkspaceAgent(ctx, agentID, &codersdk.DialWorkspaceAgentOptions{})
if err != nil {
return nil, nil, err
}
reachable := agentConn.AwaitReachable(ctx)
if !reachable {
return nil, nil, xerrors.New("we weren't reachable")
}
r.Get("/network", func(w http.ResponseWriter, r *http.Request) {
// This returns tracked network information!
})
r.Get("/port/{port}", func(w http.ResponseWriter, r *http.Request) {
// This transforms into a port forward!
})
r.Post("/exec", func(w http.ResponseWriter, r *http.Request) {
// This
})
r.Post("/stop", func(w http.ResponseWriter, r *http.Request) {

})
return r, agentConn, nil
}
7 changes: 7 additions & 0 deletions cli/vscodeipc/vscodeipc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package vscodeipc_test

import "testing"

func TestVSCodeIPC(t *testing.T) {

}