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

Skip to content

Commit 9db5fb0

Browse files
authored
refactor: Improve handshake resiliency of peer (#95)
* fix: Synchronize peer logging with a channel We were depending on the close mutex to properly report connection state. This ensures the RTC connection is properly closed before returning. * Disable pion logging * Remove buffer * Try ICE servers * Remove flushed * Add diagram explaining handshake * Fix candidate accept ordering * Add debug logging to peerbroker * Fix send ordering * Lock adding ICE candidate * Add test for negotiating out of order * Reduce connection to a single negotiation channel * Improve test times by pre-installing Terraform * Lock remote session description being applied * Organize conn * Revert to multi-channel setup * Properly close ICE gatherer * Improve comments * Try removing buffered candidates * Buffer local and remote messages * Log dTLS transport state * Add pion logging
1 parent a7d6f4b commit 9db5fb0

File tree

14 files changed

+298
-239
lines changed

14 files changed

+298
-239
lines changed

.github/workflows/coder.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,17 @@ jobs:
148148
149149
- run: go install gotest.tools/gotestsum@latest
150150

151+
- uses: hashicorp/setup-terraform@v1
152+
if: runner.os == 'Linux'
153+
with:
154+
terraform_version: 1.1.2
155+
terraform_wrapper: false
156+
151157
- name: Test with Mock Database
152158
run:
153159
gotestsum --jsonfile="gotests.json" --packages="./..." --
154160
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
155-
-count=3 -race -parallel=2
161+
-count=3 -race -short -parallel=2
156162

157163
- name: Test with PostgreSQL Database
158164
if: runner.os == 'Linux'

coderd/userpassword/userpassword_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This test runs slowly on MacOS instance, and really
2+
// only needs to run on Linux anyways.
3+
//go:build linux
4+
15
package userpassword_test
26

37
import (

database/migrate_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ func TestMain(m *testing.M) {
2020
func TestMigrate(t *testing.T) {
2121
t.Parallel()
2222

23+
if testing.Short() {
24+
t.Skip()
25+
return
26+
}
27+
2328
t.Run("Once", func(t *testing.T) {
2429
t.Parallel()
2530
connection, closeFn, err := postgres.Open()

database/postgres/postgres_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func TestMain(m *testing.M) {
2121
func TestPostgres(t *testing.T) {
2222
t.Parallel()
2323

24+
if testing.Short() {
25+
t.Skip()
26+
return
27+
}
28+
2429
connect, close, err := postgres.Open()
2530
require.NoError(t, err)
2631
defer close()

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/golang-migrate/migrate/v4 v4.15.1
1414
github.com/google/uuid v1.3.0
1515
github.com/hashicorp/go-version v1.4.0
16-
github.com/hashicorp/hc-install v0.3.1
1716
github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f
1817
github.com/hashicorp/terraform-exec v0.15.0
1918
github.com/justinas/nosurf v1.1.1
@@ -64,7 +63,6 @@ require (
6463
github.com/google/go-cmp v0.5.7 // indirect
6564
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
6665
github.com/hashicorp/errwrap v1.1.0 // indirect
67-
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
6866
github.com/hashicorp/go-multierror v1.1.1 // indirect
6967
github.com/hashicorp/hcl v1.0.0 // indirect
7068
github.com/hashicorp/hcl/v2 v2.11.1 // indirect

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,6 @@ github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
693693
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
694694
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
695695
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
696-
github.com/hashicorp/hc-install v0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk=
697-
github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak=
698696
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
699697
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
700698
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
@@ -1309,7 +1307,6 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh
13091307
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
13101308
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
13111309
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
1312-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
13131310
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
13141311
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
13151312
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

peer/channel.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ func (c *Channel) init() {
141141
// A DataChannel can disconnect multiple times, so this needs to loop.
142142
for {
143143
select {
144-
case <-c.closed:
144+
case <-c.conn.closedRTC:
145145
// If this channel was closed, there's no need to close again.
146-
return
146+
err = c.conn.closeError
147147
case <-c.conn.Closed():
148148
// If the RTC connection closed with an error, this channel
149149
// should end with the same one.

0 commit comments

Comments
 (0)