Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Snowflake WebExtension
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 WebExtension
Commits
11bd32f6
Commit
11bd32f6
authored
5 years ago
by
Cecylia Bocovich
Browse files
Options
Downloads
Patches
Plain Diff
Remove now unecessary timeoutConn
parent
76087a6a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
proxy-go/snowflake.go
+5
-24
5 additions, 24 deletions
proxy-go/snowflake.go
with
5 additions
and
24 deletions
proxy-go/snowflake.go
+
5
−
24
View file @
11bd32f6
...
...
@@ -204,38 +204,19 @@ func sendAnswer(sid string, pc *webrtc.PeerConnection) error {
return
nil
}
type
timeoutConn
struct
{
c
net
.
Conn
t
time
.
Duration
}
func
(
tc
timeoutConn
)
Read
(
buf
[]
byte
)
(
int
,
error
)
{
return
tc
.
c
.
Read
(
buf
)
}
func
(
tc
timeoutConn
)
Write
(
buf
[]
byte
)
(
int
,
error
)
{
return
tc
.
c
.
Write
(
buf
)
}
func
(
tc
timeoutConn
)
Close
()
error
{
return
tc
.
c
.
Close
()
}
func
CopyLoopTimeout
(
c1
net
.
Conn
,
c2
net
.
Conn
,
timeout
time
.
Duration
)
{
tc1
:=
timeoutConn
{
c
:
c1
,
t
:
timeout
}
tc2
:=
timeoutConn
{
c
:
c2
,
t
:
timeout
}
func
CopyLoop
(
c1
net
.
Conn
,
c2
net
.
Conn
)
{
var
wg
sync
.
WaitGroup
copyer
:=
func
(
dst
io
.
ReadWriteCloser
,
src
io
.
ReadWriteCloser
)
{
defer
wg
.
Done
()
if
_
,
err
:=
io
.
Copy
(
dst
,
src
);
err
!=
nil
{
log
.
Printf
(
"io.Copy inside CopyLoop
Timeout
generated an error: %v"
,
err
)
log
.
Printf
(
"io.Copy inside CopyLoop generated an error: %v"
,
err
)
}
dst
.
Close
()
src
.
Close
()
}
wg
.
Add
(
2
)
go
copyer
(
t
c1
,
t
c2
)
go
copyer
(
t
c2
,
t
c1
)
go
copyer
(
c1
,
c2
)
go
copyer
(
c2
,
c1
)
wg
.
Wait
()
}
...
...
@@ -271,7 +252,7 @@ func datachannelHandler(conn *webRTCConn, remoteAddr net.Addr) {
log
.
Printf
(
"connected to relay"
)
defer
wsConn
.
Close
()
wsConn
.
PayloadType
=
websocket
.
BinaryFrame
CopyLoop
Timeout
(
conn
,
wsConn
,
time
.
Minute
)
CopyLoop
(
conn
,
wsConn
)
log
.
Printf
(
"datachannelHandler ends"
)
}
...
...
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