ARP Injection in Rust on Linux

Don’t ask why, but I had to learn about this a while ago and had been meaning to write it down. ARP is Address Resolution Protocol, it is a layer 2 protocol used in local IPv4 networks for discovering a MAC address for a given IP. Say you want to send a packet to an IP on your local network, 192.168.0.136. The ethernet frame requires a destination MAC address, but you don’t know what it is yet. [Read More]

Rust superpowered DHCP cli with rhai scripts

I’ve been working on cli tool for a little while called dhcpm (“m” for “mock” - link). It started as a cli tool for constructing & sending arbitrary DHCP messages. I had been looking for a tool that could build various dhcp (mostly v4) messages with different parameters easily, then simply print the responses back so I could inspect its contents. I discovered that you can use nmap scripts for this, and there are a 2 pre-written dhcp scripts in a typical nmap install. [Read More]

Introducing: DHCProto

DHCProto is available now on crates.io. DHCProto implements a parser/encoder for DHCPv4 & DHCPv6. This crate was born out of a lack of DHCP offerings currently available in Rust. It has a comprehensive list of option types implemented, and a fallback variant for options not yet implemented. This library was written at my work (Bluecat), and they have graciously let us open source it, available on github for issues/comments/PRs. The encoder/decoder traits are inspired a lot by trust-dns-proto. [Read More]

nailgun: DNS benchmarking tool

nailgun is a small hobby project I’ve been working on sparsely for a few months, it’s a cli DNS benchmarking tool heavily inspired by flamethrower but written in Rust with tokio. I’ve been working at the intersection of DNS & Rust for a little while and this is something I’ve been pushing along in my free time. Rest assured, it has no real reason for existing just yet other than I felt like writing it so if you’re looking for a quality DNS performance testing client then you should probably still use flamethrower. [Read More]

A look at tokio 1.0 API Changes

I’ve been working in the Rust space for about a year now using tokio & async/await with DNS. The result of this work is a sizeable from-scratch tokio server using 0.2 (that’s now in production– yay! hopefully I can share more about this later). As a result, I’ve gotten to know the UDP API of tokio quite well, and have even got to submit a few PRs (double yay). I’d like to highlight some interesting changes that have happened in tokio’s API between 0. [Read More]

Cheating Higher Ranks with Traits

I ran into this a little while ago and thought it would be helpful to share a possible solution. Imagine you have an enum that describes a set of possible branches, for each branch there is a type associated with it that you want to run through a function, for this example– serialize. enum Var{One,Two,}#[derive(Serialize)]struct Foo;#[derive(Serialize)]struct Bar;fn write<W>(var: Var,mutwriter: W)-> serde_json::Result<()>whereW: Write,{matchvar{Var::One=>serde_json::to_writer(&mutwriter,&Foo),Var::Two=>serde_json::to_writer(&mutwriter,&Bar),}} Life is good. Then you realize that you actually needed to format these types in two different ways, one with to_writer and the other with to_writer_pretty. [Read More]

Rust for Java Devs

I’d like to take a change for this blog and leave the more bleeding edge topics to focus on perhaps one of the most important things one can do in the Rust community: teaching new Rust developers. I’ve been thinking about how best to approach teaching Rust to those used to working with Java, in order to bring a group of developers up to speed with the language for a new project. [Read More]

Rotary Encoders in Embedded Rust

Recently, I’ve been trying to learn more about electronics and embedded development. Maybe I’m just tired of operating purely in the virtual, but there’s something cool about being able to physically put together a circuit and push a button to make something happen. I went through the usual Arduino resources before seeing what Rust had to offer. I’m happy to report there’s some really good material out there. Discovery book Rust Embedded book Real Time For the Masses If you’re new to embedded (but not new to Rust), I’d recommend the Discovery book as your jumping off point. [Read More]

Updating to Async/Await

Unless you’ve been living under a rock; you know async/await is coming to rust stable. My last post was about implementing a simple protocol using manual futures, and interacting with tokio. It’s only fitting, then, that I update the lib that post was inspired by to async/await and report back on my findings. If you’re curious about my library or you use the window manager i3, it’s available here or on crates under tokio-i3ipc. [Read More]

Protocols in Tokio (i3 IPC)

There’s a dearth of blog posts online that cover the details of implementing a custom protocol in tokio, at least that I’ve found. I’m going to cover some of the steps I went through in implementing an async version i3wm’s IPC. Granted, I’ve not finished my library to a point I’m comfortable releasing it, but I hope I can provide some examples for the aspiring async IO enthusiast that I wish I had when I started. [Read More]