Commit Graph

10 Commits

Author SHA1 Message Date
Wez Furlong e3fdcaa628 cargo clippy --fix 2025-04-09 10:26:07 -07:00
Wez Furlong 3975afc446 proxy_handler: rustfmt
I'm not in-love with how it renders this all on one line,
but it prevents the "broken" fmt from being noisy and in the way.
2024-09-16 18:20:03 -07:00
Dirkjan Ochtman cb3fd8a5d4 proxy-server: enable compilation on non-Linux platforms
tokio-splice does not compile on macOS due to missing libc calls.
2024-09-16 06:32:33 -07:00
Wez Furlong b5596183be proxy-server: simplify passthru implementation
We've been trying to run down an issue where a user has reported that
some sessions that are running via the proxy seem to hang waiting for a
response from the peer.  The common theme is that the size of the
payload is approximately 1MB in size, and that the proxy is in use.

I haven't been able to get it to reproduce at all, but in looking
carefully at the code here, my splice(2) implementation used a pipe
buffer that was 1MB in size, and doing non-blocking IO outside of
tokio's internals is a bit of a black art, so I'd buy the theory
that we might be getting stuck somewhere if we did fill up that
pipe buffer.

Since I couldn't catch it in the act, I've opted to go for the simple
and safer route here, as a speculative remediation:

* Added a `--no-splice` command line parameter to opt out of using
  `splice(2)` completely on Linux so that we can rule out weirdness
  with splice completely. The result will have lower theoretical
  max throughput, but a simpler internal implementation.
* There now exists a `tokio-splice` crate that has the same
  functionality as my own splice_copy code does, but a different
  implementation. Adopt that for the `splice(2)` mode.
* Switch away from splitting the stream into read/write halves: there
  are now utility functions available in tokio and tokio_splice that
  don't require splitting the streams, which further simplifies
  the implementation.
2024-07-30 16:32:39 -07:00
Wez Furlong 8f87f66ea6 proxy: refine error reporting a little bit more 2024-07-15 16:04:59 -07:00
Wez Furlong b13ab592e5 kumoproxy: improve diagnostics around connectivity issues
Previously we were very tight-lipped. We now will log some
context to the journal for the proxy service for issues that
we couldn't propagate back to the client.
2024-07-15 11:55:00 -07:00
Wez Furlong a8b61ce59e proxy-server: fix missing bind(2) call
Somewhat embarrasing really
2024-03-14 17:51:58 -07:00
Wez Furlong 37e3401584 proxy: now compiles on macos 2023-10-09 10:04:24 -07:00
Wez Furlong acef2ecab9 Add timeouts to socks server handshake/connection initiation
Let's avoid things hanging forever while setting up a connection.

refs: https://github.com/KumoCorp/kumomta/issues/45
2023-05-15 17:55:28 -07:00
Wez Furlong beb120fda5 Add a SOCKS5 proxy server implementation
This is a pretty tight, lightweight implementation of SOCKS5
intended to be used to facilitate an MTA asking it to bind and
connect.

It uses the splice(2) syscall to avoid kernel/userspace copies
when passing data through, so it should be quite efficient.

refs: https://github.com/KumoCorp/kumomta/issues/45
2023-05-15 17:38:17 -07:00