Commit graph

296 commits

Author SHA1 Message Date
David Fifield
d376d7036b Make WebRTCPeer and Peers not inherit the methods of BytesLogger.
You would have been able to do, for example,
snowflake.(*WebRTCPeer).AddInbound(...).
2020-04-23 21:38:44 -06:00
David Fifield
65ecb798ca Update a comment (no signal pipe anymore). 2020-04-23 20:36:55 -06:00
David Fifield
2022496d3b Use a global RedialPacketConn and smux.Session.
This allows multiple SOCKS connections to share the available proxies,
and in particular prevents a SOCKS connection from being starved of a
proxy when the maximum proxy capacity is less then the number of the
number of SOCKS connections.

This is option 4 from https://bugs.torproject.org/33519.
2020-04-23 16:03:03 -06:00
David Fifield
70126177fb Turbo Tunnel client and server.
The client opts into turbotunnel mode by sending a magic token at the
beginning of each WebSocket connection (before sending even the
ClientID). The token is just a random byte string I generated. The
server peeks at the token and, if it matches, uses turbotunnel mode.
Otherwise, it unreads the token and continues in the old
one-session-per-WebSocket mode.
2020-04-23 16:02:56 -06:00
David Fifield
904af9cb8a Let copyLoop exit when either direction finishes.
Formerly we waiting until *both* directions finished. What this meant in
practice is that when the remote connection ended, copyLoop would become
useless but would continue blocking its caller until something else
finally closed the socks connection.
2020-04-23 14:00:03 -06:00
David Fifield
ee2fb42d33 Immediately and unconditionally grant new SOCKS connections. 2020-04-23 14:00:03 -06:00
David Fifield
8eef3b6348 Remove uniuri dependency.
https://bugs.torproject.org/33800
2020-04-03 17:52:44 -06:00
David Fifield
237fed1151 Update GitHub issue numbers to Trac ticket numbers. 2020-04-02 12:36:09 -06:00
Cecylia Bocovich
ea01bf41c3 Change dummy address for snowflake
This will prevent a bug where tor skips bandwidth events for local
addresses (see https://bugs.torproject.org/33693)
2020-04-01 12:55:37 -04:00
Arlo Breault
670e4ba438 Move StripLocalAddresses to a common util
Trac: 19026
2020-03-26 13:13:15 -04:00
Arlo Breault
5fa7578655 Rename logToStateDir/keepLocalAddresses to kebab case
https://en.wikipedia.org/wiki/Letter_case#Special_case_styles
2020-03-25 11:53:24 -04:00
Arlo Breault
f58c865d82 Add unsafe logging 2020-03-25 11:53:24 -04:00
Arlo Breault
d10af300c1 Refactor (De)SerializeSessionDescription as common utils 2020-03-17 20:16:58 -04:00
Cecylia Bocovich
920f6791f3 Add a go.mod and go.sum for snowflake 2020-03-05 09:21:17 -05:00
Arlo Breault
1220853a67 Restructure a bit based on review 2020-02-08 10:13:40 -05:00
Arlo Breault
846473b354 Unmarshal the SDP to filter attributes
Instead of string manipulation.
2020-02-08 10:13:40 -05:00
Arlo Breault
0fae4ee8ea Remove local LAN address ICE candidates
Unfortunately, the "public" RTCIceTransportPolicy was removed.

https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration#RTCIceTransportPolicy_enum

Trac: 19026
2020-02-08 10:13:40 -05:00
David Fifield
a2292ce35b Make timeout constants into time.Duration values.
This slightly changes some log messages.
2020-01-31 00:08:50 -07:00
David Fifield
dfb83c6606 Allow handling multiple SOCKS connections simultaneously.
Close the SOCKS connection in the same function that opens it.
2020-01-30 10:18:23 -07:00
Cecylia Bocovich
50673d4943 Remove client test with nil broker
We are no longer checking for nil BrokerChannels in Catch because this
case is caught from the return values of NewBrokerChannel. This change
caused a no longer necessary unit test to hang.
2020-01-29 11:40:29 -05:00
Cecylia Bocovich
7682986a45 Update client tests for NewBrokerChannel errors
We changed NewBrokerChannel to return an error value on failure. This
updates the tests to check that value.
2020-01-29 11:27:44 -05:00
David Fifield
57d4b0b5bd Use lowercase variable names in copyLoop. 2020-01-28 03:04:33 -07:00
David Fifield
bc5498cb4b Fix the order of arguments of client copyLoop to match the call.
The call was
	copyLoop(socks, snowflake)
but the function signature was
	func copyLoop(WebRTC, SOCKS io.ReadWriter) {

The mistake was mostly harmless, because both arguments were treated the
same, except that error logs would have reported the wrong direction.
2020-01-28 03:04:14 -07:00
David Fifield
db1ba4791b Simplify NewWebRTCDialer. 2020-01-27 20:53:27 -07:00
David Fifield
2fb52c8639 Check for an invalid broker URL at a higher level.
Instead of returning nil from NewBrokerChannel and having
WebRTCDialer.Catch check for nil, let NewBrokerChannel return an error
and bail out before calling WebRTCDialer.Catch.

Suggested by cohosh.
https://bugs.torproject.org/33040#comment:3
2020-01-27 20:50:26 -07:00
David Fifield
f1ab65b1c0 Close the melt channel, don't just send once on it.
Closing the channel makes it always immediately selectable.
2020-01-23 11:24:00 -07:00
David Fifield
febb4936f6 Refactor SOCKS-related logging. 2020-01-23 11:24:00 -07:00
David Fifield
aa3999857f Move ICE server logging out of parseIceServers. 2020-01-23 11:24:00 -07:00
David Fifield
509f634506 NewWebRTCDialer cannot return an error. 2020-01-23 11:24:00 -07:00
David Fifield
d6467ff585 Formatting improvements. 2020-01-23 10:43:31 -07:00
David Fifield
e27709080a Update a comment: we no longer keep track of handlers. 2020-01-23 10:42:35 -07:00
David Fifield
5ff75e1034 Remove erroneous logging around pt.*Error calls.
These functions are called for their side effect of sending a PT error
message on stdout; they also return a representation of the error
message as an error object for the caller to use if it wishes. These
functions *always* return a non-nil error object; it is not something to
be logged, any more than the return value of errors.New is.

The mistaken logging was added in
https://bugs.torproject.org/31794
b26c7a7a73
3ec9dd19fa
ed3d42e1ec
2020-01-20 23:57:31 -07:00
Cecylia Bocovich
0f99c5ab12 Touched up snowflake client tests
There were a few tests that needed refreshing since the introduction of
the pion library. Also added a few tests for the ICE server parsing
function in the client.
2019-12-06 11:30:34 -05:00
David Fifield
b4f4b29a03 Stop counting handlers before terminating.
The requirement to do so is obsolete and has already been removed from
other pluggable transports.

https://bugs.torproject.org/32046
2019-10-11 16:50:25 -06:00
Shane Howearth
01156e58eb Remove unnecessary initialisation of last
last was initialised twice (creating a shadow), the second time inside
a case statement. The second initialisation is removed, keeping the use
of last aligned to the isame style as its use other parts of the case
statement.
2019-10-08 10:25:44 -04:00
Shane Howearth
8bbdb3b51a Bring code into line with Golangci-lint linters
- Error strings are no longer capitalized nor end with punctuation
- Alias import
- Remove extraneous initilisation code (No need to provide zero value
	for variables, because the compiler does that anyway)
2019-10-08 10:25:44 -04:00
Shane Howearth
b26c7a7a73 Handle generated errors in client 2019-10-08 10:25:44 -04:00
Shane Howearth
3ec9dd19fa Handle generated errors in server-webrtc 2019-10-08 10:12:36 -04:00
Cecylia Bocovich
82e5753bcc Reverted logging changes that require Go 1.13 2019-10-08 09:58:12 -04:00
Cecylia Bocovich
2b04357550 Connect pion library logger with snowflake log
We need to set up the pion/webrtc logger to write output to the
snowflake log, otherwise the warnings we are getting from the pion
library are being lost.

Note: this requires go version 1.13 and later in order to use the
`log.Writer()` function.
2019-10-08 09:27:52 -04:00
Cecylia Bocovich
97bab94e67 Make sure command line ice servers are used
This commit fixes a small error introduced in a previous commit. Servers
given by command line options weren't being added to the configuration
because we were checking for `iceServers` to be nil instead of not nil.
2019-10-08 09:27:52 -04:00
Cecylia Bocovich
b5c50b69d0 Ported snowflake client to work with pion/webrtc
Modified the snowflake client to use pion/webrtc as the webrtc library.
This involved a few small changes to match function signatures as well
as several larger ones:
- OnNegotiationNeeded is no longer supported, so CreateOffer and
SetLocalDescription have been moved to a go routine called after the
other peer connection callbacks are set
- We need our own deserialize/serialize functions
- We need to use a SettingEngine in order to access the
OnICEGatheringStateChange callback
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
0842dad38e Added tests to check large read guards 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
5380aaca8c Use OnIceGatheringStateChange instead of OnIceComplete in client
Amounts to the same thing as currently implemented in go-webrtc
2019-05-21 14:34:40 -04:00
Arlo Breault
622005c79e Remove copy/paste signalling 2019-05-08 11:21:56 -04:00
Cecylia Bocovich
b4a4a256db Ported log sanitization to client 2019-04-12 09:52:23 -04:00