Coder Social home page Coder Social logo

Comments (4)

niklata avatar niklata commented on August 18, 2024

This is easy to implement and has very little cost either in cpu or space, so I don't mind adding it. Likely I will go with the signal to pre-specified file approach as that would avoid the parsing required for the command port.

from muonsocks.

niklata avatar niklata commented on August 18, 2024

Thinking about it more, I think the approach I would choose is to require logging to be enabled, then at connection termination, print the number of bytes (octets) sent and received to that client IP. Then whatever accounting could be done via an awk script or similar that aggregates transfer counts per ip over a desired date-time range.

Keeping a table of client IPs to sent/receive counters in memory in muonsocks has the risk of allowing a malicious client to greatly bloat the memory size of a muonsocks process, although it wouldn't be an arbitrary OOM DoS.

from muonsocks.

niklata avatar niklata commented on August 18, 2024

Well, it would be a fixed 1MB for a 16-bit unsigned to 2x 64-bit unsigned counter table [edit: which would still require a hash construction to map 32-bit IPs to 16-bit slots, and probably some expiry mechanism based on bytes exchanged], but it would require each worker thread to take a lock to update that table for each transfer or disconnection, depending on the logging precision (stats in realtime for the former, stats only at disconnect for the latter). So I still prefer the log-based approach, which has no memory cost, and the same or less locking overhead. The stats would of course only be emitted at socket disconnection, but that's likely what I would choose in either case.

from muonsocks.

niklata avatar niklata commented on August 18, 2024

I've implemented the disconnection log messages with bytes sent and received in commit 036c094.

from muonsocks.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.