Commit graph

138 commits

Author SHA1 Message Date
Michael Pu
b512e242e8 Implement better client IP per rendezvous method tracking for clients
Implement better client IP per rendezvous method tracking for clients

Add tests for added code, fix existing tests

chore(deps): update module github.com/miekg/dns to v1.1.58

Implement better client IP tracking for http and ampcache

Add tests for added code, fix existing tests

Implement GetCandidateAddrs from SDP

Add getting client IP for SQS

Bug fixes

Bug fix for tests
2024-03-09 13:36:25 -05:00
Cecylia Bocovich
b130151b24
Bump version to v2.9.1 2024-02-27 11:32:09 -05:00
am3o
acce1f1fd9
refactor: change deprecated "io/ioutil" package to recommended "io" package 2024-02-17 12:47:22 +01:00
Cecylia Bocovich
38352b22ad
Bump version to v2.9.0 2024-02-05 12:00:05 -05:00
Anthony Chang
dbecefa7d2
Move RendezvousMethod field to messages.Arg 2024-01-31 14:34:29 -05:00
Anthony Chang
f3b062ddb2
Add mocks and interfaces for testing SQS rendezvous
Co-authored-by: Michael Pu <michael.pu@uwaterloo.ca>
2024-01-22 13:10:56 -05:00
Arlo Breault
e4c818be76
Scrub space separated ip addresses
The issue with ReplaceAllFunc is that it's capturing the leading and
trailing spaces in the regexp, so successive ips don't match.  From the
docstring,

> If 'All' is present, the routine matches successive non-overlapping
> matches of the entire expression.

For #40306
2024-01-08 10:03:35 -05:00
Arlo Breault
0d8261c46e Add vcs revision to version string
For #40285
2024-01-04 00:31:08 -05:00
Cecylia Bocovich
a0e3e871c4
Bump version to v2.8.1 2023-12-21 15:54:54 -05:00
David Fifield
aa06e7bef3 Merge branch 'encapsulation-readdata-buffer' 2023-11-21 03:46:46 +00:00
Cecylia Bocovich
a88f73b0ff
Bump version to 2.8.0 2023-11-20 11:43:07 -05:00
David Fifield
d99f31d881 Have encapsulation.ReadData return an error when the buffer is short.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/154#note_2919109

Still ignoring the io.ErrShortBuffer at the callers, which retains
current behavior.
2023-11-07 05:51:35 +00:00
David Fifield
001f691b47 Have encapsulation.ReadData read into a provided buffer.
Instead of unconditionally allocating its own.
2023-11-07 05:51:35 +00:00
Cecylia Bocovich
caa2b36463
Process and properly log connection closure stats 2023-10-31 10:02:31 -04:00
Cecylia Bocovich
5c5eb2c339
Modify EventOnProxyStats to include summary data 2023-10-30 12:42:45 -04:00
Cecylia Bocovich
354cb65432
Move creation of periodic stats task inside proxy library
This adds a new type of SnowflakeEvent. EventOnProxyStats is triggered
by the periodic task run at SummaryInterval and produces an event with a
proxy stats output string.
2023-10-30 12:42:45 -04:00
Shelikhoo
5df7a06eee
Add outbound proxy configuration propagation 2023-10-24 17:47:25 +01:00
Shelikhoo
f43da1d2d2
Add transport wrapper 2023-10-24 17:43:32 +01:00
Shelikhoo
8b46e60553
Add common proxy utilities 2023-10-24 17:42:46 +01:00
Shelikhoo
bd7391d678
update version to 2.7.0 2023-10-16 15:14:51 +01:00
David Fifield
6393af6bab
Remove proxy churn measurements from broker.
We've done the analysis we planned to do on these measurements.

A program to analyze the proxy churn and extract hour-by-hour
intersections is available at:
https://github.com/turfed/snowflake-paper/tree/main/figures/proxy-churn

Closes #40280.
2023-10-09 16:16:05 +01:00
Cecylia Bocovich
3a050c6bb3
Use ShouldBeNil to check for nil values 2023-09-20 12:34:51 -04:00
Shelikhoo
b5d702f483
update version to v2.6.1 2023-09-11 14:30:00 +01:00
David Fifield
58c3121c6b Close temporary UDPSession in TestQueuePacketConnWriteToKCP.
With these not being closed, they were continuing to consume resources
after the return of the test function, which was affecting the later
BenchmarkSendQueue.

Before:
```
snowflake/common/turbotunnel$ go test -bench BenchmarkSendQueue -v
=== RUN   TestQueueIncomingOversize
--- PASS: TestQueueIncomingOversize (0.00s)
=== RUN   TestWriteToOversize
--- PASS: TestWriteToOversize (0.00s)
=== RUN   TestRestoreMTU
--- PASS: TestRestoreMTU (0.00s)
=== RUN   TestRestoreCap
--- PASS: TestRestoreCap (0.00s)
=== RUN   TestQueuePacketConnWriteToKCP
--- PASS: TestQueuePacketConnWriteToKCP (1.01s)
goos: linux
goarch: amd64
pkg: gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel
cpu: Intel(R) Core(TM) i5 CPU         680  @ 3.60GHz
BenchmarkSendQueue
BenchmarkSendQueue-4     8519708               136.0 ns/op
PASS
ok      gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel  3.481s
```

After:
```
snowflake/common/turbotunnel$ go test -bench BenchmarkSendQueue -v
=== RUN   TestQueueIncomingOversize
--- PASS: TestQueueIncomingOversize (0.00s)
=== RUN   TestWriteToOversize
--- PASS: TestWriteToOversize (0.00s)
=== RUN   TestRestoreMTU
--- PASS: TestRestoreMTU (0.00s)
=== RUN   TestRestoreCap
--- PASS: TestRestoreCap (0.00s)
=== RUN   TestQueuePacketConnWriteToKCP
--- PASS: TestQueuePacketConnWriteToKCP (1.02s)
goos: linux
goarch: amd64
pkg: gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel
cpu: Intel(R) Core(TM) i5 CPU         680  @ 3.60GHz
BenchmarkSendQueue
BenchmarkSendQueue-4    11620237               105.7 ns/op
PASS
ok      gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/turbotunnel  3.244s
```
2023-06-29 21:12:29 +00:00
David Fifield
80980a3afb Fix a comment left over from turbotunnel-quic. 2023-06-29 19:59:50 +00:00
Cecylia Bocovich
2fa8fd9188
Update version to v2.6.0 2023-06-19 12:52:25 -04:00
Cecylia Bocovich
f8eb86f24d
Append Let's Encrypt ISRG Root X1 to cert pool
This is a workaround for older versions of android that do not trust
the Let's Encrypt root certificate.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40087
2023-06-14 18:12:29 -04:00
meskio
82cc0f38f7
Move the development to gitlab
Related: tpo/anti-censorship/team#86
2023-05-31 10:01:47 +02:00
David Fifield
8e5ea82611 Add a scanner error check to ClusterCounter.Count.
It was silently exiting at the "recordingStart":"2022-09-23T17:06:59.680537075Z"
line, the first line whose length (66873) exceeds
bufio.MaxScanTokenSize. Now distinctcounter exits with an error status
instead of reporting partial results.

$ ./distinctcounter -from 2023-01-01T00:00:00Z -to 2023-01-10T00:00:00Z -in metrics-ip-salted.jsonl
2023/04/20 13:54:11 unable to count:bufio.Scanner: token too long
2023-04-20 11:28:58 -04:00
David Fifield
c097d5f3bc Use a sync.Pool to reuse packet buffers in QueuePacketConn.
This is meant to reduce overall allocations. See past discussion at
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40260#note_2885524 ff.
2023-04-04 20:22:32 -06:00
David Fifield
97c930013b Fix loop termination in TestQueuePacketConnWriteToKCP.
The noise-generating goroutine was meant to stop when the parent
function returned and closed the `done` channel. The `break` in the loop
was wrongly exiting only from the `select`, not from the `for`.

This was the cause of banchmark anomalies in
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40260#note_2885832.
The noise-generating loop from the test was continuing to run while the
benchmarks were running.
2023-04-04 19:12:22 -06:00
David Fifield
6bae31f077 Use a static array in benchmarks.
Since d2858aeb7e the caller is permitted
to reuse its slice again.
2023-04-04 18:56:55 -06:00
David Fifield
590d158df8 Comment typo. 2023-04-04 18:46:35 -06:00
David Fifield
36d5d2dd83 Fix comment typo on NewRedialPacketConn. 2023-03-13 15:10:35 -06:00
David Fifield
d2858aeb7e Revert "Take ownership of buffer in QueuePacketConn QueueIncoming/WriteTo."
This reverts commit 839d221883. (Except for
the added benchmarks in queuepacketconn_test.go.) This change
corresponds to the issues #40187 and #40199.

The analysis in https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40199
was wrong; kcp-go does reuse the buffers it passes to
QueuePacketConn.WriteTo. This led to unsynchronized reuse of packet
buffers and mangled packets observable at the client:
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40260.

Undoing the change in QueuePacketConn.QueueIncoming as well, for
symmetry, even though it is not implicated in any correctness problems.
2023-03-13 12:57:35 -06:00
David Fifield
b63d2272bf Test for data race with QueuePacketConn.WriteTo and kcp-go.
For #40260.
2023-03-13 11:42:44 -06:00
Shelikhoo
7b77001eaa
Update version to v2.5.1 2023-01-18 14:37:05 +00:00
Shelikhoo
daa9b535c8
Update Version to v2.5.0 2023-01-18 11:27:31 +00:00
Cecylia Bocovich
4895a32fd3
Bump version to v2.4.3 2023-01-16 11:55:31 -05: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
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
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
luciole
90d1a56719
change regexes for ipv6 addresses to catch url-encoded addresses 2022-11-28 15:56:35 -05: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
David Fifield
e851861e68 Benchmark for encapsulation.ReadData. 2022-11-16 13:48:34 -07:00