Commit graph

1223 commits

Author SHA1 Message Date
itchyonion
a6a18c1a9b
Parse ICE servers with pion/ice library function 2023-01-30 09:10:15 -08:00
David Fifield
b443e99417 Bring client torrc up to date with Tor Browser fc89e8b1.
https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commits/fc89e8b10c3ff30db2079b2fb327d05b2b5f3c80/projects/common/bridges_list.snowflake.txt

* Use port 80 in placeholder IP addresses
  tpo/applications/tor-browser-build!516
* Enable uTLS
  tpo/applications/tor-browser-build!540
* Shorten bridge line (remove stun.voip.blackberry.com)
  tpo/applications/tor-browser-build!558
* Add snowflake-02 bridge
  tpo/applications/tor-browser-build!571
2023-01-19 11:37:23 -07:00
Shelikhoo
7b77001eaa
Update version to v2.5.1 2023-01-18 14:37:05 +00:00
Shelikhoo
44c76ce3ad
Fix helloverify remove patch not applied 2023-01-18 14:36:18 +00:00
Shelikhoo
daa9b535c8
Update Version to v2.5.0 2023-01-18 11:27:31 +00:00
Shelikhoo
10fd000685
Apply Skip Hello Verify Migration
Backported from https://gitlab.torproject.org/shelikhoo/snowflake/-/tree/dev-skiphelloverify-backup
2023-01-17 12:47:32 +00:00
Cecylia Bocovich
4895a32fd3
Bump version to v2.4.3 2023-01-16 11:55:31 -05:00
Cecylia Bocovich
086bbb4a63
Bump version to v2.4.2 2023-01-13 13:45:17 -05:00
Cecylia Bocovich
7db2568448
Remove duplicate stun.sonetel.net entry 2023-01-03 10:32:03 -05:00
Cecylia Bocovich
8c775562c1
Remove two suggested STUN servers from client docs
Removed stun.stunprotocol.org after a discussion with the operator, and
stun.altar.com.pl after noticing it has gone offline.

https://lists.torproject.org/pipermail/anti-censorship-team/2022-December/000272.html
https://lists.torproject.org/pipermail/anti-censorship-team/2022-December/000276.html
2022-12-31 12:23:29 -05:00
Cecylia Bocovich
f6fa51d749
Switch default proxy STUN server to stun.l.google.com
This is the same default that the web-based proxies use. Proxies do not
need RFC 5780 compatible STUN servers.
2022-12-31 12:23:27 -05:00
David Fifield
936a1f8138 Add a num-turbotunnel server transport option.
Replaces the hardcoded numKCPInstances.
2022-12-14 23:02:26 -07:00
David Fifield
c6fabb212d Use multiple parallel KCP state machines in the server.
To distribute CPU load.

https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40200
2022-12-14 23:02:26 -07:00
itchyonion
53e381e45d
Fix server flag name 2022-12-13 09:23:34 -08:00
Flo418
11c3333856 add some more test for URL encoded IPs (safelog) 2022-12-12 19:56:59 +01:00
David Fifield
839d221883 Take ownership of buffer in QueuePacketConn QueueIncoming/WriteTo.
This design is easier to misuse, because it allows the caller to modify
the contents of the slice after queueing it, but it avoids an extra
allocation + memmove per incoming packet.

Before:
	$ go test -bench='Benchmark(QueueIncoming|WriteTo)' -benchtime=2s -benchmem
	BenchmarkQueueIncoming-4         7001494               342.4 ns/op          1024 B/op          2 allocs/op
	BenchmarkWriteTo-4               3777459               627 ns/op            1024 B/op          2 allocs/op
After:
	$ go test -bench=BenchmarkWriteTo -benchtime 2s -benchmem
	BenchmarkQueueIncoming-4        13361600               170.1 ns/op           512 B/op          1 allocs/op
	BenchmarkWriteTo-4               6702324               373 ns/op             512 B/op          1 allocs/op

Despite the benchmark results, the change in QueueIncoming turns out not
to have an effect in practice. It appears that the compiler had already
been optimizing out the allocation and copy in QueueIncoming.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40187

The WriteTo change, on the other hand, in practice reduces the frequency
of garbage collection.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40199
2022-12-08 08:03:54 -07:00
David Fifield
d4749d2c1d Reduce turbotunnel queueSize from 2048 to 512.
This is to reduce heap usage.

https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40179

Past discussion of queueSize:
https://lists.torproject.org/pipermail/anti-censorship-team/2021-July/000188.html
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/48#note_2744619
2022-12-08 08:03:54 -07:00
David Fifield
77b186ae6e Have SnowflakeClientConn implement io.WriterTo.
By forwarding the method to the inner smux.Stream. This is to prevent
io.Copy in the top-level proxy function from allocating a buffer per
client.

The smux.Stream WriteTo method returns io.EOF on success, contrary to
the contract of io.Copy that says it should return nil. Ignore io.EOF in
the proxy loop to avoid a log message.

/anti-censorship/pluggable-transports/snowflake/-/issues/40177
2022-12-08 08:03:54 -07:00
David Fifield
64491466ce Manually unlock the mutex in ClientMap.SendQueue.
Rather than use defer. It is only a tiny amount faster, but this
function is frequently called.

Before:
	$ go test -bench=BenchmarkSendQueue -benchtime=2s
	BenchmarkSendQueue-4    15901834               151 ns/op
After:
	$ go test -bench=BenchmarkSendQueue -benchtime=2s
	BenchmarkSendQueue-4    15859948               147 ns/op

https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40177
2022-12-08 08:03:54 -07:00
David Fifield
8e5af50bdb Increase clientIDAddrMapCapacity to 98304.
Recent increases in usage have exhausted the capacity of the map.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40173
2022-12-03 13:39:56 -07:00
Flo418
cbc50592d8
update README.md help output, fix #40232 2022-12-02 13:37:17 -08:00
Flo418
cebe4a0af6
enhance help for capacity flag, fix #40208 2022-12-02 13:37:17 -08:00
Cecylia Bocovich
7c154e5fd0
Bump version to v2.4.1 2022-12-01 11:38:22 -05:00
Shelikhoo
788e3ae956
Refactor utls roundtripper_test to deduplicate 2022-11-29 15:41:49 +00:00
Shelikhoo
d8d3e538f1
Fix uTLS RoundTripper Inconsistent Key for host:port
This commit fixes an issue described at:
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40224

This bug has been fixed, with test case describing this bug added.
2022-11-29 15:41:49 +00:00
Cecylia Bocovich
56f15a5db7
Update ChangeLog for v2.4.0 2022-11-29 09:52:09 -05:00
Cecylia Bocovich
b547d449cb
Refactor timeout loop to use a context and reuse timers 2022-11-28 17:30:05 -05:00
Cecylia Bocovich
b010de5abb
Terminate timeoutLoop when conn is closed 2022-11-28 17:11:20 -05:00
Cecylia Bocovich
5c23fcf14a
Add timeout for webRTCConn 2022-11-28 17:11:18 -05:00
Cecylia Bocovich
6007d5e08e
Refactor creation of webRTCConn in proxy 2022-11-28 17:10:49 -05:00
luciole
90d1a56719
change regexes for ipv6 addresses to catch url-encoded addresses 2022-11-28 15:56:35 -05:00
Shelikhoo
4ebd85e5d1
add version output to log 2022-11-23 12:29:55 +00:00
Shelikhoo
33248f3dec
Add Version Output Support to Snowflake
From now on, there will be a file at common/version/version.go that includes current version number.
2022-11-23 12:29:51 +00:00
luciole
2c599f8827
change bandwidth type from int to int64 to prevent overflow 2022-11-21 10:33:21 -05:00
Cecylia Bocovich
115ba6a745
Add gofmt output to CI test before calling test -z
We use a call to test -z together with go fmt because it doesn't output
a non-zero exit status (triggering CI test failure). However, we lose
useful debugging output from the go fmt call because test -z swallows
it. This adds very verbose formatting output to the CI test.
2022-11-17 11:07:48 -05:00
David Fifield
e851861e68 Benchmark for encapsulation.ReadData. 2022-11-16 13:48:34 -07:00
David Fifield
a579c969e6 encapsulation.paddingBuffer can be statically allocated. 2022-11-16 13:48:34 -07:00
David Fifield
4ae63eccab Benchmark websocket.Conn Upgrade creation.
I had thought to set a buffer size of 2048, half the websocket package
default of 4096. But it turns out when you don't set a buffer size, the
websocket package reuses the HTTP server's read/write buffers, which
empirically already have a size of 2048.

	$ go test -bench=BenchmarkUpgradeBufferSize -benchmem -benchtime=5s
	BenchmarkUpgradeBufferSize/0-4                     25669            234566 ns/op           32604 B/op        113 allocs/op
	BenchmarkUpgradeBufferSize/128-4                   24739            238283 ns/op           24325 B/op        117 allocs/op
	BenchmarkUpgradeBufferSize/1024-4                  25352            238885 ns/op           28087 B/op        116 allocs/op
	BenchmarkUpgradeBufferSize/2048-4                  22660            234890 ns/op           32444 B/op        116 allocs/op
	BenchmarkUpgradeBufferSize/4096-4                  25668            232591 ns/op           41672 B/op        116 allocs/op
	BenchmarkUpgradeBufferSize/8192-4                  24908            240755 ns/op           59103 B/op        116 allocs/op
2022-11-16 13:48:34 -07:00
David Fifield
2321642f3c Hoist temporary buffers outside the loop.
Otherwise the buffers are re-allocated on every iteration, which is a
surprise to me. I thought the compiler would do this transformation
itself.

Now there is just one allocation per client←server read (one
messageReader) and two allocations per server←client read (one
messageReader and one messageWriter).

	$ go test -bench=BenchmarkReadWrite -benchmem -benchtime=5s
	BenchmarkReadWrite/c←s_150-4              481054             12849 ns/op          11.67 MB/s           8 B/op          1 allocs/op
	BenchmarkReadWrite/s←c_150-4              421809             14095 ns/op          10.64 MB/s          56 B/op          2 allocs/op
	BenchmarkReadWrite/c←s_3000-4             208564             28003 ns/op         107.13 MB/s          16 B/op          2 allocs/op
	BenchmarkReadWrite/s←c_3000-4             186320             30576 ns/op          98.12 MB/s         112 B/op          4 allocs/op
2022-11-16 13:48:34 -07:00
David Fifield
264425a488 Use io.CopyBuffer in websocketconn.readLoop.
This avoids io.Copy allocating a 32 KB buffer on every call.
https://cs.opensource.google/go/go/+/refs/tags/go1.19.1:src/io/io.go;l=416

	$ go test -bench=BenchmarkReadWrite -benchmem -benchtime=5s
	BenchmarkReadWrite/c←s_150-4              385740             15114 ns/op           9.92 MB/s        4104 B/op          3 allocs/op
	BenchmarkReadWrite/s←c_150-4              347070             16824 ns/op           8.92 MB/s        4152 B/op          4 allocs/op
	BenchmarkReadWrite/c←s_3000-4             190257             31581 ns/op          94.99 MB/s        8208 B/op          6 allocs/op
	BenchmarkReadWrite/s←c_3000-4             163233             34821 ns/op          86.16 MB/s        8304 B/op          8 allocs/op
2022-11-16 13:48:34 -07:00
David Fifield
3df514ae29 Call WriteMessage directly in websocketconn.Conn.Write.
In the client←server direction, this hits a fast path that avoids
allocating a messageWriter.
https://github.com/gorilla/websocket/blob/v1.5.0/conn.go#L760

Cuts the number of allocations in half in the client←server direction:

	$ go test -bench=BenchmarkReadWrite -benchmem -benchtime=5s
	BenchmarkReadWrite/c←s_150-4              597511             13358 ns/op          11.23 MB/s       33709 B/op          2 allocs/op
	BenchmarkReadWrite/s←c_150-4              474176             13756 ns/op          10.90 MB/s       34968 B/op          4 allocs/op
	BenchmarkReadWrite/c←s_3000-4             156488             36290 ns/op          82.67 MB/s       68673 B/op          5 allocs/op
	BenchmarkReadWrite/s←c_3000-4             190897             34719 ns/op          86.41 MB/s       69730 B/op          8 allocs/op
2022-11-16 13:48:34 -07:00
David Fifield
8cadcaee70 Benchmark for websocketconn.Conn read/write.
Current output:
	$ go test -bench=BenchmarkReadWrite -benchmem -benchtime=5s
	BenchmarkReadWrite/c←s_150-4              451840             13904 ns/op          10.79 MB/s       34954 B/op          4 allocs/op
	BenchmarkReadWrite/s←c_150-4              452560             16134 ns/op           9.30 MB/s       36378 B/op          4 allocs/op
	BenchmarkReadWrite/c←s_3000-4             202950             40846 ns/op          73.45 MB/s       69833 B/op          8 allocs/op
	BenchmarkReadWrite/s←c_3000-4             189262             37930 ns/op          79.09 MB/s       69768 B/op          8 allocs/op
2022-11-16 13:48:34 -07:00
David Fifield
0780f2e809
Add a orport-srcaddr server transport option.
The option controls what source address to use when dialing the
(Ext)ORPort. Using a source address other than 127.0.0.1, or a range of
addresses, can help with localhost ephemeral port exhaustion.

https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40198
2022-11-16 19:41:42 +01:00
itchyonion
9d72b30603
proxy: Let verbose level act on file logging 2022-11-16 10:08:11 -08:00
itchyonion
768b80dbdf
Use event logger for proxy starting message and NAT info 2022-11-16 10:08:10 -08:00
David Fifield
2f55581098
Reduce the smux KeepAliveTimeout on the server from 10 to 4 minutes.
To save memory, we want to more aggressively close stale connections.

https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40175
2022-11-16 18:48:14 +01:00
David Fifield
12e8de8b24 Update github.com/gorilla/websocket to v1.5.0. 2022-11-15 17:21:33 -07:00
luciole
3185487aea update formatTraffic so that bandwidth unit is always KB 2022-11-10 15:12:46 +01:00
meskio
ac8562803a
Merge remote-tracking branch 'gitlab/mr/107' 2022-10-17 12:36:19 +02:00
David Fifield
39df9b36b5 Fix uTLS issue number in ChangeLog.
The right issue number is #40054.
The #40095 it referred to was for load balancing on the broker.
2022-10-16 23:14:38 -06:00