onion-tunnel/proxy: fix broken InteractiveCopier
- The
InteractiveCopier
was subtly broken; if the destination partially wrote something, it would duplicate data (in pathological cases, looping forever).- Thanks to @trinity-1686a for catching the bug!
- This unsurprisingly resulted in garbled TCP connections that subtly broke everything.
- Fix this oversight, and introduce a test that catches this kind of failure case.
- The
BoundedWriter
test harness forces partial writes. - It also panics if the copier tries to write too much, as without this feature the (broken) copier would just loop indefinitely.
- The
- A future commit should refactor the copier, which was written by eta in a fit of
Brussels-induced overconfidence (see also f173e44c,
"oops yolo"), to be a bit less prone to this sort of error.
- trinity suggested factoring out the buffer logic, which I will go and do next!