Reading List
The most recent articles from a list of feeds I subscribe to.
Introducing "Implement DNS in a Weekend"
Hello! I’m excited to announce a project I’ve been working on for a long time: a free guide to implementing your own DNS resolver in a weekend.
The whole thing is about 200 lines of Python, including implementing all of the binary DNS parsing from scratch. Here’s the link:
This project is a fun way to learn:
- How to parse a binary network protocol like DNS
- How DNS works behind the scenes (what’s actually happening when you make a DNS query?)
The testers have reported that it takes around 2-4 hours to do in Python.
what’s a DNS resolver?
A DNS resolver is a program that knows how to figure out what the IP address for a domain is. Here’s what the command line interface of the resolver you’ll write looks like:
$ python3 resolve.py example.com
93.184.216.34
implementing DNS gives me an amazing sense of confidence
In Learning DNS in 10 years, I talked about how having implemented a toy version of DNS myself from scratch gives me an unparalleled sense of confidence in my understanding of DNS.
So this guide is my attempt to share that sense of confidence with you all.
Also, if you’ve bought How DNS Works, I think this guide is a nice companion – you can implement your own DNS resolver to solidify your understanding of the concepts in the zine.
it’s a Jupyter notebook
In this guide, I wanted to mix code that you could run with explanations. I struggled to figure out the right format for months, and then I finally thought of using a Jupyter notebook! This meant that I could easily check that all of the code actually ran.
I used Jupyter Book to convert the Jupyter notebooks into a website. It reruns the notebook before converting it to HTML, so I could easily guarantee that all of the code actually runs and outputs what it says that it outputs. I ended up hacking the theme a lot to make it more minimal, as well as doing some terrible things with Beautiful Soup to get a table of contents that shows you the global TOC as well as the page’s local section headings all in one place.
You can also download the Jupyter notebooks and run them on your own computer if you’d like, using the “download the code” button on the homepage.
why Python?
I used Python for this guide instead of a lower-level language like Go or Rust to make it more approachable – when I started learning networking 10 years ago, I didn’t really know any systems languages well, and I found them kind of intimidating. Implementing traceroute using scapy in Python felt much less scary.
You can very easily pack/unpack binary data in Python with struct.pack and
struct.unpack, so Python being a higher-level language doesn’t really cause
any problems.
The idea is that you can either follow the guide in Python (which is the easiest mode), or if you want a bigger challenge, you can translate the code to any language you’d like. (Go? Javascript? Rust? Bash? Lua? Ruby?)
only the standard library
It was important to me to really show how to implement DNS “from scratch”, so
the guide only uses a few very basic standard library modules: struct,
socket, io, random, and dataclasses.
Here’s what we use each module for:
randomis used for generating DNS query IDssocketis used to make a UDP connectionstructis used for converting to/from binary (struct.packandstruct.unpack)dataclassesare used to make serializing / deserializing records a little more ergonomiciois used forBytesIO, which gives us a reader interface which stores a pointer to how much of the packet we’ve read so far. If I were implementing DNS in a language that didn’t have this kind of reader interface, I might implement my own.
it includes some bonus exercises
The toy DNS resolver is obviously missing a bunch of important features, so I’ve added some exercises at the end with examples of features you could add (and bugs you could fix) to make it a little more like a “real” DNS resolver.
This list isn’t particularly exhaustive though, and I’d love to hear other ideas for relatively-easy-to-implement DNS resolver features I’ve missed.
next goal: TLS
I’ve actually written toy implementations of a bunch of other network protocols in Python (ICMP, UDP, TCP, HTTP, and TLS), and I’m hoping to release “Implement TLS in a weekend” at some point.
No promises though – I have another zine to finish writing first (on all the surprising things about how integers and floats work on computers), and a toy TLS implementation is quite a bit more involved than a toy DNS implementation.
thanks to the beta testers
Thanks to everyone (Atticus, Miccah, Enric, Ben, Ben, Maryanne, Adam, Jordan, and anyone else I missed) who tested this guide and reported confusing or missing explanations, mistakes, and typos.
Also a huge thanks to my friend Allison Kaptur who designed the first “Domain Name Saturday” workshop with me at the Recurse Center in 2020.
The name was inspired by Ray Tracing in One Weekend.
here’s the link again
Here’s the link to the guide again if you’d like to try it out:
Resetting mastodon user password on YunoHost
Developer Tools That Shouldn’t Be Secrets • Christian Heilmann • GOTO 2022
Questions to ask a potential 3PL vendor
Over the past six months, I’ve been transitioning the fulfillment processes at my e-commerce business to a third-party logistics (3PL) vendor.
I didn’t know anything about 3PLs before starting this process, so there were a lot of things I didn’t know to ask about. Here are the list of questions that I recommend e-commerce merchants ask a 3PL if they’re considering working with them for fulfillment.
Customer profile
- Do you have other clients whose order volumes are similar to mine?
- What’s the minimum and maximum order volume you can support?
- Do you have other clients whose products are similar to mine in price?
- Do you have other clients whose products are similar to mine in weight and volume?
Integration with e-commerce platforms
- What’s the process of connecting to my e-commerce platform?
- Do I install an app?
- Do I have to make you admin in my Shopify store?
- How quickly does your order management system sync with my e-commerce platform?
- i.e., when you print a shipping label, how quickly do I see that reflected in Shopify?
- How do I present your shipping rates to my customers?
- Can I present real-time shipping rates from your couriers or do we need to use flat shipping fees?
Recordkeeping / auditing
- How often do you do stocktakes?
- Do I have access to your inventory tracking system?
- If not, how frequently do you share reports of inventory counts and changes?
- How will you share records of inventory changes with me?
- i.e., When did products arrive at your warehouse? When did they go out for customer orders? When did stocktakes happen?
Schedule
- Which days of the week do you fulfill orders?
- What holidays do you observe?
- What’s the typical turnaround time for fulfilling an order?
Shipping
- Do you pass through postage costs directly from couriers or do you add a surcharge?
- Which shipping couriers and services do you support for domestic orders?
- Which shipping couriers and services do you support for international orders?
- Can you ship international orders delivered duty paid (DDP)?
- What’s the cutoff time for same-day shipping?
Payment
- What are your fees?
- How do you accept payment?
- Do you charge a surcharge for different payment options (e.g., surcharge for credit cards)?
Handling issues and unusual orders
- What’s your error rate?
- i.e., how often do customers receive the wrong item or wrong quantities?
- Who absorbs costs of a fulfillment error?
- What if we have to re-ship with expedited shipping to meet a customer deadline?
- What if you sent a more expensive item and the customer has already opened it or refuses to return it?
- Who absorbs costs for lost inventory at the warehouse?
- e.g., warehouse confirms receipt of 100 items, ships 75 over the course of the next month, but the next stocktake shows only 23 remaining (100 - 75 - 23 = 2 are missing)
- How do we handle it if a customer places an order and then emails me to make a change?
- Will changes in my e-commerce platform immediately sync to your order management system?
- How do we handle it when a customer asks us to hold off on fulfilling an order?
- What’s the process of pausing fulfillment on an order?
- Will your order management system recognize Shopify’s “pause fulfillment” feature?
Location
- Where are your warehouses located?
- Note: Depending on your tax situation, fulfilling your orders from a warehouse in a state outside of your headquarters means you’re responsible for collecting and paying sales tax in the warehouse’s state. Keep this in mind, as filing taxes in a new state is a significant administrative burden.
Insurance
- Does your insurance cover the value of our property?
- If not:
- What year was the warehouse built?
- How many stories does the warehouse have?
- Does the warehouse have wood frame construction?
- Does the warehouse have a sprinkler system?
TinyPilot: Month 34
New here?
Hi, I’m Michael. I’m a software developer and the founder of TinyPilot, an independent computer hardware company. I started the company in 2020, and it now earns $60-80k/month in revenue and employs seven other people.
Every month, I publish a retrospective like this one to share how things are going with my business and my professional life overall.
Highlights
- We’ve completed transitioning TinyPilot’s fulfillment to a third-party vendor.
- The local team is escaping their months-long stint in “urgent mode.”
- Now that production speed isn’t a bottleneck, I can choose a price that optimizes for profitability.
Goal grades
At the start of each month, I declare what I’d like to accomplish. Here’s how I did against those goals: