mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Added check to see if peer connection succeeded
This is related to the proxy-go deadlock bug #25688. If a client doesn't do anything with the SDP answer, a token will get lost. Added a timeout after a minute that checks the PeerConnection state and destroys the peer connection and returns a token if did not yet succeed
This commit is contained in:
parent
c28c8ca489
commit
08f5205461
1 changed files with 17 additions and 3 deletions
|
@ -325,6 +325,20 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
|||
pc.Destroy()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Set a timeout on peerconnection. If the connection state has not
|
||||
// advanced to PeerConnectionStateConnected in this time,
|
||||
// destroy the peer connection and return the token.
|
||||
go func() {
|
||||
<-time.After(time.Minute)
|
||||
if pc.ConnectionState() != webrtc.PeerConnectionStateConnected {
|
||||
log.Println("Timed out waiting for client to open data cannel.")
|
||||
pc.Destroy()
|
||||
retToken()
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
return pc, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue