Packet Capturing MySQL with Rust
agildata.com
agildata.com
To be clear, it's not just slower, it's much slower. See the benchmark comparison here: https://gist.github.com/b0f6a17744dd1df60752b6e8ced47afd <-- That's why the `regex!` macro isn't even in the docs any more.
It looks like `regex!` is the only thing preventing your project from compiling on stable Rust, right? FWIW, the Clippy lint tool will check your `Regex::new` calls at compile time for you (assuming it's a string literal, which it is in your case).
Also, I'd recommend not using `*` as a version constraint in your `Cargo.toml`. You do have a `Cargo.lock` so it's not as bad, but with better version constraints, you'll be able to run `cargo update` and get semver compatible updates.
Regarding the asterisk for versioning in Cargo.toml, I also agree. When quickly putting things together, I usually start with it just to see if the default version pulled works. The great utility of Cargo.lock, effectively storing the working versions of all the crates, allows scraping the versions out of there at any time, and putting them into the .toml.
I hope you noticed the extensive links in the post, as one of the goals was to bring more people into the Rust ecosystem. The Spyglass utility does work quite well. None of us claimed it has reached a state of absolute perfection, so your comments are appreciated (and pull requests will be as well)!
Thank you.
Another approach is to re-implement everything that has gone into Regex::new, but in a way that works at compile time.
Another approach is to operate more like Ragel and try to get better performance, but this will need to be compensated somehow to provide the full suite of the regex API.
(1) isn't that interesting since lazy_static! and Clippy already serve that role. That latter two approaches require a lot of work that will only be available on nightly for the foreseeable future. (And it's not even clear to me how much faster (3) could even be.)
Am I missing some subtlety that makes it safe?
My comments regarding the regex was the very high number of cases that are correctly handled, with such a small amount of code.
Thank you for your comments. I appreciate it.
https://www.vividcortex.com/resources/network-analyzer-for-m...
However, libpnet doesn't have two very useful things, as far as I can see: Reading/writing packet capture files, and the ability to use BPF filters. The first in this case might be useful mainly for testing, but the latter seems like it might simplify a fair amount of their code.
And adding the functionality for a pcap like fileformat doesn't seem that difficult.
The filters are a major pain point, I don't know how libpcap handles this, but at least it says it won't copy packets from kernel- to userspace that are not matching. Thus avoiding alot of overhead, maybe it's possible to introduce some rusty kind of filtering in libpnet, too.
Going to log into Github now and see if I can do something.
EDIT: fixed spelling
Here's a quick example demonstrating socket & recv capturing all packets on all interfaces.
https://gist.github.com/fkautz/0104084fd79cee5608d8e3fc6e729...
As for reading and writing pcap files, I just use the pcap crate and use a common buffer. It's a little clumsy but it does work.
Wouldn't it be better to use some kind of privilege separation? I think there is a reason WireShark does this... And even saying Rust is a safe Language won't save you from programming errors, it just makes them more diffcult.
And, you're correct it won't save you from all programming errors. It does, however, make it far more difficult to accidentally encounter whole classes of them which constitute, on average, quite a high percentage of debug time in other systems languages.
[0] https://www.percona.com/blog/2009/02/10/impact-of-logging-on...
Oh, and nothing is wrong about posts by new accounts making the front page. We welcome new users!