mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Remove the pollInterval loop from SignalingServer.pollOffer in the standalone proxy
Closes #40210.
This commit is contained in:
parent
a7855d506c
commit
f4305180b9
2 changed files with 27 additions and 38 deletions
|
@ -364,7 +364,7 @@ func TestBrokerInteractions(t *testing.T) {
|
|||
b,
|
||||
}
|
||||
|
||||
sdp, _ := broker.pollOffer(sampleOffer, DefaultProxyType, "", DefaultPollInterval, nil)
|
||||
sdp, _ := broker.pollOffer(sampleOffer, DefaultProxyType, "")
|
||||
expectedSDP, _ := strconv.Unquote(sampleSDP)
|
||||
So(sdp.SDP, ShouldResemble, expectedSDP)
|
||||
})
|
||||
|
@ -378,7 +378,7 @@ func TestBrokerInteractions(t *testing.T) {
|
|||
b,
|
||||
}
|
||||
|
||||
sdp, _ := broker.pollOffer(sampleOffer, DefaultProxyType, "", DefaultPollInterval, nil)
|
||||
sdp, _ := broker.pollOffer(sampleOffer, DefaultProxyType, "")
|
||||
So(sdp, ShouldBeNil)
|
||||
})
|
||||
Convey("sends answer to broker", func() {
|
||||
|
|
|
@ -234,18 +234,9 @@ func (s *SignalingServer) Post(path string, payload io.Reader) ([]byte, error) {
|
|||
|
||||
// pollOffer communicates the proxy's capabilities with broker
|
||||
// and retrieves a compatible SDP offer and relay URL.
|
||||
func (s *SignalingServer) pollOffer(sid string, proxyType string, acceptedRelayPattern string, pollInterval time.Duration, shutdown chan struct{}) (*webrtc.SessionDescription, string) {
|
||||
func (s *SignalingServer) pollOffer(sid string, proxyType string, acceptedRelayPattern string) (*webrtc.SessionDescription, string) {
|
||||
brokerPath := s.url.ResolveReference(&url.URL{Path: "proxy"})
|
||||
|
||||
ticker := time.NewTicker(pollInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
// Run the loop once before hitting the ticker
|
||||
for ; true; <-ticker.C {
|
||||
select {
|
||||
case <-shutdown:
|
||||
return nil, ""
|
||||
default:
|
||||
numClients := int((tokens.count() / 8) * 8) // Round down to 8
|
||||
currentNATTypeLoaded := getCurrentNATType()
|
||||
body, err := messages.EncodeProxyPollRequestWithRelayPrefix(sid, proxyType, currentNATTypeLoaded, numClients, acceptedRelayPattern)
|
||||
|
@ -273,8 +264,6 @@ func (s *SignalingServer) pollOffer(sid string, proxyType string, acceptedRelayP
|
|||
}
|
||||
return offer, relayURL
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
|
@ -609,7 +598,7 @@ func (sf *SnowflakeProxy) makeNewPeerConnection(
|
|||
}
|
||||
|
||||
func (sf *SnowflakeProxy) runSession(sid string) {
|
||||
offer, relayURL := broker.pollOffer(sid, sf.ProxyType, sf.RelayDomainNamePattern, sf.PollInterval, sf.shutdown)
|
||||
offer, relayURL := broker.pollOffer(sid, sf.ProxyType, sf.RelayDomainNamePattern)
|
||||
if offer == nil {
|
||||
log.Printf("bad offer from broker")
|
||||
tokens.ret()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue