snowflake/broker
Cecylia Bocovich 78cf8e68b2
Simplify broker metrics and remove mutexes
This is a large change to how the snowflake broker metrics are
implemented. This change removes all uses of mutexes from the metrics
implementation in favor of atomic operations on counters stored in
sync.Map.

There is a small change to the actual metrics output. We used to count
the same proxy ip multiple times in our snowflake-ips-total and
snowflake-ips country stats if the same proxy ip address polled more
than once with different proxy types. This was an overcounting of the
number of unique proxy IP addresses that is now fixed.

If a unique proxy ip polls with more than one proxy type or nat type,
these polls will still be counted once for each proxy type or nat type
in our proxy type and nat type specific stats (e.g.,
snowflake-ips-nat-restricted and snowflake-ips-nat-unrestricted).
2025-06-24 13:12:10 -04:00
..
amp.go Comment typo. 2025-06-19 15:39:24 +00:00
bridge-list.go Better error msg on bad fingerprint 2024-09-04 10:47:08 -04:00
bridge-list_test.go Move the development to gitlab 2023-05-31 10:01:47 +02:00
broker.go Remove default relay pattern option from broker 2025-03-26 13:32:30 -04:00
http.go Remove broker log messages for invalid SDP and SQS cleanup 2025-03-27 15:34:09 -04:00
ipc.go Simplify broker metrics and remove mutexes 2025-06-24 13:12:10 -04:00
metrics.go Simplify broker metrics and remove mutexes 2025-06-24 13:12:10 -04:00
README.md Cleaned up and reorganized READMEs 2021-07-19 10:16:26 -04:00
snowflake-broker_test.go Simplify broker metrics and remove mutexes 2025-06-24 13:12:10 -04:00
snowflake-heap.go Encode client-broker messages as json in HTTP body 2021-06-02 09:52:42 -04:00
sqs.go Remove broker log messages for invalid SDP and SQS cleanup 2025-03-27 15:34:09 -04:00
sqs_test.go Remove default relay pattern option from broker 2025-03-26 13:32:30 -04:00
test_bridgeList.txt add test_bridgeList.txt file 2024-08-21 20:50:59 +04:00
test_geoip Implemented geoip lookups for the snowflake broker. This heavily based off of how tor maps IP addresses to country codes, and relies on the provided ipv4 and ipv6 files. 2019-04-29 17:10:15 -04:00
test_geoip6 Implemented geoip lookups for the snowflake broker. This heavily based off of how tor maps IP addresses to country codes, and relies on the provided ipv4 and ipv6 files. 2019-04-29 17:10:15 -04:00

Table of Contents

This is the Broker component of Snowflake.

Overview

The Broker handles the rendezvous by matching Snowflake Clients with Proxies, and passing their WebRTC Session Descriptions (the "signaling" step). This allows Clients and Proxies to establish a Peer connection.

It is analogous to Flashproxy's Facilitator, but bidirectional and domain-fronted.

The Broker expects:

  • Clients to send their SDP offer in a POST request, which will then block until the Broker responds with the answer of the matched Proxy.
  • Proxies to announce themselves with a POST request, to which the Broker responds with some Client's SDP offer. The Proxy should then send a second POST request soon after containing its SDP answer, which the Broker passes back to the same Client.

Running your own

The server uses TLS by default. There is a --disable-tls option for testing purposes, but you should use TLS in production.

The server automatically fetches certificates from Let's Encrypt as needed. Use the --acme-hostnames option to tell the server what hostnames it may request certificates for. You can optionally provide a contact email address, using the --acme-email option, so that Let's Encrypt can inform you of any problems.

In order to fetch certificates automatically, the server needs to open an additional HTTP listener on port 80. On Linux, you can use the setcap program, part of libcap2, to enable the broker to bind to low-numbered ports without having to run as root:

setcap 'cap_net_bind_service=+ep' /usr/local/bin/broker

You can control the listening broker port with the --addr option. Port 443 is the default.

You'll need to provide the URL of the custom broker to the client plugin using the --url $URL flag.