mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Implement DataChannel flow control
This commit is contained in:
parent
f8eb86f24d
commit
ea01c92cf1
2 changed files with 30 additions and 1 deletions
|
@ -83,6 +83,8 @@ const (
|
|||
sessionIDLength = 16
|
||||
)
|
||||
|
||||
const bufferedAmountLowThreshold uint64 = 256 * 1024 // 256 KB
|
||||
|
||||
var broker *SignalingServer
|
||||
|
||||
var currentNATTypeAccess = &sync.RWMutex{}
|
||||
|
@ -408,6 +410,15 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(sdp *webrtc.SessionDescrip
|
|||
pr, pw := io.Pipe()
|
||||
conn := newWebRTCConn(pc, dc, pr, sf.EventDispatcher)
|
||||
|
||||
dc.SetBufferedAmountLowThreshold(bufferedAmountLowThreshold)
|
||||
|
||||
dc.OnBufferedAmountLow(func() {
|
||||
select {
|
||||
case conn.sendMoreCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
})
|
||||
|
||||
dc.OnOpen(func() {
|
||||
log.Printf("Data Channel %s-%d open\n", dc.Label(), dc.ID())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue