Skip to content

Commit 2f71d8c

Browse files
Add http-based client to tunnel server
1 parent dfcc669 commit 2f71d8c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pkg/agent/tunnelserver/client.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net"
77

88
"github.com/loft-sh/devpod/pkg/agent/tunnel"
9+
"github.com/loft-sh/devpod/pkg/daemon/workspace/network"
910
"github.com/loft-sh/devpod/pkg/stdio"
1011
"google.golang.org/grpc"
1112
"google.golang.org/grpc/credentials/insecure"
@@ -34,3 +35,24 @@ func NewTunnelClient(reader io.Reader, writer io.WriteCloser, exitOnClose bool,
3435

3536
return c, nil
3637
}
38+
39+
// NewTunnelClient creates a gRPC tunnel client that connects via the Unix domain socket,
40+
// using the shared dialer from the network package.
41+
func NewHTTPTunnelClient(_ io.Reader, _ io.WriteCloser, _ bool, _ int) (tunnel.TunnelClient, error) {
42+
// After moving from deprecated grpc.Dial to grpc.NewClient we need to setup resolver first
43+
// https://github.com/grpc/grpc-go/issues/1786#issuecomment-2119088770
44+
resolver.SetDefaultScheme("passthrough")
45+
46+
// Set up a connection to the server.
47+
conn, err := grpc.NewClient("",
48+
grpc.WithTransportCredentials(insecure.NewCredentials()),
49+
grpc.WithContextDialer(network.GetContextDialer()),
50+
)
51+
if err != nil {
52+
return nil, err
53+
}
54+
55+
c := tunnel.NewTunnelClient(conn)
56+
57+
return c, nil
58+
}

0 commit comments

Comments
 (0)