aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-06-03[WIP] Split broker into componentsi26092Arlo Breault
Exploring #26092
2021-06-03Get rid of legacy versionArlo Breault
Move the logic for the legacy version into the http handlers and use a shim when doing ipc.
2021-06-02Move http handlers to a separate fileArlo Breault
2021-06-02Intermediary refactor teasing apart http / ipcArlo Breault
Introduces an IPC struct and moves the logic out of the http handlers and into methods on that.
2021-06-02Add man pages for proxy and client commandsmeskio
To be used by the debian package (#19409)
2021-06-02Encode client-broker messages as json in HTTP bodyCecylia Bocovich
Send the client poll request and response in a json-encoded format in the HTTP request body rather than sending the data in HTTP headers. This will pave the way for using domain-fronting alternatives for the Snowflake rendezvous.
2021-05-24Release resources in client Transport.Dial on error.David Fifield
Make a stack of cleanup functions to run (as with defer), but clear the stack before returning if no error occurs. Uselessly pushing the stream.Close() cleanup just before clearing the stack is an intentional safeguard, for in case additional operations are added before the return in the future. Fixes #40042.
2021-05-24Fix error handling around transport.Dial.David Fifield
The code checked for and displayed an error, but would then go on to call copyLoop on the nil Conn returned from transport.Dial. Add a return in that case, and put the cleanup operations in defer. Also remove an obsolete comment about an empty address. Obsolete because: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/31#note_2733279
2021-05-21Stop timers before expirationDavid Fifield
If we don't stop them explicitly, the timers will not get garbage collected until they timeout: https://medium.com/@oboturov/golang-time-after-is-not-garbage-collected-4cbc94740082 Related to #40039
2021-05-20Remove sync.Once from around logMetricsArlo Breault
Follow up to 160ae2d Analysis by @dcf, > I don't think the sync.Once around logMetrics is necessary anymore. Its original purpose was to inhibit logging on later file handles of metrics.log, if there were more than one opened. See 171c55a9 and #29734 (comment 2593039) "Making a singleton *Metrics variable causes problems with how Convey does tests. It shouldn't be called more than once, but for now I'm using sync.Once on the logging at least so it's explicit." Commit ba4fe1a7 changed it so that metrics.log is opened in main, used to create a *log.Logger, and that same instance of *log.Logger is passed to both NewMetrics and NewBrokerContext. It's safe to share the same *log.Logger across multiple BrokerContext.
2021-05-18Make promMetrics not a globalArlo Breault
Doesn't seem like it needs to exist outside of the metrics struct. Also, the call to logMetrics is moved to the constructor. A metrics instance is only created when a BrokerContext is created, which only happens at startup. The sync of only doing that once is left for documentation purposes, since it doesn't hurt, but also seems redundant.
2021-05-12Update .gitlab-ci.yml after refactor of clientCecylia Bocovich
2021-05-12Ensure turbotunnel read and write loop terminateCecylia Bocovich
Introduce a waitgroup and done channel to ensure that both the read and write gorouting for turbotunnel connections terminate when the connection is closed.
2021-05-12Implement server as a v2.1 PT Go APICecylia Bocovich
2021-05-12Implement snowflake client lib as PTv2.1 Go APICecylia Bocovich
This implements a pluggable transports v2.1 compatible Go API in the Snowflake client library, and refactors how the main Snowflake program calls it. The Go API implements the two required client side functions: a constructor that returns a Transport, and a Dial function for the Transport that returns a net.Conn. See the PT specification for more information: https://github.com/Pluggable-Transports/Pluggable-Transports-spec/blob/master/releases/PTSpecV2.1/Pluggable%20Transport%20Specification%20v2.1%20-%20Go%20Transport%20API.pdf
2021-04-26Replace default with custom prometheus registrymasterCecylia Bocovich
The default prometheus registry exports data that may be useful for side-channel attacks. This removes all of the default metrics and makes sure we are only reporting snowflake metrics from the broker.
2021-04-26Add new gauge to show currently available proxiesCecylia Bocovich
2021-04-26Implement binned counts for polling metricsCecylia Bocovich
2021-04-22Export snowflake broker metrics for prometheusCecylia Bocovich
This change adds a prometheus exporter for our existing snowflake broker metrics. Current values for the metrics can be fetched by sending a GET request to /prometheus.
2021-04-01Switch front domain and host to fastlyCecylia Bocovich
2021-03-25Update Go version for .gitlab-ci.ymlCecylia Bocovich
2021-03-18Update webrtc library to v3.0.15Cecylia Bocovich
This fixes a vulnerability in the library: CVE-2021-28681
2021-03-18Don't log errors from callng close on OR connsCecylia Bocovich
Snowflake copies data between the OR connection and the KCP stream, meaning that in most cases the copy loops will only terminate once the OR connection times out. In this case the OR connection is already closed and so calls to CloseRead and CloseWrite will generate errors.
2021-03-18Don't log io.ErrClosedPipe in serverCecylia Bocovich
These errors are triggered in three places when the OR connection times out. They don't tell us anything useful and are filling up our logs.
2021-03-05Update required Go version to 1.13 in README.David Fifield
2021-02-02Log a throughput summary for each connectionCecylia Bocovich
This will increase transparency for people running standalone proxies and help us debug any potential issues with proxies behaving unreliably.
2021-01-25Classify proxies with unknown NATs as restrictedCecylia Bocovich
2021-01-25Bump version of pion/sdpCecylia Bocovich
Update our dependency on pion/sdp from v2 to v3, to match pion/webrtc v3. This requires some changes in how we parse out addresses from ice candidates. This will ease tor browser builds of snowflake since we are now only relying on one version of pion/sdp instead of two different ones.
2021-01-12Update webrtc library to v3.0.0Cecylia Bocovich
This update required two main changes to how we use the library. First, we had to make sure we created the datachannel on the offering peer side before creating the offer. Second, we had to make sure we wait for the gathering of all candidates to complete since trickle-ice is enabled by default. See the release notes for more details: https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0.
2020-12-17Increase the KCP maximum window sizeCecylia Bocovich
2020-12-16Pass lock to socksAcceptLoop by referenceCecylia Bocovich
This fixes a bug where we were passing the lock by value to socksAcceptLoop.
2020-12-05Avoid double delay in client from ReconnectTimeoutCecylia Bocovich
Run the snowflake collection ReconnectTimeout timer in parallel to the negotiation with the broker. This way, if the broker takes a long time to respond the client doesn't have to wait the full timeout to respond.
2020-12-05Wait until all goroutines finish before shutdownCecylia Bocovich
2020-12-05Send shutdown signal to shutdown open connectionsCecylia Bocovich
Normally all dangling goroutines are terminated when the main function exits. However, for projects that use a patched version of snowflake as a library, these goroutines continued running as long as the main function had not yet terminated. This commit has all open SOCKS connections close after receiving a shutdown signal.
2020-12-04Create new smux session for each SOCKS connectionCecylia Bocovich
Each SOCKS connection has its own set of snowflakes and broker poll loop. Since the session manager was tied to a single set of snowflakes, this resulted in a bug where RedialPacketConn would sometimes try to pull snowflakes from a previously melted pool. The fix is to maintain separate smux sessions for each SOCKS connection, tied to its own snowflake pool.
2020-11-27Sort snowflake-ips stats by country count.Philipp Winter
We currently don't sort the snowflake-ips metrics: snowflake-ips CA=1,DE=1,AR=1,NL=1,FR=1,GB=2,US=4,CH=1 To facilitate eyeballing our metrics, this patch sorts snowflake-ips by value. If the value is identical, we sort by string, i.e.: snowflake-ips US=4,GB=2,AR=1,CA=1,CH=1,DE=1,FR=1,NL=1 This patch fixes tpo/anti-censorship/pluggable-transports/snowflake#40011
2020-11-23Remove for loop around broker.NegotiateCecylia Bocovich
Instead of continuously polling the broker until the client receives a snowflake, fail back to the Connect() loop and try again to collect more peers after ReconnectTimeout.
2020-11-20Note that isRestrictedFiltering is no longer usedCecylia Bocovich
2020-11-20Use remote probe to determine proxy NAT typeCecylia Bocovich
Rather than having standalone proxies determine their NAT type by conducting the NAT behaviour checks in RFC 5780, use the remote probe service instead.
2020-11-18Add a stub sid to probetest answerCecylia Bocovich
This will prevent calls to DecodeAnswerRequest from returning an error even though the sid is not needed for the probetest.
2020-11-18Redefine only symmetric NATs as restrictedCecylia Bocovich
2020-11-05Revert accidentally merged codeCecylia Bocovich
Some temporary testing code for the proxy got accidentally merged into the latest changes. This commit undoes that mistake.
2020-11-05Make probetest wait for a datachannel to openCecylia Bocovich
2020-11-05Fixed a bug that forced datachannel timeoutCecylia Bocovich
The probetest answer response was not being sent until the select call received a datachannel timeout causing all attempted connections to fail.
2020-10-29Add Dockerfile and README for deploying probetestCecylia Bocovich
The easiest way to set up the probe server behind a symmetric NAT is to deploy it as a Docker container and alter the iptables rules for the Docker network subnet that the container runs in.
2020-10-29Add a remote service to test NAT compatabilityCecylia Bocovich
Add a remote probetest service that will allow proxies to test their compatability with symmetric NATs.
2020-10-29Refactor proxy to reuse signaling codeCecylia Bocovich
Simplify proxy interactions with the broker signaling server and prepare for the introduction of an additional signaling server.
2020-10-22Don't log io.ErrClosedPipe in proxy.David Fifield
We expect one of these at the end of just about every proxy session, as the Conns in both directions are closed as soon as the copy loop finishes in one direction. Closes #40016.
2020-10-15Add synchronization to prevent post-melt collectsCecylia Bocovich
This fixes a race condition in which snowflakes.End() is called while snowflakes.Collect() is in progress resulting in a write to a closed channel. We now wait for all in-progress collections to finish and add an extra check before proceeding with a collection.
2020-10-05Extract remote address from ICE candidatesCecylia Bocovich
Parse the received ICE candidates as well as the Connection Data field for a non-local IP address to pass to the bridge. This fixes bug #33157.