Skip to content

Commit eae77d7

Browse files
committed
Add extio
1 parent 6540746 commit eae77d7

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

cli/extension.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cli
2+
3+
import "github.com/spf13/cobra"
4+
5+
func extension() *cobra.Command {
6+
return &cobra.Command{}
7+
}

cli/vscodeipc/vscodeipc.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package vscodeipc
2+
3+
import (
4+
"context"
5+
"io"
6+
"net/http"
7+
8+
"github.com/go-chi/chi/v5"
9+
"github.com/google/uuid"
10+
"golang.org/x/xerrors"
11+
12+
"github.com/coder/coder/codersdk"
13+
)
14+
15+
// It's a lil http server that listens for messages from the VS Code extension.
16+
// It can listen on macOS and Windows, and explicitly blocks any web requests.
17+
18+
type Dial struct {
19+
//
20+
}
21+
22+
type PortForward struct {
23+
}
24+
25+
type Exec struct {
26+
}
27+
28+
type ExecRequest struct {
29+
Command string
30+
}
31+
32+
type PortForwardRequest struct {
33+
Port string
34+
}
35+
36+
type NetworkStats struct {
37+
P2P bool
38+
Latency float64
39+
PreferredDERP int
40+
DERPLatency map[string]float64
41+
}
42+
43+
func New(ctx context.Context, client *codersdk.Client, agentID uuid.UUID, options *codersdk.DialWorkspaceAgentOptions) (http.Handler, io.Closer, error) {
44+
r := chi.NewRouter()
45+
agentConn, err := client.DialWorkspaceAgent(ctx, agentID, &codersdk.DialWorkspaceAgentOptions{})
46+
if err != nil {
47+
return nil, nil, err
48+
}
49+
reachable := agentConn.AwaitReachable(ctx)
50+
if !reachable {
51+
return nil, nil, xerrors.New("we weren't reachable")
52+
}
53+
r.Get("/network", func(w http.ResponseWriter, r *http.Request) {
54+
// This returns tracked network information!
55+
})
56+
r.Get("/port/{port}", func(w http.ResponseWriter, r *http.Request) {
57+
// This transforms into a port forward!
58+
})
59+
r.Post("/exec", func(w http.ResponseWriter, r *http.Request) {
60+
// This
61+
})
62+
r.Post("/stop", func(w http.ResponseWriter, r *http.Request) {
63+
64+
})
65+
return r, agentConn, nil
66+
}

cli/vscodeipc/vscodeipc_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package vscodeipc_test
2+
3+
import "testing"
4+
5+
func TestVSCodeIPC(t *testing.T) {
6+
7+
}

0 commit comments

Comments
 (0)