Commit graph

89 commits

Author SHA1 Message Date
Cecylia Bocovich
920f6791f3 Add a go.mod and go.sum for snowflake 2020-03-05 09:21:17 -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
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
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
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
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
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
David Fifield
a554439370 Link to #26360 for why we blackhole logs without -log.
Maybe we'll able to remove this in the far future.
2018-12-18 21:24:32 -07:00
Arlo Breault
cce7ee64a7 Start refactoring out a client and library 2018-11-20 22:38:02 -05:00
David Fifield
6077141f4a Log to io.Discard if no log file is set.
https://bugs.torproject.org/25600#comment:14

Snowflake in Tor Browser has been hanging after surfing for a while.
(Tor reports "no running bridges".) It only began happening after commit
12922a232b, which caused snowflake-client not to log to a file by
default (leaving it to log to its default stderr). What seems to be
happening is that tor doesn't read from its PT clients' stderr, leaving
a buffer to fill up that eventually causes a hang.
2018-06-10 16:41:32 -07:00
David Fifield
bdc1798adb Exit immediately after SIGTERM is there are no signals running.
Cf. https://bugs.torproject.org/24875
2018-03-21 00:51:04 -07:00
David Fifield
6a9c2bf951 Don't log "SOCKS accepted" if there was an Accept error.
This actually caused a nil pointer dereference panic when Accept
returned an error, because conn was nil.
2018-03-21 00:43:17 -07:00
Arlo Breault
8a31312ca1 Provide a flag to Log to state dir 2018-03-13 15:00:58 -04:00
Arlo Breault
bbb5a6aca2 webrtc.NewIceServer already does this split / validation
It also expects to be called with a non-empty string, which isn't
the case with this Split which always envokes the loop at least
once.  If -ice was omitted, an error was logged.
2017-10-18 11:15:53 -04:00
David Fifield
0c02af35d0 Move handling of -ice option into main.
Rather than having it happen as a side effect of flag parsing.

Having it happen as a side effect of flag parsing caused log messages
related to handling the option (e.g. "IceServerList:") to always go to
stderr, despite the presence of a -log option. This is because the
requested log file had not been opened yet.
2017-08-14 12:33:28 -07:00
David Fifield
86a244c39e Make client and server-webrtc log in UTC. 2017-07-16 14:58:34 -07:00
David Fifield
12922a232b Make logging optional and controlled by a -log option. 2017-06-29 15:46:57 -07:00
David Fifield
f418ec7a85 Handle TOR_PT_EXIT_ON_STDIN_CLOSE. 2017-06-29 15:28:27 -07:00
David Fifield
1fa9bc051c Remove SIGINT handling (no longer part of pt-spec). 2017-06-29 15:20:54 -07:00
Arlo Breault
6cecd31fd8 Log to TOR_PT_STATE_LOCATION 2016-08-21 18:32:02 -07:00
Serene H
ac9d49b872 ensure closing stale remotes from the client side 2016-08-01 12:17:28 -07:00
Serene H
ea2e052a7d defer snowflake.Reset to fix handler recovery when localhost SOCKS occassionally fails first 2016-07-29 10:59:51 -07:00
Serene Han
e93c38f834 client multiplexes AND recovers correctly! (close #31)
- stabilize rest of WebRTCPeer
 - use uid for the datachannel label
 - store a consistent WebRTC config in the dialer
2016-06-15 21:57:56 -07:00
Serene Han
2bf0e5457e pull copyLoop out of goroutine, better pop and reset 2016-06-14 17:07:21 -07:00
Serene Han
a71c98c0ae able to break out of ConnectLoop, try separate webrtcConfigs as well 2016-06-13 15:12:47 -07:00
Serene Han
4ca0a3aa0a improve client interface specificity and composability which eliminates much unnecessary code 2016-06-13 11:10:49 -07:00
Serene Han
02562ba750 copy-paste rendezvous works again, but with new interface allowing seamless recovery for the first time 2016-06-12 12:43:24 -07:00
Serene Han
fedb124313 localize ptInfo and iceServers vars, separate copy-paste helpers, move some logging
to more sensible locations
2016-06-12 11:51:59 -07:00
Serene Han
b6f15a8d5c expose multiplex capacity as flag, un-global some more 2016-06-12 00:20:54 -07:00
Serene Han
2caa47988d fix Peers.Count() using activePeers list, mark for delete on Close, and remove
maxedChan
2016-06-11 23:59:26 -07:00
Serene Han
c63f5cfc0a Separate peers.go file with improved documentation and more solid interfaces 2016-06-11 19:58:08 -07:00
Serene Han
556596cc5a interfaces.go, SnowflakeCollector, better composition 2016-05-24 15:18:54 -07:00
Serene Han
b2c9fcac5e webRTCConn has better seam with BytesLogger interface 2016-05-24 12:56:09 -07:00
Serene Han
6b8568cc6c client interfaces compose better, remove some globals, test ConnectLoop 2016-05-19 19:44:54 -07:00
Serene Han
00196bbd74 more complete and improved client rendezvous tests 2016-05-18 13:21:01 -07:00
Serene Han
1d1882b59d webRTCConn close as part of its reset, instead of depending on external deferred close after receiving reset channel, allows valid disconnections even before use 2016-04-05 10:29:17 -07:00
Serene Han
bc1a499bc8 use only one BrokerChannel 2016-04-05 10:29:17 -07:00
Serene Han
b2d7586cb4 use webrtcRemotes len for capacity instead of the chan 2016-03-27 09:08:54 -07:00
Serene Han
22ace32a71 replace webrtcRemote with webrtcRemotes map & indexing, client multiplexing remotes confirmed working (#31) 2016-03-27 09:08:54 -07:00