Commit graph

42 commits

Author SHA1 Message Date
David Fifield
e47dd5e2b4 Remove some redundancy in websocketconn naming.
Rename websocketconn.WebSocketConn to websocketconn.Conn, and
       websocketconn.NewWebSocketConn to websocketconn.New

Following the guidelines at
https://blog.golang.org/package-names#TOC_3%2e
2020-01-30 10:18:23 -07:00
Cecylia Bocovich
7277bb37cd Update broker--proxy protocol with proxy type
Proxies now include information about what type they are when they poll
for client offers. The broker saves this information along with
snowflake ids and outputs it on the /debug page.
2019-11-28 13:52:58 -05:00
Arlo Breault
7092b2cb2c Revert abstracting copyloop 2019-11-21 19:33:39 -05:00
Arlo Breault
30b5ef8a9e Use gorilla websocket in proxy-go too
Trac: 32465
2019-11-20 19:33:28 -05:00
Cecylia Bocovich
446f39a9e5 Use http.RoundTripper for connections to broker
This change makes it easier for us to write tests with mock transports
2019-11-13 13:57:14 -05:00
Cecylia Bocovich
32bec89a84 Add tests for session descripion functions
Also removed some unnecessary code
2019-11-13 13:57:06 -05:00
Cecylia Bocovich
c4ae64905b Redo protocol for proxy--broker messages
Switch to containing all communication between the proxy and the broker
in the HTTP response body. This will make things easier if we ever use
something other than HTTP communicate between different actors in the
snowflake system.

Other changes to the protocol are as follows:
- requests are accompanied by a version number so the broker can be
backwards compatable if desired in the future
- all responses are 200 OK unless the request was badly formatted
2019-11-13 10:54:48 -05:00
Cecylia Bocovich
11bd32f62e Remove now unecessary timeoutConn 2019-10-25 17:12:45 -04:00
Cecylia Bocovich
76087a6a77 Don't log error messages from SetDeadline
We haven't implemented SetDeadline for webRTCConn and the error messages
are misleading to proxy-go operators.
2019-10-25 15:34:41 -04:00
Shane Howearth
78a37844b2 Handle generated errors in proxy-go 2019-10-08 10:25:36 -04:00
Cecylia Bocovich
0428797ea0 Modified proxy-go to use pion/webrtc
The API is very similar, differences were mostly due to:
- closing peer connections and datachannels (no destroy/delete methods)
- different way to set datachannel/peer connection callbacks
- differences in whether functions take pointers or values
- no serialize/deserialize functions in the API
2019-10-08 09:27:52 -04:00
Cecylia Bocovich
cd650fa009 Keyed composite literal to avoid go vet warning 2019-05-28 13:58:16 -04:00
Cecylia Bocovich
254e6b9a3d Simplified limitedReader by reading one extra byte 2019-05-28 13:29:59 -04:00
Cecylia Bocovich
1d76d3ca2e Implement limitedRead function for client side
MaxBytesReader is only documented for server side reads, so we're using
a local limitedRead function instead that uses an io.LimitedReader.

Declared limits in a commented constant
2019-05-28 13:29:59 -04:00
Cecylia Bocovich
ce3101d016 Guard against large reads
This is a fix for #26348
2019-05-28 13:29:59 -04:00
Arlo Breault
2e4383434f Move datachannel timeout to after sendAnswer return 2019-05-20 15:43:55 -04:00
Cecylia Bocovich
695dd10b2c Fix for ticket #30206
This fixes a bug introduced by the deadlock patch for ticket #25688.
2019-05-08 17:45:55 -04:00
Cecylia Bocovich
482d60d9d3 Use safelog scrubber in broker and proxy-go 2019-04-11 14:47:31 -04:00
Cecylia Bocovich
62fddab153 Moved data channel timeout to constant 2019-04-05 10:40:11 -04:00
Cecylia Bocovich
08f5205461 Added check to see if peer connection succeeded
This is related to the proxy-go deadlock bug #25688. If a client doesn't
do anything with the SDP answer, a token will get lost. Added a timeout
after a minute that checks the PeerConnection state and destroys the
peer connection and returns a token if did not yet succeed
2019-04-03 15:59:47 -04:00
Cecylia Bocovich
c28c8ca489 Fix for proxy deadlock bug
This is a fix for the proxy-go deadlock bug (ticket #25688). The
assumption that OnIceComplete is always followed by a successful
connection where OnDataChannel has been called turns out not to occur in
practice. OnICEComplete looks like it is being deprecated in other
libraries anyway, so it's safer to just remove it.
2019-04-03 13:44:48 -04:00
David Fifield
947636ae81 Change to standalone broker.
https://snowflake-reg-test.appspot.com/ for the client (needs domain fronting)
https://snowflake-broker.bamsoftware.com/ for the proxies (no fronting)

Note that fronting to App Engine doesn't currently actually work because
of https://bugs.torproject.org/25804; this commit doesn't change that.
2018-04-16 10:24:00 -07:00
David Fifield
07291a0136 Add a 5s delay between polls in proxy-go.
https://bugs.torproject.org/25344

5s matches DEFAULT_BROKER_POLL_INTERVAL in the JavaScript proxy.

This is set up so as long as the actual HTTPS requests take less time
than pollInterval, there will a steady one poll per pollInterval. If the
HTTPS requests take longer than that, there will be no delay between
polls.
2018-03-21 22:52:30 -07:00
Arlo Breault
1114acbcb4 Add synchronization around destroying DataChannels and PeerConnections
From https://trac.torproject.org/projects/tor/ticket/21312#comment:33
2018-03-20 15:08:36 -04:00
Arlo Breault
f2abf5b60c Try to protect against crash from dereferencing a NULL in go-proxy
Follow up to ff8f385

Similar to c834c76
2018-03-14 00:15:13 -04:00
Arlo Breault
42ec097a58 Allow broker base url to have a path 2018-03-14 00:04:59 -04:00
David Fifield
44ab82bc61 Add a "starting" log line to proxy-go. 2018-03-13 19:25:41 -07:00
Arlo Breault
ff8f385108 Call explicit frees in proxy-go 2018-03-08 13:46:55 -05:00
Arlo Breault
da8b37e866 Fix go vet complaint
"net.IPAddr composite literal uses unkeyed fields"
2017-10-18 11:34:00 -04:00
Hooman
ae0643320e Pass client IP from proxy-go to server by parsing SDP
Call conn.RemoteAddr() before entering the datachannelHandler goroutine.
This is a workaround for the hang described at
https://bugs.torproject.org/18628#comment:8
2017-10-14 15:06:33 -04:00
David Fifield
3e3e4b8dd9 Deglobalize some flag-controlled variables.
Remove global opt struct.
2017-08-01 15:53:36 -07:00
David Fifield
1eb5c66428 Stop writing to global opt.brokerURL variable.
This variable was being written to by multiple goroutines, overwriting
the Path to either "/proxy" or "/answer" as necessary, which was racy.
2017-08-01 15:51:34 -07:00
David Fifield
461dbeba80 Make capacity a uint.
This prohibits some nonsense like "./proxy-go -capacity -550", which
otherwise results in a panic like:

INFO: configuration.go:174: Created Configuration at  &{[{[stun:stun.l.google.com:19302]  }] All Balanced }
panic: makechan: size out of range
2017-08-01 15:06:53 -07:00
David Fifield
dbe1ef4fa5 Remove unused stunURL and relayURL, unused except for parsing tests. 2017-08-01 10:55:14 -07:00
David Fifield
5440a4ba16 fmt 2017-07-25 18:59:15 -07:00
David Fifield
bfea72b50e Have proxy-go log in UTC. 2017-06-29 16:44:17 -07:00
David Fifield
b0dbf47473 Move some default config into constants at the stop. 2017-06-29 16:11:03 -07:00
David Fifield
c2c1a9d09d Enable proxy-go to create its log file. 2017-06-29 16:09:25 -07:00
David Fifield
faeb8da8c9 Use crypto/rand, not math/rand, to generate session IDs.
math/rand always uses a deterministic seed. The sequence of session IDs
was therefore always the same:
	Uv38ByGCZU8WP18PmmIdcg
	lWbHTRDYaB0NhtHpHgAWeQ
	...

Multiple copies of this program would have had session ID collisions. I
don't know what the consequences of that would be.
2017-06-29 16:00:29 -07:00
David Fifield
af8a026991 Improve some error messages. 2017-06-29 15:59:07 -07:00
David Fifield
c3f87281be Add -log option to proxy-go. 2017-06-29 15:11:14 -07:00
yinghuocho
4b5794c935 Golang implementation of standalone snowflake proxy 2017-04-24 16:16:02 -07:00