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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Cecylia Bocovich
Snowflake WebExtension
Commits
b26c7a7a
Commit
b26c7a7a
authored
5 years ago
by
Shane Howearth
Committed by
Cecylia Bocovich
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Handle generated errors in client
parent
78a37844
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/lib/snowflake.go
+5
-5
5 additions, 5 deletions
client/lib/snowflake.go
client/lib/webrtc.go
+8
-3
8 additions, 3 deletions
client/lib/webrtc.go
client/snowflake.go
+15
-6
15 additions, 6 deletions
client/snowflake.go
with
28 additions
and
14 deletions
client/lib/snowflake.go
+
5
−
5
View file @
b26c7a7a
...
...
@@ -56,18 +56,18 @@ func Handler(socks SocksConnector, snowflakes SnowflakeCollector) error {
// Exchanges bytes between two ReadWriters.
// (In this case, between a SOCKS and WebRTC connection.)
func
copyLoop
(
a
,
b
io
.
ReadWriter
)
{
func
copyLoop
(
WebRTC
,
SOCKS
io
.
ReadWriter
)
{
var
wg
sync
.
WaitGroup
wg
.
Add
(
2
)
go
func
()
{
if
_
,
err
:=
io
.
Copy
(
ORPort
,
WebRTC
);
err
!=
nil
{
log
.
Printf
(
"copying WebRTC to
ORPort
resulted in error: %v"
,
err
)
if
_
,
err
:=
io
.
Copy
(
SOCKS
,
WebRTC
);
err
!=
nil
{
log
.
Printf
(
"copying WebRTC to
SOCKS
resulted in error: %v"
,
err
)
}
wg
.
Done
()
}()
go
func
()
{
if
_
,
err
:=
io
.
Copy
(
WebRTC
,
ORPort
);
err
!=
nil
{
log
.
Printf
(
"copying
ORPort
to WebRTC resulted in error: %v"
,
err
)
if
_
,
err
:=
io
.
Copy
(
WebRTC
,
SOCKS
);
err
!=
nil
{
log
.
Printf
(
"copying
SOCKS
to WebRTC resulted in error: %v"
,
err
)
}
wg
.
Done
()
}()
...
...
This diff is collapsed.
Click to expand it.
client/lib/webrtc.go
+
8
−
3
View file @
b26c7a7a
...
...
@@ -138,7 +138,8 @@ func (c *WebRTCPeer) Connect() error {
}
err
=
c
.
establishDataChannel
()
if
err
!=
nil
{
return
errors
.
New
(
"WebRTC: Could not establish DataChannel."
)
// nolint: golint
return
errors
.
New
(
"WebRTC: Could not establish DataChannel"
)
}
err
=
c
.
exchangeSDP
()
if
err
!=
nil
{
...
...
@@ -151,7 +152,9 @@ func (c *WebRTCPeer) Connect() error {
// Create and prepare callbacks on a new WebRTC PeerConnection.
func
(
c
*
WebRTCPeer
)
preparePeerConnection
()
error
{
if
nil
!=
c
.
pc
{
c
.
pc
.
Close
()
if
err
:=
c
.
pc
.
Close
();
err
!=
nil
{
log
.
Printf
(
"c.pc.Close returned error: %v"
,
err
)
}
c
.
pc
=
nil
}
...
...
@@ -267,7 +270,9 @@ func (c *WebRTCPeer) establishDataChannel() error {
if
err
!=
nil
{
// TODO: Maybe shouldn't actually close.
log
.
Println
(
"Error writing to SOCKS pipe"
)
c
.
writePipe
.
CloseWithError
(
err
)
if
inerr
:=
c
.
writePipe
.
CloseWithError
(
err
);
inerr
!=
nil
{
log
.
Printf
(
"c.writePipe.CloseWithError returned error: %v"
,
inerr
)
}
}
if
n
!=
len
(
msg
.
Data
)
{
log
.
Println
(
"Error: short write"
)
...
...
This diff is collapsed.
Click to expand it.
client/snowflake.go
+
15
−
6
View file @
b26c7a7a
...
...
@@ -45,7 +45,7 @@ func ConnectLoop(snowflakes sf.SnowflakeCollector) {
}
// Accept local SOCKS connections and pass them to the handler.
func
socksAcceptLoop
(
ln
*
pt
.
SocksListener
,
snowflakes
sf
.
SnowflakeCollector
)
error
{
func
socksAcceptLoop
(
ln
*
pt
.
SocksListener
,
snowflakes
sf
.
SnowflakeCollector
)
{
defer
ln
.
Close
()
log
.
Println
(
"Started SOCKS listener."
)
for
{
...
...
@@ -55,7 +55,8 @@ func socksAcceptLoop(ln *pt.SocksListener, snowflakes sf.SnowflakeCollector) err
if
e
,
ok
:=
err
.
(
net
.
Error
);
ok
&&
e
.
Temporary
()
{
continue
}
return
err
log
.
Printf
(
"SOCKS accept error: %s"
,
err
)
break
}
log
.
Println
(
"SOCKS accepted: "
,
conn
.
Req
)
err
=
sf
.
Handler
(
conn
,
snowflakes
)
...
...
@@ -155,7 +156,9 @@ func main() {
log
.
Fatal
(
err
)
}
if
ptInfo
.
ProxyURL
!=
nil
{
pt
.
ProxyError
(
"proxy is not supported"
)
if
err
:=
pt
.
ProxyError
(
"proxy is not supported"
);
err
!=
nil
{
log
.
Printf
(
"call to pt.ProxyError generated error: %v"
,
err
)
}
os
.
Exit
(
1
)
}
listeners
:=
make
([]
net
.
Listener
,
0
)
...
...
@@ -165,14 +168,18 @@ func main() {
// TODO: Be able to recover when SOCKS dies.
ln
,
err
:=
pt
.
ListenSocks
(
"tcp"
,
"127.0.0.1:0"
)
if
err
!=
nil
{
pt
.
CmethodError
(
methodName
,
err
.
Error
())
if
inerr
:=
pt
.
CmethodError
(
methodName
,
err
.
Error
());
inerr
!=
nil
{
log
.
Printf
(
"handling error generated by pt.ListenSocks with pt.CmethodError generated error: %v"
,
inerr
)
}
break
}
go
socksAcceptLoop
(
ln
,
snowflakes
)
pt
.
Cmethod
(
methodName
,
ln
.
Version
(),
ln
.
Addr
())
listeners
=
append
(
listeners
,
ln
)
default
:
pt
.
CmethodError
(
methodName
,
"no such method"
)
if
err
:=
pt
.
CmethodError
(
methodName
,
"no such method"
);
err
!=
nil
{
log
.
Printf
(
"calling pt.CmethodError generated error: %v"
,
err
)
}
}
}
pt
.
CmethodsDone
()
...
...
@@ -186,7 +193,9 @@ func main() {
// This environment variable means we should treat EOF on stdin
// just like SIGTERM: https://bugs.torproject.org/15435.
go
func
()
{
io
.
Copy
(
ioutil
.
Discard
,
os
.
Stdin
)
if
_
,
err
:=
io
.
Copy
(
ioutil
.
Discard
,
os
.
Stdin
);
err
!=
nil
{
log
.
Printf
(
"calling io.Copy(ioutil.Discard, os.Stdin) returned error: %v"
,
err
)
}
log
.
Printf
(
"synthesizing SIGTERM because of stdin close"
)
sigChan
<-
syscall
.
SIGTERM
}()
...
...
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