Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[In-progress PoC] dumping connection logs #10279

Draft
wants to merge 2 commits into
base: v2.10
Choose a base branch
from

Conversation

mzealey
Copy link

@mzealey mzealey commented Dec 4, 2023

I'd appreciate a review of this code to let me know if I'm on a track that you'd be happy to eventually upstream... I have tried to implement as separate wrapper functions so that they can be toggled based on whether this config parameter exists or not with no change to other code.

Unfortunately, the only way I could make it so that the TLS and TCP connections dumped in the same place was to change the signature of ServeTCP to include a context object similar to HTTP's req.Context() as I did not want to extend tcp.WriterCloser to include context. I feel like there should be a better way to do this, but I'm not a golang expert.

What does this PR do?

Creates a 'connectionlog' similar to 'accesslog' but on a per-TCP connection level (later can be extended UDP/QUIC)

Motivation

We wish to account for bandwidth more accurately than just the http payload. In order to do this we currently account:

  • plain data (ie post-TLS decryption)
  • raw data (ie pre-TLS decryption)
  • TCP overhead and other stats via the kernel where possible.

Currently it's just dumping JSON to the standard log, however we will extend it by copying a fair bit of the accesslog code to make it relatively compatible with this.

The idea is that with appropriate connection open/close timestamps and source ip/port this could then be correlated with the accesslog to create a fuller view of the connection.

More

  • Added/updated tests
  • Added/updated documentation

Additional Notes

Still to do:
- [ ] Create a nice formatter like accesslog
- [ ] Figure out a nicer way to dump TLS and TCP both together at the
  end of the connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants