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

Skip to content

Commit ff99b40

Browse files
committed
Add TURN server to coder start
1 parent 54d5a59 commit ff99b40

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

cli/start.go

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"github.com/briandowns/spinner"
2020
"github.com/coreos/go-systemd/daemon"
21+
"github.com/pion/turn/v2"
2122
"github.com/spf13/cobra"
2223
"golang.org/x/xerrors"
2324
"google.golang.org/api/idtoken"
@@ -34,6 +35,7 @@ import (
3435
"github.com/coder/coder/coderd/database/databasefake"
3536
"github.com/coder/coder/coderd/devtunnel"
3637
"github.com/coder/coder/coderd/gitsshkey"
38+
"github.com/coder/coder/coderd/turnconn"
3739
"github.com/coder/coder/codersdk"
3840
"github.com/coder/coder/provisioner/terraform"
3941
"github.com/coder/coder/provisionerd"
@@ -56,6 +58,7 @@ func start() *cobra.Command {
5658
tlsEnable bool
5759
tlsKeyFile string
5860
tlsMinVersion string
61+
turnRelayAddress string
5962
skipTunnel bool
6063
traceDatadog bool
6164
secureAuthCookie bool
@@ -154,6 +157,14 @@ func start() *cobra.Command {
154157
return xerrors.Errorf("parse ssh keygen algorithm %s: %w", sshKeygenAlgorithmRaw, err)
155158
}
156159

160+
turnServer, err := turnconn.New(&turn.RelayAddressGeneratorStatic{
161+
RelayAddress: net.ParseIP(turnRelayAddress),
162+
Address: turnRelayAddress,
163+
})
164+
if err != nil {
165+
return xerrors.Errorf("create turn server: %w", err)
166+
}
167+
157168
logger := slog.Make(sloghuman.Sink(os.Stderr))
158169
options := &coderd.Options{
159170
AccessURL: accessURLParsed,
@@ -163,6 +174,7 @@ func start() *cobra.Command {
163174
GoogleTokenValidator: validator,
164175
SecureAuthCookie: secureAuthCookie,
165176
SSHKeygenAlgorithm: sshKeygenAlgorithm,
177+
TURNServer: turnServer,
166178
}
167179

168180
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "access-url: %s\n", accessURL)
@@ -375,6 +387,8 @@ func start() *cobra.Command {
375387
cliflag.BoolVarP(root.Flags(), &skipTunnel, "skip-tunnel", "", "CODER_DEV_SKIP_TUNNEL", false, "Skip serving dev mode through an exposed tunnel for simple setup.")
376388
_ = root.Flags().MarkHidden("skip-tunnel")
377389
cliflag.BoolVarP(root.Flags(), &traceDatadog, "trace-datadog", "", "CODER_TRACE_DATADOG", false, "Send tracing data to a datadog agent")
390+
cliflag.StringVarP(root.Flags(), &turnRelayAddress, "turn-relay-address", "", "CODER_TURN_RELAY_ADDRESS", "127.0.0.1",
391+
"Specifies the address to bind TURN connections.")
378392
cliflag.BoolVarP(root.Flags(), &secureAuthCookie, "secure-auth-cookie", "", "CODER_SECURE_AUTH_COOKIE", false, "Specifies if the 'Secure' property is set on browser session cookies")
379393
cliflag.StringVarP(root.Flags(), &sshKeygenAlgorithmRaw, "ssh-keygen-algorithm", "", "CODER_SSH_KEYGEN_ALGORITHM", "ed25519", "Specifies the algorithm to use for generating ssh keys. "+
380394
`Accepted values are "ed25519", "ecdsa", or "rsa4096"`)

go.mod

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ replace github.com/chzyer/readline => github.com/kylecarbs/readline v0.0.0-20220
1717
// Required until https://github.com/briandowns/spinner/pull/136 is merged.
1818
replace github.com/briandowns/spinner => github.com/kylecarbs/spinner v1.18.2-0.20220329160715-20702b5af89e
1919

20-
// Required until https://github.com/pion/ice/pull/444 is merged.
21-
replace github.com/pion/ice/v2 => github.com/kylecarbs/ice/v2 v2.1.8-0.20220414143940-b5b2f89c4a4f
22-
2320
// opencensus-go leaks a goroutine by default.
2421
replace go.opencensus.io => github.com/kylecarbs/opencensus-go v0.23.1-0.20220307014935-4d0325a68f8b
2522

@@ -191,7 +188,7 @@ require (
191188
github.com/pelletier/go-toml/v2 v2.0.0-beta.6 // indirect
192189
github.com/philhofer/fwd v1.1.1 // indirect
193190
github.com/pion/dtls/v2 v2.1.3 // indirect
194-
github.com/pion/ice/v2 v2.2.3 // indirect
191+
github.com/pion/ice/v2 v2.2.4 // indirect
195192
github.com/pion/interceptor v0.1.10 // indirect
196193
github.com/pion/mdns v0.0.5 // indirect
197194
github.com/pion/randutil v0.1.0 // indirect

go.sum

+3-2
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
11021102
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
11031103
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
11041104
github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
1105-
github.com/kylecarbs/ice/v2 v2.1.8-0.20220414143940-b5b2f89c4a4f h1:y6JzBYK3+bN5+l1ZXPu5ns91KgbnQojFaDdvwY5N3G8=
1106-
github.com/kylecarbs/ice/v2 v2.1.8-0.20220414143940-b5b2f89c4a4f/go.mod h1:SWuHiOGP17lGromHTFadUe1EuPgFh/oCU6FCMZHooVE=
11071105
github.com/kylecarbs/opencensus-go v0.23.1-0.20220307014935-4d0325a68f8b h1:1Y1X6aR78kMEQE1iCjQodB3lA7VO4jB88Wf8ZrzXSsA=
11081106
github.com/kylecarbs/opencensus-go v0.23.1-0.20220307014935-4d0325a68f8b/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
11091107
github.com/kylecarbs/readline v0.0.0-20220211054233-0d62993714c8/go.mod h1:n/KX1BZoN1m9EwoXkn/xAV4fd3k8c++gGBsgLONaPOY=
@@ -1357,6 +1355,9 @@ github.com/pion/datachannel v1.5.2 h1:piB93s8LGmbECrpO84DnkIVWasRMk3IimbcXkTQLE6
13571355
github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ=
13581356
github.com/pion/dtls/v2 v2.1.3 h1:3UF7udADqous+M2R5Uo2q/YaP4EzUoWKdfX2oscCUio=
13591357
github.com/pion/dtls/v2 v2.1.3/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus=
1358+
github.com/pion/ice/v2 v2.2.3/go.mod h1:SWuHiOGP17lGromHTFadUe1EuPgFh/oCU6FCMZHooVE=
1359+
github.com/pion/ice/v2 v2.2.4 h1:sTHT39ywr5uqzyEMT7thEhOWsNOcdkHSZBbgQohFuZU=
1360+
github.com/pion/ice/v2 v2.2.4/go.mod h1:SWuHiOGP17lGromHTFadUe1EuPgFh/oCU6FCMZHooVE=
13601361
github.com/pion/interceptor v0.1.10 h1:DJ2GjMGm4XGIQgMJxuEpdaExdY/6RdngT7Uh4oVmquU=
13611362
github.com/pion/interceptor v0.1.10/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
13621363
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=

0 commit comments

Comments
 (0)