Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Snowflake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Anti-censorship
Pluggable Transports
Snowflake
Commits
a2292ce3
Commit
a2292ce3
authored
5 years ago
by
David Fifield
Browse files
Options
Downloads
Patches
Plain Diff
Make timeout constants into time.Duration values.
This slightly changes some log messages.
parent
dfb83c66
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/lib/snowflake.go
+3
-2
3 additions, 2 deletions
client/lib/snowflake.go
client/lib/webrtc.go
+5
-5
5 additions, 5 deletions
client/lib/webrtc.go
client/snowflake.go
+2
-2
2 additions, 2 deletions
client/snowflake.go
with
10 additions
and
9 deletions
client/lib/snowflake.go
+
3
−
2
View file @
a2292ce3
...
...
@@ -6,11 +6,12 @@ import (
"log"
"net"
"sync"
"time"
)
const
(
ReconnectTimeout
=
10
SnowflakeTimeout
=
30
ReconnectTimeout
=
10
*
time
.
Second
SnowflakeTimeout
=
30
*
time
.
Second
)
// Given an accepted SOCKS connection, establish a WebRTC connection to the
...
...
This diff is collapsed.
Click to expand it.
client/lib/webrtc.go
+
5
−
5
View file @
a2292ce3
...
...
@@ -117,9 +117,9 @@ func (c *WebRTCPeer) checkForStaleness() {
if
c
.
closed
{
return
}
if
time
.
Since
(
c
.
lastReceive
)
.
Seconds
()
>
SnowflakeTimeout
{
log
.
Print
ln
(
"WebRTC: No messages received for
"
,
SnowflakeTimeout
,
"seconds -- closing stale connection."
)
if
time
.
Since
(
c
.
lastReceive
)
>
SnowflakeTimeout
{
log
.
Print
f
(
"WebRTC: No messages received for
%v -- closing stale connection."
,
SnowflakeTimeout
)
c
.
Close
()
return
}
...
...
@@ -314,8 +314,8 @@ func (c *WebRTCPeer) exchangeSDP() error {
go
c
.
sendOfferToBroker
()
answer
,
ok
=
<-
c
.
answerChannel
// Blocks...
if
!
ok
||
nil
==
answer
{
log
.
Printf
(
"Failed to retrieve answer. Retrying in %
d seconds
"
,
ReconnectTimeout
)
<-
time
.
After
(
time
.
Second
*
ReconnectTimeout
)
log
.
Printf
(
"Failed to retrieve answer. Retrying in %
v
"
,
ReconnectTimeout
)
<-
time
.
After
(
ReconnectTimeout
)
answer
=
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
client/snowflake.go
+
2
−
2
View file @
a2292ce3
...
...
@@ -31,11 +31,11 @@ func ConnectLoop(snowflakes sf.SnowflakeCollector) {
// Check if ending is necessary.
_
,
err
:=
snowflakes
.
Collect
()
if
err
!=
nil
{
log
.
Printf
(
"WebRTC: %v Retrying in %v
seconds
..."
,
log
.
Printf
(
"WebRTC: %v Retrying in %v..."
,
err
,
sf
.
ReconnectTimeout
)
}
select
{
case
<-
time
.
After
(
time
.
Second
*
sf
.
ReconnectTimeout
)
:
case
<-
time
.
After
(
sf
.
ReconnectTimeout
)
:
continue
case
<-
snowflakes
.
Melted
()
:
log
.
Println
(
"ConnectLoop: stopped."
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment