mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Fix for ticket #30206
This fixes a bug introduced by the deadlock patch for ticket #25688.
This commit is contained in:
parent
d11e55aabe
commit
695dd10b2c
1 changed files with 8 additions and 4 deletions
|
@ -30,7 +30,7 @@ const pollInterval = 5 * time.Second
|
||||||
|
|
||||||
//amount of time after sending an SDP answer before the proxy assumes the
|
//amount of time after sending an SDP answer before the proxy assumes the
|
||||||
//client is not going to connect
|
//client is not going to connect
|
||||||
const dataChannelTimeout = time.Minute
|
const dataChannelTimeout = 20 * time.Second
|
||||||
|
|
||||||
var brokerURL *url.URL
|
var brokerURL *url.URL
|
||||||
var relayURL string
|
var relayURL string
|
||||||
|
@ -265,6 +265,7 @@ func datachannelHandler(conn *webRTCConn, remoteAddr net.Addr) {
|
||||||
// datachannelHandler.
|
// datachannelHandler.
|
||||||
func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.Configuration) (*webrtc.PeerConnection, error) {
|
func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.Configuration) (*webrtc.PeerConnection, error) {
|
||||||
|
|
||||||
|
dataChan := make(chan struct{})
|
||||||
pc, err := webrtc.NewPeerConnection(config)
|
pc, err := webrtc.NewPeerConnection(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("accept: NewPeerConnection: %s", err)
|
return nil, fmt.Errorf("accept: NewPeerConnection: %s", err)
|
||||||
|
@ -274,6 +275,7 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
||||||
}
|
}
|
||||||
pc.OnDataChannel = func(dc *webrtc.DataChannel) {
|
pc.OnDataChannel = func(dc *webrtc.DataChannel) {
|
||||||
log.Println("OnDataChannel")
|
log.Println("OnDataChannel")
|
||||||
|
close(dataChan)
|
||||||
|
|
||||||
pr, pw := io.Pipe()
|
pr, pw := io.Pipe()
|
||||||
conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
|
conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
|
||||||
|
@ -335,9 +337,11 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
||||||
// advanced to PeerConnectionStateConnected in this time,
|
// advanced to PeerConnectionStateConnected in this time,
|
||||||
// destroy the peer connection and return the token.
|
// destroy the peer connection and return the token.
|
||||||
go func() {
|
go func() {
|
||||||
<-time.After(dataChannelTimeout)
|
select {
|
||||||
if pc.ConnectionState() != webrtc.PeerConnectionStateConnected {
|
case <-dataChan:
|
||||||
log.Println("Timed out waiting for client to open data cannel.")
|
log.Println("Connection successful.")
|
||||||
|
case <-time.After(dataChannelTimeout):
|
||||||
|
log.Println("Timed out waiting for client to open data channel.")
|
||||||
pc.Destroy()
|
pc.Destroy()
|
||||||
retToken()
|
retToken()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue