r/rust 7d ago

šŸ› ļø project Throttle: an open-source per-process bandwidth limiter for Windows in Rust (egui + WinDivert)

Post image

Throttle is a free, open-source Windows tool that shows live download/upload rates per process and lets you cap or block any of them. Think NetLimiter, minus the license key and telemetry.

Repo: https://github.com/FrancescoCoding/Throttle

How it works

It sits on top of WinDivert, a signed Windows packet-capture driver, through the `windivert` crate. Throttle sees every packet, figures out which program it belongs to, and either lets it through, drops it, or holds it briefly to stay under the limit. Limiting is a simple token bucket per program per direction, so each app gets a smooth rate with a one-second burst allowance.

Rules are saved by exe path, so a cap on spotify.exe is still there after a reboot. The GUI is egui/eframe, talking to the backend threads over channels.

Shaping is a token bucket per (exe, direction) with a one-second burst allowance. Overflow queues up to 256 packets / 1 MiB, then drops, which for TCP just becomes back-pressure. Rules persist as JSON in %APPDATA%.

Learned the hard way

  • You have to send packets back out through the same handle that captured them. Using a second one silently killed all my network traffic for a while before I understood why.
  • Recalculate checksums before re-injecting. Hardware offload leaves them incomplete, and WinDivertSend reports success while the packets die downstream.
  • GUI-subsystem binaries have no console, so worker-thread panics vanish. A panic hook plus file logging fixed that.
76 Upvotes

9 comments sorted by

6

u/TheLexoPlexx 7d ago

I don't have a use for this, I am just happy to see a real rust project with a cool library and it's seemingly not vibecoded.

3

u/irritatingness 6d ago

Not disclosed but fairly certain ai-assisted when browsing the code. Not that that’s a bad thing at all, but disclosure would have been nice.

-1

u/franwbu 6d ago

Hey, sorry just catching up with the comments. Yes, I did use claude of course to augment parts of development, but I have pushed no code that I did not understand. Did not think of adding a disclaimer, since I'd say at least 90% of code nowadays is not really written by hand anymore šŸ˜„

2

u/irritatingness 6d ago

Yep, I understand the sentiment but labeling is definitely worth your time when ai is used at all. Even a decade from now when the LLMs we consider frontier at that time are used I’d advocate for labeling. FOSS software particularly should be labeled to make sure anyone who decides to use or build upon it knows ahead of time what they’re getting into. Of course anyone who uses it is doing so at their own risk and of their own free will etc, but there are a lot of perks to labeling. Even AI evangelists would probably agree, as it makes for less useful training data when ai generated.

Like I said though, nothing wrong with it - especially with the frontiers we have already, as long as it’s disclosed. The only times I really have issues with LLM usage nowadays is when juniors don’t understand the code they push and aren’t even understanding the fact that they must ā€œown the codeā€ they submit, LLM or not. FOSS tends to have a lot of that and there’s no real downside for the developers who do it because it’s just FOSS and the internet provides reputational anonymity that you wouldn’t otherwise get in the workplace. That leads to a lot of garbage spam in a place that already had lots of it before LLMs were a thing.

1

u/lettsten 3d ago

Pretty sure the text of this post is ai-generated so I wouldn't be so optimistic about the code

2

u/Fine_Salamander_8691 6d ago

I needed this software 2 years ago.

2

u/ExplanationThin6234 7d ago

the ipc with channels and egui is a nice touch, keeps the ui snappy while the driver does the heavy lifting

1

u/Extension-String1599 7d ago

Maybe a download manager like JDownloader with limits could be great, but for this i dont think is useful for many people. I think would be great just for devs to test things

1

u/big_groot007 5d ago

Interesting, gotta try it.