@@ -20,6 +20,7 @@ import (
20
20
"github.com/coreos/go-systemd/daemon"
21
21
"github.com/google/go-github/v43/github"
22
22
"github.com/pion/turn/v2"
23
+ "github.com/pion/webrtc/v3"
23
24
"github.com/spf13/cobra"
24
25
"golang.org/x/oauth2"
25
26
xgithub "golang.org/x/oauth2/github"
@@ -46,6 +47,7 @@ import (
46
47
"github.com/coder/coder/provisionersdk/proto"
47
48
)
48
49
50
+ // nolint:gocyclo
49
51
func server () * cobra.Command {
50
52
var (
51
53
accessURL string
@@ -67,6 +69,7 @@ func server() *cobra.Command {
67
69
tlsMinVersion string
68
70
turnRelayAddress string
69
71
skipTunnel bool
72
+ stunServers []string
70
73
traceDatadog bool
71
74
secureAuthCookie bool
72
75
sshKeygenAlgorithmRaw string
@@ -176,8 +179,15 @@ func server() *cobra.Command {
176
179
return xerrors .Errorf ("create turn server: %w" , err )
177
180
}
178
181
182
+ iceServers := make ([]webrtc.ICEServer , 0 )
183
+ for _ , stunServer := range stunServers {
184
+ iceServers = append (iceServers , webrtc.ICEServer {
185
+ URLs : []string {stunServer },
186
+ })
187
+ }
179
188
options := & coderd.Options {
180
189
AccessURL : accessURLParsed ,
190
+ ICEServers : iceServers ,
181
191
Logger : logger .Named ("coderd" ),
182
192
Database : databasefake .New (),
183
193
Pubsub : database .NewPubsubInMemory (),
@@ -411,6 +421,9 @@ func server() *cobra.Command {
411
421
`Specifies the minimum supported version of TLS. Accepted values are "tls10", "tls11", "tls12" or "tls13"` )
412
422
cliflag .BoolVarP (root .Flags (), & skipTunnel , "skip-tunnel" , "" , "CODER_DEV_SKIP_TUNNEL" , false , "Skip serving dev mode through an exposed tunnel for simple setup." )
413
423
_ = root .Flags ().MarkHidden ("skip-tunnel" )
424
+ cliflag .StringArrayVarP (root .Flags (), & stunServers , "stun-server" , "" , "CODER_STUN_SERVERS" , []string {
425
+ "stun:stun.l.google.com:19302" ,
426
+ }, "Specify URLs for STUN servers to enable P2P connections." )
414
427
cliflag .BoolVarP (root .Flags (), & traceDatadog , "trace-datadog" , "" , "CODER_TRACE_DATADOG" , false , "Send tracing data to a datadog agent" )
415
428
cliflag .StringVarP (root .Flags (), & turnRelayAddress , "turn-relay-address" , "" , "CODER_TURN_RELAY_ADDRESS" , "127.0.0.1" ,
416
429
"Specifies the address to bind TURN connections." )
0 commit comments