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

Commit8da2581

Browse files
authored
Use ICE servers from API (#406)
1 parent8e81679 commit8da2581

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ dev: build/linux
4848
-rm ./coder
4949
@echo"untarring..."
5050
@tar -xzf ./ci/bin/coder-cli-linux-amd64.tar.gz
51-
@echo"new dev binary ready"
51+
@echo"new dev binary ready"

‎coder-sdk/interface.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/url"
66

77
"cdr.dev/wsep"
8+
"github.com/pion/webrtc/v3"
89
"nhooyr.io/websocket"
910
)
1011

@@ -242,7 +243,7 @@ type Client interface {
242243
// SetPolicyTemplate sets the workspace policy template
243244
SetPolicyTemplate(ctx context.Context,templateIDstring,templateScopeTemplateScope,dryRunbool) (*SetPolicyTemplateResponse,error)
244245

245-
//satellites fetches all satellitess known to the Coder control plane.
246+
//Satellites fetches all satellitess known to the Coder control plane.
246247
Satellites(ctx context.Context) ([]Satellite,error)
247248

248249
// CreateSatellite creates a new satellite entity.
@@ -253,4 +254,7 @@ type Client interface {
253254

254255
// UpdateLastConnectionAt updates the last connection at attribute of a workspace.
255256
UpdateLastConnectionAt(ctx context.Context,workspaceIDstring)error
257+
258+
// ICEServers fetches the list of ICE servers advertised by the deployment.
259+
ICEServers(ctx context.Context) ([]webrtc.ICEServer,error)
256260
}

‎coder-sdk/webrtc.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package coder
2+
3+
import (
4+
"context"
5+
"net/http"
6+
7+
"github.com/pion/webrtc/v3"
8+
)
9+
10+
typegetICEServersResstruct {
11+
Data []webrtc.ICEServer`json:"data"`
12+
}
13+
14+
// ICEServers fetches the list of ICE servers advertised by the deployment.
15+
func (c*DefaultClient)ICEServers(ctx context.Context) ([]webrtc.ICEServer,error) {
16+
varresgetICEServersRes
17+
err:=c.requestBody(ctx,http.MethodGet,"/api/private/webrtc/ice",nil,&res)
18+
iferr!=nil {
19+
returnnil,err
20+
}
21+
22+
returnres.Data,nil
23+
}

‎internal/cmd/tunnel.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,18 @@ coder tunnel my-dev 3000 3000
7575
returnxerrors.Errorf("No workspace found by name '%s'",args[0])
7676
}
7777

78+
iceServers,err:=sdk.ICEServers(ctx)
79+
iferr!=nil {
80+
returnxerrors.Errorf("get ICE servers: %w",err)
81+
}
82+
log.Debug(ctx,"got ICE servers",slog.F("ice",iceServers))
83+
7884
c:=&tunnneler{
7985
log:log,
8086
brokerAddr:&baseURL,
8187
token:sdk.Token(),
8288
workspaceID:workspaceID,
89+
iceServers:iceServers,
8390
stdio:args[2]=="stdio",
8491
localPort:uint16(localPort),
8592
remotePort:uint16(remotePort),
@@ -102,6 +109,7 @@ type tunnneler struct {
102109
brokerAddr*url.URL
103110
tokenstring
104111
workspaceIDstring
112+
iceServers []webrtc.ICEServer
105113
remotePortuint16
106114
localPortuint16
107115
stdiobool
@@ -119,7 +127,7 @@ func (c *tunnneler) start(ctx context.Context) error {
119127
TURNProxyAuthToken:c.token,
120128
TURNRemoteProxyURL:c.brokerAddr,
121129
TURNLocalProxyURL:c.brokerAddr,
122-
ICEServers:[]webrtc.ICEServer{wsnet.TURNProxyICECandidate()},
130+
ICEServers:c.iceServers,
123131
},
124132
nil,
125133
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp