close ws gracefully to avoid stale joiners

This commit is contained in:
kulikov0 committed 2026-07-25 18:14:21 +02:00
1 parent 1dad19e6b6
commit c89688afd2
9 files changed
+32 -14

No files matched your search

+1 -3
View File
@@ -273,9 +273,7 @@ func (b *Bridge) forceReconnect(reason string) {
b.mu.Lock()
ws := b.ws
b.mu.Unlock()
if ws != nil {
ws.Close()
}
common.CloseWS(ws)
}
func (b *Bridge) sendInitBundle() {
+4 -1
View File
@@ -4,6 +4,9 @@ go 1.26.1
require whitelist-bypass/relay v0.0.0
require github.com/pion/transport/v4 v4.0.1 // indirect
require (
github.com/gorilla/websocket v1.5.3 // indirect
github.com/pion/transport/v4 v4.0.1 // indirect
)
replace whitelist-bypass/relay => ../../relay
+2
View File
@@ -1,2 +1,4 @@
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
+1
View File
@@ -12,6 +12,7 @@ replace whitelist-bypass/relay => ../../relay
require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/klauspost/reedsolomon v1.12.0 // indirect
github.com/pion/datachannel v1.6.0 // indirect
+2
View File
@@ -25,6 +25,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
+17
View File
@@ -0,0 +1,17 @@
package common
import (
"time"
"github.com/gorilla/websocket"
)
func CloseWS(ws *websocket.Conn) {
if ws == nil {
return
}
ws.WriteControl(websocket.CloseMessage,
websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""),
time.Now().Add(time.Second))
ws.Close()
}
+2 -1
View File
@@ -283,7 +283,8 @@ func (c *SignalingClient) Close() error {
if !c.closed.CompareAndSwap(false, true) {
return nil
}
return c.conn.Close()
common.CloseWS(c.conn)
return nil
}
func (c *SignalingClient) sendFrame(method string, params any) error {
+1 -3
View File
@@ -191,9 +191,7 @@ func (c *Client) Close() {
c.wsMu.Lock()
ws := c.ws
c.wsMu.Unlock()
if ws != nil {
_ = ws.Close()
}
common.CloseWS(ws)
if c.pubPC != nil {
_ = c.pubPC.Close()
}
@@ -214,9 +214,7 @@ func (j *TelemostHeadlessJoiner) Close() {
ws := j.ws
j.ws = nil
j.wsMu.Unlock()
if ws != nil {
ws.Close()
}
common.CloseWS(ws)
if j.vp8tunnel != nil {
j.vp8tunnel.Stop()
}
@@ -585,9 +583,7 @@ func (j *TelemostHeadlessJoiner) forceReconnect(reason string) {
j.wsMu.Lock()
ws := j.ws
j.wsMu.Unlock()
if ws != nil {
ws.Close()
}
common.CloseWS(ws)
}
func (j *TelemostHeadlessJoiner) sendStartupSlotsRamp() {