mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Added check for active pair in onopen
Because the timeout makes the pair inactive, we should check for this state in onopen before connecting to the client. Updated tests to set the proxy pair to active before testing onopen. Also removed a redundant statement.
This commit is contained in:
parent
8a5941daab
commit
16a1b69823
3 changed files with 4 additions and 2 deletions
|
@ -85,6 +85,9 @@ class ProxyPair {
|
|||
prepareDataChannel(channel) {
|
||||
channel.onopen = () => {
|
||||
log('WebRTC DataChannel opened!');
|
||||
if (!this.active) {
|
||||
return
|
||||
}
|
||||
this.running = true;
|
||||
snowflake.state = Snowflake.MODE.WEBRTC_READY;
|
||||
snowflake.ui.setActive(true);
|
||||
|
|
|
@ -86,8 +86,6 @@ class Snowflake {
|
|||
return pair.active = false;
|
||||
}
|
||||
}), 20000); // 20 second timeout
|
||||
} else {
|
||||
return pair.active = false;
|
||||
}
|
||||
}, function() {
|
||||
return pair.active = false;
|
||||
|
|
|
@ -100,6 +100,7 @@ describe('ProxyPair', function() {
|
|||
|
||||
it('connects to the relay once datachannel opens', function() {
|
||||
spyOn(pp, 'connectRelay');
|
||||
pp.active = true;
|
||||
pp.client.onopen();
|
||||
expect(pp.connectRelay).toHaveBeenCalled();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue