mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05: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
|
@ -307,9 +307,9 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
||||||
|
|
||||||
log.Println("Generating answer...")
|
log.Println("Generating answer...")
|
||||||
answer, err := pc.CreateAnswer()
|
answer, err := pc.CreateAnswer()
|
||||||
// blocks on ICE gathering. we need to add a timeout if needed
|
// blocks on ICE gathering. we need to add a timeout if needed
|
||||||
// not putting this in a separate go routine, because we need
|
// not putting this in a separate go routine, because we need
|
||||||
// SetLocalDescription(answer) to be called before sendAnswer
|
// SetLocalDescription(answer) to be called before sendAnswer
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pc.Destroy()
|
pc.Destroy()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -325,6 +325,20 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
||||||
pc.Destroy()
|
pc.Destroy()
|
||||||
return nil, err
|
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
|
return pc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue